ferdikoomen / openapi-typescript-codegen

NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification
MIT License
2.88k stars 520 forks source link

Empty models #1066

Open NikitaIT opened 2 years ago

NikitaIT commented 2 years ago

Describe the bug

https://github.com/vechain/thor/blob/master/api/doc/thor.yaml

For all models output looks like:

export const $Account = {
    properties: {
    },
} as const;
garcipat commented 2 years ago

Got this as well. All models generated have no properties, only the types defined. In the openapi.json document properties are defined properly.

ajenkinski commented 2 years ago

None of the schemas in the referenced OpenAPI spec specify a type. Adding type: object to the schemas causes the models to be correctly generated.

I don't know if the type property of schemas is supposed to be mandatory. This is certainly the first time I've seen an OpenAPI schema omit the type field, so I would have thought this OpenAPI spec is invalid. It seems like the author of this spec is assuming type is supposed to be optional, and it's supposed to default to object. If that's a valid assumption, then the fix is to make the generator implement that default.