Validation annotations on @PathVariable/@RequestParam are ignored in generated OpenAPI schema + 'date' support - #299
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves generated API specs by (1) applying documented Bean Validation constraints to OpenAPI parameter schemas (path/query/header) and (2) adding explicit DATE field support in the JSON Schema generator, with corresponding sample endpoints and tests.
Changes:
- Apply
validationConstraintsfrom parameter descriptors to OpenAPI parameter schemas (min/max length, pattern, minimum/maximum). - Add
DATEtype support in JSON Schema generation astype: stringwithformat: date, plus optional format validation. - Add sample controller + integration tests demonstrating constrained request params/path variables and the resulting documentation.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/restdocs-api-spec-sample/src/test/java/com/epages/restdocs/apispec/sample/ProductSearchIntegrationTest.java | Adds sample integration tests that document/query/path parameter constraints via validationConstraints. |
| samples/restdocs-api-spec-sample/src/main/java/com/epages/restdocs/apispec/sample/ProductSearchController.java | Adds sample endpoints annotated with Bean Validation constraints on @RequestParam/@PathVariable. |
| restdocs-api-spec-openapi3-generator/src/test/kotlin/com/epages/restdocs/apispec/openapi3/OpenApi3GeneratorTest.kt | Adds assertions that parameter constraints are reflected in generated OpenAPI schemas. |
| restdocs-api-spec-openapi3-generator/src/main/kotlin/com/epages/restdocs/apispec/openapi3/OpenApi3Generator.kt | Implements constraint-to-schema mapping for OpenAPI parameter schemas. |
| restdocs-api-spec-jsonschema/src/test/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGeneratorTest.kt | Adds tests for DATE schema generation and stricter error messages for unsupported types. |
| restdocs-api-spec-jsonschema/src/main/kotlin/com/epages/restdocs/apispec/jsonschema/JsonSchemaFromFieldDescriptorsGenerator.kt | Implements DATE field schema generation and improves unsupported-type error messaging. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
meysamzamani
approved these changes
Jul 30, 2026
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.
No description provided.