-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] Migrating from openapi-generator-maven-plugin 5.0.0 to 5.0.1+/6.x+ doesnt apply @DecimalMin and @DecimalMax anymore to string field #16312
Comments
please try 7.0.0-beta release instead. 5.x release was a while ago |
7.0.0-beta version also results the same. 5.0.1 is just the version where we started seeing the issue. Checking the release notes, not sure what introduce this change. We are actually at 6.6.0. |
do you mind performing a git bisect to identify the commit causing the issue? |
My analysis leads to this merge - 2331432 Checking the commits, Not Working - Adds hasValidation to all java core Schema classes (#8474) - 2331432 Working - [PowerShell] minor fix to API doc - 3d23b99 Checked by building the project locally on these commit and testing with the minimal project provided earlier. |
thanks for identifying the issue. let me try to come up with a fix later. |
to fix the issue, use
|
You can specify the input like this: price:
type: string
format: number
minimum: -999999999999999999.99999
maximum: 999999999999999999.99999
description: Price This way price will still be a string for users of your API. In the generated code, it will be represented as If you also want to change the internal representation in the generated code to String, on top of the above change you can add a type mapping to your pom.xml like this: <generatorName>spring</generatorName>
<typeMappings>
<typeMapping>BigDecimal=String</typeMapping>
</typeMappings>
<!-- ... --> This will generate @Valid @DecimalMin("-1.0E+18") @DecimalMax("1.0E+18")
@Schema(name = "price", description = "Price", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
@JsonProperty("price")
public String getPrice() { |
Thanks @wing328 @martin-mfg for the workarounds. |
Description
We had a schema with type string that contained decimal value.
With 4.3.1 or 5.0.0 it use to @DecimalMax, @DecimalMin anootation based on
maximum/minimum
Starting from 5.0.1, it didnt added those
openapi-generator version
5.0.1 version (used to work in 5.0.0 and 4.3.1)
Also reproducible with the lates 6.6.0 (with spring boot 3)
OpenAPI declaration file content or url
Minimum example here -https://github.com/dhananjay12/learn-open-api/blob/string-decimal/sample-service/src/main/openapi/test-service-api-v1.yaml
Generation Details
https://github.com/dhananjay12/learn-open-api/blob/string-decimal/sample-service/pom.xml#L110
Steps to reproduce
In the pom.xml , with
openapi-generator-maven-plugin
version5.0.1
generated the code to see the reproduce the issue. With5.0.0
or4.3.1
its fine.Suggest a fix
Any workaround to achieve the same? (Add @DecimalMin and @DecimalMax annotation to string type)
The text was updated successfully, but these errors were encountered: