Closed KaiSuchomel closed 1 year ago
I am getting similar error; could you please let me know when the fix will be available?
@KaiSuchomel The issue in your specific case is that the old OpenAPI specification is invalid with regards to defining arrays (emphasize is mine):
Arrays are defined as:
type: array items: type: string
Unlike JSON Schema, the
items
keyword is required in arrays. The value ofitems
is a schema that describes the type and format of array items.
https://swagger.io/docs/specification/data-models/data-types/#array
Your OpenAPI specification contains something like this:
--- core/src/test/resources/issue-423_1.yaml 2023-02-26 00:02:52
+++ core/src/test/resources/issue-423_2.yaml 2023-02-25 23:55:36
@@ -26,8 +26,8 @@
application/json:
schema:
type: array
- #items:
- # $ref: '#/components/schemas/OrganizationUnitCurrentConditionView'
+ items:
+ $ref: '#/components/schemas/OrganizationUnitCurrentConditionView'
When adding a (rather generic) type for the array items, things are working as expected:
--- core/src/test/resources/issue-423_1.yaml 2023-02-26 00:02:52
+++ core/src/test/resources/issue-423_2.yaml 2023-02-25 23:55:36
@@ -26,8 +26,8 @@
application/json:
schema:
type: array
items:
- type: object
+ $ref: '#/components/schemas/OrganizationUnitCurrentConditionView'
@joschi Both Yamls seems to be valid. (https://apitools.dev/swagger-parser/online/) We are getting the yamls from the Quarkus Extension (https://quarkus.io/guides/openapi-swaggerui). We are not able to change the generation of the yamls.
@KaiSuchomel Could you please open a bug report in the upstream project https://github.com/swagger-api/swagger-parser for this?
The parser doesn't recognize it as an array schema but only as a generic schema in your "old" version of the spec.
This being said, the OpenAPI spec is clear in that the items
property is required for array schemas.
I'd recommend opening a bug report in the Quarkus project and https://github.com/APIDevTools/swagger-parser, too.
Hey, with the attached yamls (see yamls.zip) we get the following Exception:
yamls.zip
Command:
java -jar cli/target/openapi-diff-cli-2.1.0-SNAPSHOT-all.jar openapi_prev.yaml openapi.yaml