Fixes #6169. Add OpenAPI Validator extension#8883
Conversation
b7c8360 to
d3926bc
Compare
| cqJvmSince: 3.37.0 | ||
| cqNativeSince: 3.37.0 |
There was a problem hiding this comment.
I guess it will be since 3.38.0, isn't it?
There was a problem hiding this comment.
Yes, you're right — it should be 3.38.0. Fixed in the latest push, thanks for catching that
| :cq-jvm-since: 3.37.0 | ||
| :cq-native-since: 3.37.0 |
There was a problem hiding this comment.
I guess it will be since 3.38.0, isn't it?
There was a problem hiding this comment.
Same as above — updated to 3.38.0. Thanks!
| .produce(new RuntimeInitializedClassBuildItem("com.github.fge.jackson.JsonNodeReader")); | ||
| runtimeInitializedClasses | ||
| .produce(new RuntimeInitializedClassBuildItem("com.github.fge.jackson.JsonLoader")); | ||
| runtimeInitializedClasses | ||
| .produce(new RuntimeInitializedClassBuildItem("com.github.fge.jsonschema.core.util.RegexECMA262Helper")); |
There was a problem hiding this comment.
Is it possible to use the Java method JsonNodeReader.class.getName() ?
it allows to detect deprecation and removal more easily when there are upgrades of the library dependency
There was a problem hiding this comment.
Great suggestion .updated all three RuntimeInitializedClassBuildItem entries to use class references. This will make it easier to catch breakages on dependency upgrades.
|
PR check failures are due to the usage of 3.38.0-SNAPSHOT version instead of 3.38.0-SNAPSHOT |
d3926bc to
c631889
Compare
|
@apupier Thanks for flagging.Updated all to 3.38.0-SNAPSHOT in the latest push. |
601e9a4 to
3398ced
Compare
|
The earlier failure was due to the generated flattened BOM files (poms/bom/src/main/generated/flattened-*.xml) still carrying 3.37.0-SNAPSHOT versions , a leftover from the rebase conflict resolution. I've since regenerated them with the correct 3.38.0-SNAPSHOT versions and force pushed. The CI check should pass now. |
| === Enabling Request Validation | ||
|
|
||
| To validate incoming requests against an OpenAPI specification, use the REST DSL with `clientRequestValidation` enabled: | ||
|
|
||
| [source,java] | ||
| ---- | ||
| rest().clientRequestValidation(true).openApi().specification("openapi.json"); | ||
|
|
||
| // Handler route — auto-wired by operationId from the spec | ||
| from("direct:addFruit") | ||
| .setBody(constant("Fruit created")); | ||
| ---- | ||
|
|
||
| Invalid requests are rejected with HTTP 400 and a validation report describing the errors. | ||
|
|
There was a problem hiding this comment.
We can probably remove this. It's a duplication of the Camel component documentation.
There was a problem hiding this comment.
Good point.removed. Kept only the Native Mode section since that's Quarkus-specific.Thanks
There was a problem hiding this comment.
There are uncommitted changes
HEAD detached at pull/8883/merge
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: docs/modules/ROOT/pages/reference/extensions/openapi-validator.adoc
You'll need to run mvn clean install in the openapi-validator extension module to regenerate the docs
There was a problem hiding this comment.
Sorry about that . Fixed now by running mvn process-classes on the deployment module and pushed the update.
3398ced to
070161c
Compare
Add a Camel Quarkus extension for the camel-openapi-validator component, providing native image support for JSON Schema validation of REST API requests against OpenAPI specifications. The extension registers reflective classes for keyword validators, native image resources for JSON Schema draft directories, and runtime-initialized classes required by the underlying Atlassian swagger-request-validator library. The integration test uses the REST DSL consumer with clientRequestValidation enabled to exercise the full validation path, including JSON Schema keyword validation for required fields and type checking.
070161c to
39ebfb9
Compare
Fixes #6169. Add OpenAPI Validator extension
camel-quarkus-openapi-validatorextension providing native image support for thecamel-openapi-validatorcomponent
runtime-initialized classes for the Atlassian swagger-request-validator library
clientRequestValidationto exercise the full JSON Schema validation path(required fields, type checking, missing body)