Repository navigation
Conversation
What: the license object of an OpenAPI 3.1.0 document must not declare both url and identifier: an SPDX license expression and a license URL are mutually exclusive. A license declaring both is now reported when the info license validation is enabled (default): *ERROR* Section: APIInfo: 'url|identifier' in license -> The license url and identifier are mutually exclusive, only one of them should be set Why: the identifier field was introduced by OpenAPI 3.1.0 and the specification states that it is mutually exclusive of the url field, but the validator had no awareness of it (OpenAPITools#92). How: the check lives in the existing license validation of validateInfo(). The MicroProfile OpenAPI API the library is built against (3.1) declares no identifier accessor, and the CLI, Gradle and Maven plugins convert parsed specifications through empoa-swagger-core, whose license wrapper keeps the swagger model - carrying identifier - behind its getSw() accessor. The identifier is therefore read reflectively, first through getIdentifier() when the model provides it (e.g. MicroProfile OpenAPI 4.0), then through the swagger model behind an empoa wrapper, and no identifier is reported when neither is available. Note that the swagger-parser itself only carries license.identifier for licenses declaring no url: a license declaring both is rejected by the parser before the validator sees it, so file-based usage relies on the parser message until the parser models both fields. Tests use plain @test methods: junit-jupiter-params is declared testCompileOnly in the root build.gradle, so @ParameterizedTest methods compile but are silently skipped at runtime. Fixes OpenAPITools#92 Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
… url and identifier What: rewords the README bullet for the license url/identifier check from "only one of them should be set", which reads as one of the two being required, to "at most one of them may be set", matching what the check enforces: it reports a license declaring both fields, and a license declaring either one alone is fine. Why: addresses the review note on PR OpenAPITools#813. Signed-off-by: Inf1mum <vadimlazuk5@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The
identifierfield of the license object was introduced by OpenAPI 3.1.0, where it is mutually exclusive of theurlfield (an SPDX license expression and a license URL cannot both be declared). The validator now reports a license declaring both when the info license validation is enabled (default):A license declaring only one of the two fields is not affected, and neither are licenses validated against OAS 3.0 (where
identifiercannot appear).Why
The specification states that the
identifierfield is mutually exclusive of theurlfield, but the validator had no awareness of it (#92), so a specification declaring both passed validation silently.How
validateInfo(), right after thename|urlminimum check - no new option, since flagging it is never noisy: a license declaring both is invalid in every caseidentifieraccessor on the license model, and the CLI, Gradle and Maven plugins convert parsed specifications through empoa-swagger-core, whose license wrapper (SwLicense) keeps the swagger model - which does carryidentifier- behind itsgetSw()accessor. The identifier is therefore read reflectively: first throughgetIdentifier()when the model provides it (e.g. a MicroProfile OpenAPI 4.0 implementation), then through the swagger model behind an empoa wrapper, and no identifier is reported when neither is available. Once the MicroProfile OpenAPI dependency is aligned with OAS 3.1 (#798), the first lookup handles it directlylicense.identifierfor licenses declaring nourl- a license declaring both is already rejected by the parser as an unexpected attribute (in its own parse messages, which the CLI does not surface) before the validator sees it. So for file-based usage the parser reports the problem first; the new check covers model-based usage of the lib today and file-based usage if the parser ever models both fields@Testmethods on purpose: junit-jupiter-params is declaredtestCompileOnlyin the root build.gradle, so@ParameterizedTestmethods compile but are silently skipped at runtime (as noted in Validate that object schemas declare additionalProperties #812)Tests
lib module (plain
@Test):getIdentifier()(the way an OAS 3.1-aware model, e.g. MicroProfile OpenAPI 4.0, does) and a wrapper hiding it behindgetSw()(the empoa-swagger-core contract)ErrorAggregatorTestcovers the new aggregator methodcli module (end-to-end):
identifieralone passes validation with the default options, which exercises the real parse -> empoa conversion -> reflective read chain./gradlew buildis green with JDK 17.Summary by cubic
Reports an error when an OpenAPI 3.1 license sets both
urlandidentifier; either field alone remains valid. The check runs when info-license validation is enabled, which is the default.identifierreflectively because the model and wrapper APIs do not expose it directly.Written for commit 14ec313. Summary will update on new commits.