-
Notifications
You must be signed in to change notification settings - Fork 83
Specifying minimum/maximum for date/date-time #411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Unfortunately I think the best you could do right now is to either add this as text in the description of the field (or in the bean) OR add an extension element. But I do not believe there is support for min/max of dates in OpenAPI or JSON Schema. You could try raising that as an issue in either or both of those communities. Because it's not something supported there, we cannot support it in microprofile-openapi. Is your goal to have the payloads actually validated using the OpenAPI schema, or is the schema just used for generating documentation? |
Thanks for the answer. I think we will add it to the description for now, since we're using the schema only for generating documentation. |
If you wanted to get fancy, you could annotate a field with an extension using the @Extension("x-minInclusive", "2010-01-01")
private Date myDateField; Then your filter would look for the |
Thank you for the suggestion. Our objects are actually defined in xsd-s and we are using jaxb to generate the java objects. We have a plugin for jaxb which annotates the objects with |
Closing, as there is no further action to take from a MicroProfile OpenAPI perspective. |
2.0.4 release
We are using micoprofile openApi for generating an API description for our REST endpoints, and have a date type property on one of our request objects, which is required to be later than a specific date (2010-01-01 in our case), however if we set minimum to "2010-01-01" on @Schema we get a NumberFormatException.
We already realized that OpenApi specification itself is based on the JSON Schema draft which explicitly specifies minimum/maximum as number and does not have any other property for this (maybe there will be once with some vocabulary: json-schema-org/json-schema-spec#116).
(Note: our dto-s are defined and validated by xsd-s, in which we can specify minimum for date ie.:
Our goal is to include this restriction in the openAPI definition as well.)
Do you have any suggestions (or workaround) to imply the given property has a minimum/maximum date in the API specification?
The text was updated successfully, but these errors were encountered: