Closed esfox closed 1 month ago
Hey @esfox, is that a valid type? Why not make it string to begin with?
Actually I think you're right. It doesn't say here and in the Swagger docs too that json
is a valid type.
I tried changing the type in the spec to object
and it did translate to a valid type ({ [key: string]: unknown; }
).
Gonna close this issue. Thanks for the timely response!
No worries. Are you constructing the schema by hand? If so, why?
Actually no. It's just that in our backend, we actually use the Swagger module of NestJS and we defined a property of a class as @ApiProperty({ type: 'json', required: false })
. The type
field there apparently doesn't have static typing so json
was freely specified.
Description
If an object property in the spec is
type: json
, the generated type of that property intypes.gen.ts
isjson
, which is not a valid type in TypeScript, if I'm not mistaken. The linter suggestsJSON
, but I think thejson
type in the spec translates to a JSON string, and if so, the generated type of the field should bestring
.Expected
Actual
Reproducible example or configuration
No response
OpenAPI specification (optional)
System information (optional)
No response