-
-
Notifications
You must be signed in to change notification settings - Fork 613
Closed
Description
Description
| Name | Version |
|---|---|
openapi-typescript |
6.1.1 |
| Node.js | 18.12.2 |
| OS + version | Ubuntu 22.04.2 |
Reproduction
- Create a file named api.json with the following content:
api.json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"User": {
"type": "object",
"additionalProperties": false,
"properties": {
"Info": {
"nullable": false
}
}
}
}
}
}- Run
openapi-typescript:
$ npx openapi-typescript api.json --output type.ts
✨ openapi-typescript 6.1.1
🚀 api.json → file:///path/to/type.ts [12ms]- You should get the following result:
type.ts
/**
* This file was auto-generated by openapi-typescript.
* Do not make direct changes to the file.
*/
export type paths = Record<string, never>;
export type webhooks = Record<string, never>;
export interface components {
schemas: {
User: {
Info?: Record<string, never>;
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
export type external = Record<string, never>;
export type operations = Record<string, never>;As you can see, schemas.User.Info is defined as Record<string, never> which is incorrect because Info might contain a string, number or boolean and not necessarily an object.
Expected result
export interface components {
schemas: {
User: {
Info?: unknown;
};
};
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}Checklist
- I’m willing to open a PR (see CONTRIBUTING.md)
felixschorer
Metadata
Metadata
Assignees
Labels
No labels