Path params don't work with OpenAPI version 3.1.0
Fix: update your swagger-api/swagger-parser
dependency to version v2.1.12
https://github.com/swagger-api/swagger-parser/commit/b2a9442509fd95a51dadbdc97871bab7f506e339 is needed to work with OpenAPI 3.1.0.
Comments (5)
-
-
I ended up doing the same and reaching the same place with the debugger, there is a work around for this and its to set
System.setProperty("bind-type", "true")
. As explained here https://github.com/swagger-api/swagger-core/wiki/Swagger-2.X---OpenAPI-3.1is deserialized into a
Schema
class with populatedtypes
member with a single item array (whiletype
remains null).In order to allow for no change support of 3.1 processing by existing clients in specific limited scenarios, users can set system property
bind-type=true
to haveSchema.getType()
return the value of the single item ofSchema.types
in OAS 3.1 specifications with a non-arraySchema.type
. This is however NOT RECOMMENDED (see this comment).See also Foreword above, this choice has been implemented to allow to maintain the same APIs, even if it introduces some "less clean" code.
Please note that the above is not strictly related to OAS 3.1 / JSON Schema 2020/12, as
type
supports an array data type also in previous version, but this wasn't supported in Swagger Core versions < 2.2.x.So
swagger-request-validator
(specificallycom.atlassian.oai.validator.schema.SchemaValidator
) needs to be updated to useSchema.getTypes()
instead ofSchema.getType()
. -
The workaround mentioned by @ggorelik does not work when multiple types are needed.
-
Can we please get support for this? It’s a very common OpenAPI 3.1 scenario.
-
This is also an issue for us. Please can we get a timeline for possible resolution?
- Log in to comment
Running into this problem on 3.1.0 with a UUID path parameter. Seems to be tokenizing it for whatever reason. I ran through the debugger and I think I narrowed down the issue.
In
com.atlassian.oai.validator.schema.SchemaValidator
The above is reading
type
which is null in 3.1.0, it migrated to an array calledtypes
with 3.1.0. Thus, logic is falling through to line 15 and failing. Should return `createStringNode(value)`.Guessing this is related to how you can now define types in an array. See the following link on how nullables are now handled.
https://stackoverflow.com/questions/48111459/how-to-define-a-property-that-can-be-string-or-null-in-openapi-swagger