···11+import type { MaybeArray } from '../../../types/utils';
12import type { EnumExtensions } from '../../shared/types/openapi-spec-extensions';
23import type { OpenApiSchemaExtensions } from './spec-extensions';
34···144145 /**
145146 * If it is an array, it must be an array of strings, where each string is the name of one of the basic types, and each element is unique. In this case, the JSON snippet is valid if it matches any of the given types.
146147 */
147147- type?: JsonSchemaTypes | ReadonlyArray<JsonSchemaTypes>;
148148+ type?: MaybeArray<JsonSchemaTypes>;
148149 /**
149150 * The boolean keywords `readOnly` and `writeOnly` are typically used in an API context. `readOnly` indicates that a value should not be modified. It could be used to indicate that a `PUT` request that changes a value would result in a `400 Bad Request` response. `writeOnly` indicates that a value may be set, but will remain hidden. In could be used to indicate you can set a value with a `PUT` request, but it would not be included when retrieving that record with a `GET` request.
150151 */
···233233 (prop) => !removedProperties.has(prop),
234234 );
235235236236- if (filteredRequired.length === 0) {
236236+ if (!filteredRequired.length) {
237237 delete (schema as Record<string, unknown>).required;
238238 } else {
239239 (schema as Record<string, unknown>).required = filteredRequired;
+19-10
packages/openapi-ts/src/types/config.d.ts
···11import type { PluginConfigMap } from '../plugins/config';
22import type { Plugin, PluginNames } from '../plugins/types';
33-import type { Input, InputPath, Watch } from './input';
33+import type { Input, UserInput, Watch } from './input';
44import type { Logs } from './logs';
55import type { Output, UserOutput } from './output';
66import type { Parser, UserParser } from './parser';
77+import type { MaybeArray } from './utils';
7888-export interface UserConfigMultiOutputs extends Omit<UserConfig, 'output'> {
99- output: string | UserOutput | ReadonlyArray<string | UserOutput>;
1010-}
119export interface UserConfig {
1210 /**
1311 * Path to the config file. Set this value if you don't use the default
···3028 * object directly if you're fetching the file yourself.
3129 *
3230 * Alternatively, you can define a configuration object with more options.
3131+ *
3232+ * If you define an array, we will generate a single output from multiple
3333+ * inputs. If you define an array of outputs with the same length, we will
3434+ * generate multiple outputs, one for each input.
3335 */
3434- input: InputPath | Input | ReadonlyArray<InputPath | Input>;
3636+ input: MaybeArray<UserInput | Required<UserInput>['path']>;
3537 /**
3638 * Show an interactive error reporting tool when the program crashes? You
3739 * generally want to keep this disabled (default).
···4648 */
4749 logs?: string | Logs;
4850 /**
4949- * Path to the output folder. You can define an array to generate
5050- * multiple outputs from your input.
5151+ * Path to the output folder.
5252+ *
5353+ * If you define an array of outputs with the same length as inputs, we will
5454+ * generate multiple outputs, one for each input.
5155 */
5252- output: string | UserOutput;
5656+ output: MaybeArray<string | UserOutput>;
5357 /**
5458 * Customize how the input is parsed and transformed before it's passed to
5559 * plugins.
···138142 | 'watch'
139143> &
140144 Pick<UserConfig, 'base' | 'name' | 'request'> & {
141141- input: Omit<Input, 'path' | 'watch'> &
142142- Pick<Required<Input>, 'path'> & { watch: Watch };
145145+ /**
146146+ * Path to the input specification.
147147+ */
148148+ input: ReadonlyArray<Input>;
143149 logs: Logs;
150150+ /**
151151+ * Path to the output folder.
152152+ */
144153 output: Output;
145154 /**
146155 * Customize how the input is parsed and transformed before it's passed to
+89-6
packages/openapi-ts/src/types/input.d.ts
···11-export type InputPath =
11+type JsonSchema = Record<string, unknown>;
22+33+type ApiRegistryShorthands =
24 | `https://get.heyapi.dev/${string}/${string}`
35 | `${string}/${string}`
46 | `readme:@${string}/${string}#${string}`
57 | `readme:${string}`
66- | `scalar:@${string}/${string}`
77- | (string & {})
88- | Record<string, unknown>;
88+ | `scalar:@${string}/${string}`;
991010-export type Input = {
1010+export type UserInput = {
1111 /**
1212 * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
1313 *
···5353 * Both JSON and YAML file formats are supported. You can also pass the parsed
5454 * object directly if you're fetching the file yourself.
5555 */
5656- path?: InputPath;
5656+ path?: ApiRegistryShorthands | (string & {}) | JsonSchema;
5757 /**
5858 * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
5959 *
···8383 * @default false
8484 */
8585 watch?: boolean | number | Watch;
8686+};
8787+8888+export type Input = {
8989+ /**
9090+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
9191+ *
9292+ * Projects are private by default, you will need to be authenticated
9393+ * to download OpenAPI specifications. We recommend using project API
9494+ * keys in CI workflows and personal API keys for local development.
9595+ *
9696+ * API key isn't required for public projects. You can also omit this
9797+ * parameter and provide an environment variable `HEY_API_TOKEN`.
9898+ */
9999+ api_key?: string;
100100+ /**
101101+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
102102+ *
103103+ * You can fetch the last build from branch by providing the branch
104104+ * name.
105105+ */
106106+ branch?: string;
107107+ /**
108108+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
109109+ *
110110+ * You can fetch an exact specification by providing a commit sha.
111111+ * This will always return the same file.
112112+ */
113113+ commit_sha?: string;
114114+ /**
115115+ * You can pass any valid Fetch API options to the request for fetching your
116116+ * specification. This is useful if your file is behind auth for example.
117117+ */
118118+ fetch?: RequestInit;
119119+ /**
120120+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
121121+ *
122122+ * Organization created in Hey API Platform.
123123+ */
124124+ organization?: string;
125125+ /**
126126+ * Path to the OpenAPI specification. This can be:
127127+ * - path
128128+ * - URL
129129+ * - API registry shorthand
130130+ *
131131+ * Both JSON and YAML file formats are supported. You can also pass the parsed
132132+ * object directly if you're fetching the file yourself.
133133+ */
134134+ path: ApiRegistryShorthands | (string & {}) | JsonSchema;
135135+ /**
136136+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
137137+ *
138138+ * Project created in Hey API Platform.
139139+ */
140140+ project?: string;
141141+ /**
142142+ * If input path was resolved to a registry, this contains the registry
143143+ * identifier so we don't need to parse it again.
144144+ *
145145+ * @default undefined
146146+ */
147147+ registry?: 'hey-api' | 'readme' | 'scalar';
148148+ /**
149149+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
150150+ *
151151+ * If you're tagging your specifications with custom tags, you can use
152152+ * them to filter the results. When you provide multiple tags, only
153153+ * the first match will be returned.
154154+ */
155155+ tags?: ReadonlyArray<string>;
156156+ /**
157157+ * **Requires `path` to start with `https://get.heyapi.dev` or be undefined**
158158+ *
159159+ * Every OpenAPI document contains a required version field. You can
160160+ * use this value to fetch the last uploaded specification matching
161161+ * the value.
162162+ */
163163+ version?: string;
164164+ /**
165165+ * Regenerate the client when the input file changes? You can alternatively
166166+ * pass a numeric value for the interval in ms.
167167+ */
168168+ watch: Watch;
86169};
8717088171export type Watch = {
-12
packages/openapi-ts/src/types/types.d.ts
···1212 */
1313 headers: Headers;
1414 /**
1515- * Per-input watch state for multi-input mode. Keys should be a stable
1616- * identifier for the input (typically the URL or file path).
1717- */
1818- inputs?: Record<
1919- string,
2020- {
2121- headers: Headers;
2222- isHeadMethodSupported?: boolean;
2323- lastValue?: string;
2424- }
2525- >;
2626- /**
2715 * Can we send a HEAD request instead of fetching the whole specification?
2816 * This value will be set after the first successful fetch.
2917 */
+4
packages/openapi-ts/src/types/utils.d.ts
···1010};
11111212export type Files = Record<string, GeneratedFile>;
1313+1414+export type LazyOrAsync<T> = T | (() => T) | (() => Promise<T>);
1515+1616+export type MaybeArray<T> = T | ReadonlyArray<T>;