Skip to content

Use class level validation - #4269

Closed
lehphyro wants to merge 2 commits into
OpenAPITools:masterfrom
lehphyro:use-class-level-validation
Closed

lehphyro wants to merge 2 commits into
OpenAPITools:masterfrom
lehphyro:use-class-level-validation

Conversation

@lehphyro

Copy link
Copy Markdown

@diyfr
Suggested fix for #4268, add a new parameter to choose which Spring validation behavior should be applied to the generated code.

@lehphyro
lehphyro force-pushed the use-class-level-validation branch from 14e2e33 to 0e74f97 Compare October 25, 2019 09:32
@wing328

wing328 commented Oct 25, 2019

Copy link
Copy Markdown
Member

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328

wing328 commented Oct 25, 2019

Copy link
Copy Markdown
Member

@lehphyro what about adding class-level validation without an additional option (which means it should be enabled by default)?

@wing328

wing328 commented Oct 25, 2019

Copy link
Copy Markdown
Member

cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04)

@lehphyro

Copy link
Copy Markdown
Author

@lehphyro what about adding class-level validation without an additional option (which means it should be enabled by default)?

That's the case currently, @Validated is always added to the controller interface which means Spring always throws ConstraintViolationException when there are validation errors, the suggested change is to make that optional.

@lehphyro
lehphyro force-pushed the use-class-level-validation branch from 0e74f97 to 77935fc Compare October 26, 2019 11:35
@wing328 wing328 removed this from the 4.2.0 milestone Oct 30, 2019
@lehphyro

lehphyro commented Jan 7, 2020

Copy link
Copy Markdown
Author

@wing328 this PR is open for quite some time even though it's very small, can we please merge it?

@lehphyro

Copy link
Copy Markdown
Author

@wing328 Please, could you help me merge this? I'm maintaining a fork of the project just because of it...

@lehphyro
lehphyro force-pushed the use-class-level-validation branch from 77935fc to 10ae79b Compare February 11, 2020 10:16
@lehphyro
lehphyro force-pushed the use-class-level-validation branch from 10ae79b to ecc5319 Compare April 29, 2020 16:36
@lehphyro

lehphyro commented May 1, 2020

Copy link
Copy Markdown
Author

@diyfr @bkabrda Could you please have a look and help me merge this PR?

@wing328

wing328 commented May 7, 2020

Copy link
Copy Markdown
Member

Sorry for late reply on this. Please PM via Slack to discuss on how to proceed with this PR.

@wing328

wing328 commented May 7, 2020

Copy link
Copy Markdown
Member

@lehphyro as discussed in Slack, what about using customized templates with the -t option instead as the option only changes one line in the template?

@wing328

wing328 commented May 7, 2020

Copy link
Copy Markdown
Member

To elaborate a bit more, the spring generator has too many options and we prefer to avoid adding another option to change just one line in the template.

@lehphyro

lehphyro commented May 7, 2020

Copy link
Copy Markdown
Author

As discussed in Slack, this option will allow users to select which Spring out-of-the-box behavior they'd like to use, so it's really about supporting Spring features.

The suggested change is to make spring throw MethodArgumentNotValidException instead of ConstraintViolationException, serialization of validation errors into a response body and amount of detail available change depending on which exception is thrown.

@lehphyro

Copy link
Copy Markdown
Author

Closed due to inactivity.

@lehphyro lehphyro closed this Dec 15, 2023
@lehphyro
lehphyro deleted the use-class-level-validation branch December 15, 2023 12:24
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.

2 participants