-
-
Notifications
You must be signed in to change notification settings - Fork 575
Closed as not planned
Closed as not planned
Copy link
Labels
enhancementNew feature or requestNew feature or requestopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript librarystale
Description
Description
If a payload has a required object field whose additionalProperties
specifies a schema for the values, the generated type shouldn't allow undefined
values.
OpenAPI
The real schema where I'm hitting this is here but this toy schema demonstrates the problem.
openapi: 3.0.1
components:
schemas:
Payload:
type: object
required:
- children
properties:
children:
type: object
additionalProperties:
type: object
required:
- field
properties:
field: string
Generated TS
export type paths = Record<string, never>;
export type webhooks = Record<string, never>;
export interface components {
schemas: {
Payload: {
children: {
[key: string]: {
field: string;
} | undefined;
};
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
export type external = Record<string, never>;
export type operations = Record<string, never>;
Expected TS
Same as above but without the | undefined
.
export type paths = Record<string, never>;
export type webhooks = Record<string, never>;
export interface components {
schemas: {
Payload: {
children: {
[key: string]: {
field: string;
};
};
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
export type external = Record<string, never>;
export type operations = Record<string, never>;
Checklist
- My OpenAPI schema passes a validator
- I’m willing to open a PR for this (see CONTRIBUTING.md)
michaelmass, K-Kielak, segiddins, severinh and naktinis
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestopenapi-tsRelevant to the openapi-typescript libraryRelevant to the openapi-typescript librarystale