Skip to content
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

JSR 303 Validation for generated Models #5

Open
maschleg opened this issue Jun 12, 2015 · 5 comments
Open

JSR 303 Validation for generated Models #5

maschleg opened this issue Jun 12, 2015 · 5 comments

Comments

@maschleg
Copy link

It would be nice to have some validation for defined Models (Schema Objects). Swagger uses the JSON Schema Validation as Validation Specification.
This codegen Plugin cloud map the defined validation into JSR 303: Bean Validation. For example:

Swagger JSR 303
required @NotNull
maximum @max
minimum @min
pattern @pattern
jbellmann added a commit that referenced this issue Jun 26, 2015
@jbellmann
Copy link
Contributor

It is implemented (without 'pattern'). Please try out. Use true in the pom.

0.4.9

@ghost
Copy link

ghost commented Jul 30, 2015

Hi again!
Using version 0.4.12, still getting
'''
[INFO] Generate for language : jaxrsinterfaces
[INFO] JSR 303 enabled ...
[INFO] but not supported by jaxrsinterfaces
'''

because of this probles and issue related to swagger-codegen (you may see swagger-api/swagger-codegen#443 (comment) ; guys advices to test their develop_2.0 branch to check if issue still exists; but even it not exists, it need to be released first and then i think version of codegen used by your plugin must also be updated as well...) 'contract validation' implemented as set of ugly if blocks

@jkerak
Copy link

jkerak commented Oct 13, 2016

Is there a way yet to generate bean validation annotations on the generated pojos?

@jbellmann
Copy link
Contributor

@jkerak I would say it is (without 'pattern'). See here for a configuration-example. Does not work for JAX-RS, only implemented for Spring-***-templates.
Let me know how it worked for you (or if not open an issue and paste some stacktraces if possible)

@jkerak
Copy link

jkerak commented Oct 13, 2016

@jbellmann I ran that code sample and did not find it working. In the ApplicationDetails swagger definition, name is defined with minLength: 1. When I ran the integration tests and looked at the resulting ApplicationDetails.java, I expected to see an @Min annotation on the name property, but it is not there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants