Skip to content

Commit 1a35b77

Browse files
committed
feat: integrate ReadMe input format in configuration
1 parent 48636ae commit 1a35b77

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

packages/openapi-ts/src/config/input.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Config, UserConfig } from '../types/config';
2+
import { isReadmeInput, transformReadmeInput } from '../utils/readme';
23

34
const defaultWatch: Config['input']['watch'] = {
45
enabled: false,
@@ -38,7 +39,12 @@ export const getInput = (userConfig: UserConfig): Config['input'] => {
3839
};
3940

4041
if (typeof userConfig.input === 'string') {
41-
input.path = userConfig.input;
42+
// Handle ReadMe input format transformation
43+
if (isReadmeInput(userConfig.input)) {
44+
input.path = transformReadmeInput(userConfig.input);
45+
} else {
46+
input.path = userConfig.input;
47+
}
4248
} else if (
4349
userConfig.input &&
4450
(userConfig.input.path !== undefined ||
@@ -51,6 +57,11 @@ export const getInput = (userConfig: UserConfig): Config['input'] => {
5157
...userConfig.input,
5258
};
5359

60+
// Handle ReadMe input format transformation when path is specified
61+
if (typeof input.path === 'string' && isReadmeInput(input.path)) {
62+
input.path = transformReadmeInput(input.path);
63+
}
64+
5465
// watch only remote files
5566
if (input.watch !== undefined) {
5667
input.watch = getWatch(input);

packages/openapi-ts/src/types/config.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ export interface UserConfig {
1818
*/
1919
dryRun?: boolean;
2020
/**
21-
* Path to the OpenAPI specification. This can be either local or remote path.
21+
* Path to the OpenAPI specification. This can be either:
22+
* - local file
23+
*. - remote path
24+
* - ReadMe API Registry UUID (full and simplified formats)
25+
*
2226
* Both JSON and YAML file formats are supported. You can also pass the parsed
2327
* object directly if you're fetching the file yourself.
2428
*
2529
* Alternatively, you can define a configuration object with more options.
2630
*/
2731
input:
28-
| 'https://get.heyapi.dev/<organization>/<project>'
32+
| `https://get.heyapi.dev/${string}/${string}`
33+
| `readme:@${string}/${string}#${string}`
34+
| `readme:${string}`
2935
| (string & {})
3036
| (Record<string, unknown> & { path?: never })
3137
| Input;

packages/openapi-ts/src/types/input.d.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,18 @@ export type Input = {
3636
*/
3737
organization?: string;
3838
/**
39-
* Path to the OpenAPI specification. This can be either local or remote path.
39+
* Path to the OpenAPI specification. This can be either:
40+
* - local file
41+
*. - remote path
42+
* - ReadMe API Registry UUID (full and simplified formats)
43+
*
4044
* Both JSON and YAML file formats are supported. You can also pass the parsed
4145
* object directly if you're fetching the file yourself.
4246
*/
4347
path?:
44-
| 'https://get.heyapi.dev/<organization>/<project>'
48+
| `https://get.heyapi.dev/${string}/${string}`
49+
| `readme:@${string}/${string}#${string}`
50+
| `readme:${string}`
4551
| (string & {})
4652
| Record<string, unknown>;
4753
/**

0 commit comments

Comments
 (0)