-
-
Notifications
You must be signed in to change notification settings - Fork 46
Description
Describe the bug
When composing a model with allOf
, the validation of required fields doesn't work if an object is defined inside that same allOf
. It works if the composed model references a component model outside of it.
To Reproduce
I'm using version 1.6
of the plugin. When trying the latest 1.8
version it fails with an internal error (see Additional context section).
This doesn't fail:
components:
schemas:
Composition:
allOf:
- type: object
required:
- something
properties:
someotherthing:
type: array
items:
$ref: '#/components/schemas/Another'
- $ref: '#/components/schemas/Other'
Other:
type: string
example: "Other"
Another:
type: string
example: "Another"
This does fail:
components:
schemas:
Composition:
type: object
allOf:
- $ref: '#/components/schemas/This'
- $ref: '#/components/schemas/Other'
This:
type: object
required:
- something
properties:
someotherthing:
type: array
items:
$ref: '#/components/schemas/Another'
Other:
type: string
example: "Sample"
Another:
type: string
example: "Another"
...with this error:
[ERROR] OpenAPI Specification does not meet the requirements. Issues:
[ERROR] *ERROR* in Model 'This', property 'something' -> This property should be present or removed from the list of required
Minimal project to reproduce: test-required-fields.zip. Run mvn verify
with inputFile
as build-success-but-should-fail.yaml
and fails-and-it-should-fail.yaml
.
Expected behavior
Both of those examples should fail the validation of required fields.
Additional context
Internal error that I get in the minimal project on 1.8
version and validating build-success-but-should-fail.yaml
:
[ERROR] Failed to execute goal org.openapitools.openapistylevalidator:openapi-style-validator-maven-plugin:1.8:validate (default) on project test-required-fields: Execution default of goal org.openapitools.openapistylevalidator:openapi-style-validator-maven-plugin:1.8:validate failed: An API incompatibility was encountered while executing org.openapitools.openapistylevalidator:openapi-style-validator-maven-plugin:1.8:validate: java.lang.NoSuchMethodError: 'io.swagger.v3.oas.models.media.Schema io.swagger.v3.oas.models.media.ComposedSchema.addAllOfItem(io.swagger.v3.oas.models.media.Schema)'
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.openapitools.openapistylevalidator:openapi-style-validator-maven-plugin:1.8
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/[...]/.m2/repository/org/openapitools/openapistylevalidator/openapi-style-validator-maven-plugin/1.8/openapi-style-validator-maven-plugin-1.8.jar
[ERROR] urls[1] = file:/[...]/.m2/repository/org/openapitools/openapistylevalidator/openapi-style-validator-lib/1.8/openapi-style-validator-lib-1.8.jar
[ERROR] urls[2] = file:/[...]/.m2/repository/org/eclipse/microprofile/openapi/microprofile-openapi-api/3.0/microprofile-openapi-api-3.0.jar
[ERROR] urls[3] = file:/[...]/.m2/repository/io/swagger/parser/v3/swagger-parser/2.0.32/swagger-parser-2.0.32.jar
[ERROR] urls[4] = file:/[...]/.m2/repository/io/swagger/parser/v3/swagger-parser-v2-converter/2.0.32/swagger-parser-v2-converter-2.0.32.jar
[ERROR] urls[5] = file:/[...]/.m2/repository/io/swagger/swagger-core/1.6.6/swagger-core-1.6.6.jar
[ERROR] urls[6] = file:/[...]/.m2/repository/io/swagger/swagger-models/1.6.6/swagger-models-1.6.6.jar
[ERROR] urls[7] = file:/[...]/.m2/repository/io/swagger/swagger-annotations/1.6.6/swagger-annotations-1.6.6.jar
[ERROR] urls[8] = file:/[...]/.m2/repository/com/google/guava/guava/31.0.1-android/guava-31.0.1-android.jar
[ERROR] urls[9] = file:/[...]/.m2/repository/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar
[ERROR] urls[10] = file:/[...]/.m2/repository/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
[ERROR] urls[11] = file:/[...]/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar
[ERROR] urls[12] = file:/[...]/.m2/repository/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar
[ERROR] urls[13] = file:/[...]/.m2/repository/org/checkerframework/checker-compat-qual/2.5.5/checker-compat-qual-2.5.5.jar
[ERROR] urls[14] = file:/[...]/.m2/repository/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar
[ERROR] urls[15] = file:/[...]/.m2/repository/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar
[ERROR] urls[16] = file:/[...]/.m2/repository/javax/validation/validation-api/1.1.0.Final/validation-api-1.1.0.Final.jar
[ERROR] urls[17] = file:/[...]/.m2/repository/io/swagger/swagger-parser/1.0.59/swagger-parser-1.0.59.jar
[ERROR] urls[18] = file:/[...]/.m2/repository/io/swagger/swagger-compat-spec-parser/1.0.59/swagger-compat-spec-parser-1.0.59.jar
[ERROR] urls[19] = file:/[...]/.m2/repository/com/github/java-json-tools/json-schema-validator/2.2.14/json-schema-validator-2.2.14.jar
[ERROR] urls[20] = file:/[...]/.m2/repository/com/github/java-json-tools/jackson-coreutils-equivalence/1.0/jackson-coreutils-equivalence-1.0.jar
[ERROR] urls[21] = file:/[...]/.m2/repository/com/github/java-json-tools/json-schema-core/1.2.14/json-schema-core-1.2.14.jar
[ERROR] urls[22] = file:/[...]/.m2/repository/com/github/java-json-tools/uri-template/0.10/uri-template-0.10.jar
[ERROR] urls[23] = file:/[...]/.m2/repository/org/mozilla/rhino/1.7.7.2/rhino-1.7.7.2.jar
[ERROR] urls[24] = file:/[...]/.m2/repository/com/sun/mail/mailapi/1.6.2/mailapi-1.6.2.jar
[ERROR] urls[25] = file:/[...]/.m2/repository/joda-time/joda-time/2.10.5/joda-time-2.10.5.jar
[ERROR] urls[26] = file:/[...]/.m2/repository/com/googlecode/libphonenumber/libphonenumber/8.11.1/libphonenumber-8.11.1.jar
[ERROR] urls[27] = file:/[...]/.m2/repository/net/sf/jopt-simple/jopt-simple/5.0.4/jopt-simple-5.0.4.jar
[ERROR] urls[28] = file:/[...]/.m2/repository/com/github/java-json-tools/json-patch/1.13/json-patch-1.13.jar
[ERROR] urls[29] = file:/[...]/.m2/repository/com/github/java-json-tools/msg-simple/1.2/msg-simple-1.2.jar
[ERROR] urls[30] = file:/[...]/.m2/repository/com/github/java-json-tools/btf/1.3/btf-1.3.jar
[ERROR] urls[31] = file:/[...]/.m2/repository/com/github/java-json-tools/jackson-coreutils/2.0/jackson-coreutils-2.0.jar
[ERROR] urls[32] = file:/[...]/.m2/repository/org/apache/httpcomponents/httpclient/4.5.13/httpclient-4.5.13.jar
[ERROR] urls[33] = file:/[...]/.m2/repository/org/apache/httpcomponents/httpcore/4.4.13/httpcore-4.4.13.jar
[ERROR] urls[34] = file:/[...]/.m2/repository/commons-logging/commons-logging/1.2/commons-logging-1.2.jar
[ERROR] urls[35] = file:/[...]/.m2/repository/commons-codec/commons-codec/1.11/commons-codec-1.11.jar
[ERROR] urls[36] = file:/[...]/.m2/repository/io/swagger/parser/v3/swagger-parser-core/2.0.32/swagger-parser-core-2.0.32.jar
[ERROR] urls[37] = file:/[...]/.m2/repository/io/swagger/parser/v3/swagger-parser-v3/2.0.32/swagger-parser-v3-2.0.32.jar
[ERROR] urls[38] = file:/[...]/.m2/repository/io/swagger/core/v3/swagger-core/2.2.0/swagger-core-2.2.0.jar
[ERROR] urls[39] = file:/[...]/.m2/repository/jakarta/xml/bind/jakarta.xml.bind-api/2.3.2/jakarta.xml.bind-api-2.3.2.jar
[ERROR] urls[40] = file:/[...]/.m2/repository/jakarta/activation/jakarta.activation-api/1.2.1/jakarta.activation-api-1.2.1.jar
[ERROR] urls[41] = file:/[...]/.m2/repository/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.13.2/jackson-datatype-jsr310-2.13.2.jar
[ERROR] urls[42] = file:/[...]/.m2/repository/io/swagger/core/v3/swagger-annotations/2.2.0/swagger-annotations-2.2.0.jar
[ERROR] urls[43] = file:/[...]/.m2/repository/jakarta/validation/jakarta.validation-api/2.0.2/jakarta.validation-api-2.0.2.jar
[ERROR] urls[44] = file:/[...]/.m2/repository/com/fasterxml/jackson/core/jackson-annotations/2.13.2/jackson-annotations-2.13.2.jar
[ERROR] urls[45] = file:/[...]/.m2/repository/com/fasterxml/jackson/core/jackson-databind/2.13.2.2/jackson-databind-2.13.2.2.jar
[ERROR] urls[46] = file:/[...]/.m2/repository/com/fasterxml/jackson/core/jackson-core/2.13.2/jackson-core-2.13.2.jar
[ERROR] urls[47] = file:/[...]/.m2/repository/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.13.2/jackson-dataformat-yaml-2.13.2.jar
[ERROR] urls[48] = file:/[...]/.m2/repository/org/yaml/snakeyaml/1.30/snakeyaml-1.30.jar
[ERROR] urls[49] = file:/[...]/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar
[ERROR] urls[50] = file:/[...]/.m2/repository/org/openapitools/empoa/empoa-swagger-core/2.0.0/empoa-swagger-core-2.0.0.jar
[ERROR] urls[51] = file:/[...]/.m2/repository/io/swagger/core/v3/swagger-models/2.1.2/swagger-models-2.1.2.jar
[ERROR] urls[52] = file:/[...]/.m2/repository/org/apache/commons/commons-lang3/3.8.1/commons-lang3-3.8.1.jar
[ERROR] urls[53] = file:/[...]/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.5/org.eclipse.sisu.inject-0.3.5.jar
[ERROR] urls[54] = file:/[...]/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[55] = file:/[...]/.m2/repository/org/codehaus/plexus/plexus-utils/3.3.0/plexus-utils-3.3.0.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]