-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Hello,
I'm using swagger codegen maven plugin to auto-generate endpoints and models for a REST API project. I personalize mustache template to generate javax.validation annotations such as
@Valid, @min, @max, @SiZe, @pattern, etc... on Query/PathParam and Models
So far I'm facing to those 2 Issues :
- {{minimum}} and {{maximum}} returns Double values because of CodegenProperty minimum and maximum types which are Double (and I understand it could be useful to have Double instead of Integer...)
Issue is that I can't use @min({{minimum}}) and @max({{maximum}}) on my mustache templates : it will break at compilation because it requires Integer values instead of Double
Now I'm looking for a fancy solution without modifying codegen source code if possible. Is CodegenProperty overridable by config ? Is there any secret param I can use to change that behavior ? - For Endpoint QueryParams, I have this problem : @NotNull must be added only if required = true, but I can only test if tag 'required' is present or not, through {{#required}}, and so I cannot use same tricks than in java's templates
So far I can work-around this issue by deleting all 'required = false' in swagger specification yaml and using {{#required}}@NotNull{{/required}} but this will generate functional issues if people modify yaml...
So I was looking for some kind of isRequired tag or another solution without modifying codegen source if possible, but haven't found one yet.
At worst, if those issues are not solvable by config, is extending AbstractJavaJAXRSServerCodegen a good idea to generate new properties and use them for mustache templates ?
FYI I'm adding my overrides of jaxrs-cxf templates (dev on-going...), maybe it can help to understand/reproduce
jaxrs-cxf_javax_validation_mustache_templates.zip
I'll be glad to post those templates and contribute to this project once all issues solved.
Thanks and regards,
Florent Barreau