Repository navigation
Conversation
What: OpenAPI 3.1.0 requires at least one of `paths`, `components` or `webhooks` to exist at the top level of a document: a specification describing only webhooks, or only reusable components, is valid. The structural check flagged documents that declare neither `paths` nor `components` without considering `webhooks`, so a webhooks-only document was reported in error. The check now also treats the document as non-empty when webhooks are declared, and the message names the three alternatives. The MicroProfile OpenAPI API the library is built against (3.1) declares no `webhooks` accessor, so webhooks are read reflectively: through `getWebhooks()` when the model provides it (e.g. a MicroProfile OpenAPI 4.0 implementation), then through the swagger model behind an empoa-swagger-core wrapper (the path taken by the CLI, Gradle and Maven plugins); a model exposing neither is considered to have no webhooks. Why: the specification makes webhooks a first alternative to paths and components, and the validator had no awareness of it (OpenAPITools#93), so valid webhooks-only documents failed the structural check. Fixes OpenAPITools#93 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
What: the tests now build the webhooks maps with Collections.singletonMap and Collections.emptyMap instead of Map.of, which the codebase cannot use: the build targets Java 8 and Map.of is Java 9+. The reflective read of the swagger model behind an empoa wrapper also handles a null return of getSw() by considering the document free of webhooks, as the method comment describes, instead of failing with a NullPointerException. Why: addresses two review notes on PR OpenAPITools#816. 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.
Fixes #93
Problem
OpenAPI 3.1 allows a document with only
webhooksor onlycomponentsat the top level, but the structural check added for #190 only knewpaths/components, so a valid webhooks-only document was reported as an error.Change
Declared webhooks now count as content, and the message names all three alternatives:
paths, components or webhooks.The MicroProfile OpenAPI API the library builds against (3.1) has no
webhooksaccessor, so webhooks are read reflectively:getWebhooks()first, then the swagger model behind an empoa-swagger-core wrapper (SwOpenAPI#getSw()); a model exposing neither counts as no webhooks — until MicroProfile OpenAPI is aligned with OAS 3.1 (#798). An emptywebhooksobject counts as present, consistent withpathssince #190. The check stays always-on, no new option (same reasoning as #813).Verification
lib tests: webhooks-only passes through both model shapes, an empty
webhookscounts as present, none of the three gets the exact new message;ErrorAggregatorTestcovers the renamed aggregator method. cli: an end-to-end webhooks-only 3.1 spec passes with default options../gradlew build -x :openapi-style-validator-gradle-plugin:functionalTestgreen on JDK 21 (the exclusion is the known Gradle 7.6 vs JDK 21 incompatibility; upstream CI runs it).Summary by cubic
Fixes the top-level structure check so valid OpenAPI 3.1 documents declaring only webhooks (or only reusable components) no longer fail with a false "missing paths or components" error. The check now requires at least one of
paths,components, orwebhooks, and the error message names all three.Implementation notes
webhooksaccessor: the lookup triesgetWebhooks()first, then the swagger model behind an empoa-swagger-core wrapper, matching how the CLI, Gradle and Maven plugins parse documents. A missing swagger model is treated as having no webhooks.webhooksobject counts as present, consistent withpathsandcomponents.Written for commit 4a4eb73. Summary will update on new commits.