-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[Java] [Spring] Spring new mapping annotations #7189
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
[Java] [Spring] Spring new mapping annotations #7189
Conversation
…rator into spring-new-mapping-annotations
dbdc78a
to
d6bbd51
Compare
@wing328 could you please review? |
produces = [{{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}}], {{/hasProduces}}{{#hasConsumes}} | ||
consumes = [{{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}}],{{/hasConsumes}}{{/singleContentTypes}} | ||
method = [RequestMethod.{{httpMethod}}]) | ||
@{{#lambda.titlecase}}{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}{{/lambda.titlecase}}Mapping( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using {{#lambda.titlecase}}{{#lambda.lowercase}} ... {{/lambda.lowercase}}{{/lambda.titlecase}}
is fine. Later I may switch it to something else (e.g. x-kotlin-http-method) to make it easier for new users to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello,
I just encountered a case where this change is actually blocking for me to upgrade from 4.3.1 to 5.x.x.
I do have an HTTP OPTIONS in my OpenAPI. This change generates an @OptionsMapping
, but it does not exist in Spring. The previous version with @RequestMapping
and setting the RequestMethod
was working for all HTTP methods. I admit, it is more verbose, but at least it covers the various cases.
This change is only viable once there are annotations *Mapping
for every RequestMethod
values in Spring.
You can find more information in this Spring issue where it is a bit discussed: spring-projects/spring-framework#18565
Can this change be reverted?
I'm using the Maven OpenAPi generator, and the generated spring code has "@OptionsMapping" annotations in several methods, but those annotations cannot be found anywhere. |
@billbarni @mwatel42 could you please create an issue for this? I'll fix this issue shortly. As for now there is no workaround other than downgrade of generator .. Or remove any |
Issue submitted #9773 (comment) @borsch I cannot simply change our production API to remove the support of HTTP OPTIONS, while it is a completely valid use case. |
If I downgrade I get a lot of: |
Replace old
@RequestMapping
with new@GetMapping
,@PostMapping
etc. Related issue: #7184./bin/generate-samples.sh
to update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*
. For Windows users, please run the script in Git BASH.master