You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When modeling a schema object with an array property with items of type string and the minLength validation set, the generated code is missing an import to jakarta.validation.constraints.Size or the annotation must use its FQCN when using Bean Validation.
/** * Some object to be validated **/@jakarta.ws.rs.QueryParam("_list")
privateList<@Size(min = 1)String> _list = null;
Compilation error:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[227,23] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject.ValidatedObjectQueryParam
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[332,22] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject.ValidatedObjectQueryParam
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[339,35] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject.ValidatedObjectQueryParam
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[343,54] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject.ValidatedObjectQueryParam
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[39,19] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[135,18] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[142,31] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject
[ERROR] ./client/integration-tests/bean-validation/target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java:[146,40] cannot find symbol
symbol: class Size
location: class org.openapi.quarkus.bean_validation_true_yaml.model.ValidatedObject
The text was updated successfully, but these errors were encountered:
For fun I looked at this and as I understand it, the @Size annotation is added by the OpenAPI generator, so either you add an import in the beginning of the file or you somehow modify the code that OpenAPI generator generates.
Or am I missing something in the code? I have tried to look if there is some code that alters the code that's generated, but I can't find it when looking in the code and tried solving the issue.
Edit 1:
I have now checked a bit more and realized that the "problem" lies here:
v.datatypeWithEnum that I understand comes from the OpenAPI generator is in this case List<@Size(min = 1)String>, I can't find an good way to add so we get an FQCN in the annotation. The simplest solution is to add an import, but I know @hbelmiro has said thats not what's the goal. What also looks like a problem is that the code in beanValidationCore.qute doesn't handle Lists.
@denvitaharen you can open a PR to change the template by adding the FQCN to the annotation. 👍
Adding the import is not an option because we can't possibly know for sure if it will include @Size in the generated code.
Alternatively, you can add this import to the list of imports (see our subclasses of JavaGenerator from the openapi-gen lib) if validation is enabled and the POJOs would have these annotations.
When modeling a schema object with an
array
property with items of typestring
and theminLength
validation set, the generated code is missing an import tojakarta.validation.constraints.Size
or the annotation must use its FQCN when using Bean Validation.Example:
Generated code:
target/generated-sources/open-api-yaml/org/openapi/quarkus/bean_validation_true_yaml/model/ValidatedObject.java
Compilation error:
The text was updated successfully, but these errors were encountered: