Skip to content

[JavaJaxrsResteasy] add @Valid to getter methods#2039

Closed
tnmtechnologies wants to merge 1 commit intoOpenAPITools:masterfrom
b-com:fix/JavaJaxrsResteasy_add_@Valid_to_getter_methods_when_bean_validation_is_enabled
Closed

[JavaJaxrsResteasy] add @Valid to getter methods#2039
tnmtechnologies wants to merge 1 commit intoOpenAPITools:masterfrom
b-com:fix/JavaJaxrsResteasy_add_@Valid_to_getter_methods_when_bean_validation_is_enabled

Conversation

@tnmtechnologies
Copy link
Copy Markdown
Contributor

@tnmtechnologies tnmtechnologies commented Feb 1, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

fix issue #1698

  • add @Valid to getter methods (pojo.mustache file)
  • update jaxrs-resteasy samples

@wing328 @jmini

@ApiModelProperty({{#example}}example = "{{{example}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}")
@JsonProperty("{{baseName}}")
{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} public {{{datatypeWithEnum}}} {{getter}}() {
{{#useBeanValidation}}{{>beanValidation}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime}}{{^isString}}{{^isFile}}@Valid{{/isFile}}{{/isString}}{{/isDateTime}}{{/isDate}}{{/isPrimitiveType}}{{/useBeanValidation}}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid blank lines, please use the following instead:

    {{#useBeanValidation}}
    {{>beanValidation}}{{^isPrimitiveType}}{{^isDate}}{{^isDateTime}}{{^isString}}{{^isFile}}@Valid{{/isFile}}{{/isString}}{{/isDateTime}}{{/isDate}}{{/isPrimitiveType}}
    {{/useBeanValidation}}

@@ -1,4 +1,6 @@
import io.swagger.annotations.*;
{{#useBeanValidation}}import javax.validation.Valid;{{/useBeanValidation}}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tnmtechnologies maybe we don't need another blank line here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, no problem to remove the blank line.

@wing328 wing328 added this to the 4.0.3 milestone Jun 25, 2019
@wing328 wing328 modified the milestones: 4.0.3, 4.1.0 Jul 9, 2019

@ApiModelProperty(value = "")
@JsonProperty("id")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which code style you following to put whitespace between method and annotations? Isn't redundant?

@wing328 wing328 modified the milestones: 4.1.0, 4.1.1 Aug 9, 2019
@wing328 wing328 modified the milestones: 4.1.1, 4.1.2 Aug 26, 2019
@wing328 wing328 modified the milestones: 4.1.2, 4.1.3 Sep 11, 2019
@wing328 wing328 modified the milestones: 4.1.3, 4.2.0 Oct 4, 2019
@wing328 wing328 removed this from the 4.2.0 milestone Oct 30, 2019
@martin-mfg
Copy link
Copy Markdown
Contributor

I addressed the remaining comments in #15064. Please have a look there.

@wing328 wing328 closed this Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants