openapi-typescript
openapi-typescript copied to clipboard
--enum-values tries to access array props like if they were objects in order to define the array type
openapi-typescript version
7.6.1
Node.js version
v20.17.0
OS + version
Arch Linux
Description
export interface components {
schemas: {
BatchMappingItemRequest: {
data: {
/** @enum {string} */
mode?: "create" | "update" | "delete";
}[];
};
}
export const batchMappingItemRequestDataModeValues: ReadonlyArray<components["schemas"]["BatchMappingItemRequest"]["data"]["mode"]> = ["create", "update", "delete"];
Since data is an array you won't be able to access mode on components["schemas"]["BatchMappingItemRequest"]["data"]["mode"] (Property 'mode' does not exist on type).
Reproduction
See description.
Expected result
type FlattenedDeepRequired<T> = {
[K in keyof T]: Required<FlattenedDeepRequired<T[K] extends unknown[] ? T[K][number] : T[K]>>;
};
type ReadonlyArray<T> = [
Exclude<T, undefined>
] extends [
any[]
] ? Readonly<Exclude<T, undefined>> : Readonly<Exclude<T, undefined>[]>;
export const batchMappingItemRequestDataModeValues: ReadonlyArray<FlattenedDeepRequired<components>["schemas"]["BatchMappingItemRequest"]["data"]["mode"]> = ["create", "update", "delete"];
Required
- [x] My OpenAPI schema is valid and passes the Redocly validator (
npx @redocly/cli@latest lint)
Extra
- [x] I’m willing to open a PR (see CONTRIBUTING.md)