Closed erkstruwe closed 8 months ago
We are having the same issue over here, this is a breaking change.
So, what do we do? Maintain two versions for each version of OpenAPI?
I'm completely open to suggestions. It sounds like NestJS isn't going to update their OpenAPI Spec anytime soon.
Maybe we create an option to specify what API spec you want to use and generate to that one?
NestJS's @nestjs/swagger
uses a hardcoded OpenAPI version 3.0 here.
Given the progress this library has made towards OpenAPI 3.1, I can imagine it makes sense to keep types according to OpenAPI 3.1 throughout the zod-openapi
package (e. g. extendApi
parameters) and to manually change this "back" to OpenAPI 3.0 in zod-nestjs
. After all, the list of changes is rather brief.
From my point of view, SchemaHolderClass._OPENAPI_METADATA_FACTORY() would be a good place to pull that off by altering the generatedSchema
.
Alternatively, we could add a version parameter to zod-openapi
's generateSchema
function and handle the differences there. However, this could make typing more difficult (e. g. how should a user choose which version to target when using extendApi
?).
@Brian-McBride I drafted a PR for the "nullable" and "exclusive limits" issues. Could you please let me know what you think about it? Thanks!
@erkstruwe how do we opt-in into that? If I don't explicitly pin @anatine/zod-openapi
to 2.2.1
I still have the issue.
Hi there and thanks for your awesome library!
179 changed
null
handling from OpenAPI 3.0 to OpenAPI 3.1 syntax (fromnullable: true
totype: [..., "null"]
.According to OpenAPI 3.0 documentation at https://swagger.io/docs/specification/data-models/data-types/, the syntax now used is explicitly marked as "incorrect". Thus, schemas created in NestJS using
zod-openapi
andzod-nestjs
(which uses OpenAPI 3.0) are no longer working with downstream tools such asopenapi-generator
(e. g. withtypescript-axios
).How can we get nullable attributes to work again?