Fix for openapi-typescript issue with empty swagger spec components.schema object
The swagger openapi v3.0.3 json that the Fastify Swagger plugin generates includes an empty schema object field when there are no schemas present. The openai-trypescript tool has issues dealing with this empty object when trying to generate typescript types programatically.
swagger.d.ts
.
.
.
export interface components {
schemas: {
}; -- wrong type, this means "any non-nullish value". It should be schemas: never
responses: never;
parameters: never;
requestBodies: never;
headers: never;
pathItems: never;
}
.
.
.
Two work arounds:
- Delete the empty component.schema object from the swagger file before generating the types.
- Upgrade openapi-typescript version to
next
where this bug is fixed. At time of writing the version where this is fixed is not released yet. The current latest published version is6.7.5
, the next version where this is fixed should be ~7.0.0
.