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

Process @Parameters method parameters as Spring MergedAnnotations #668

Merged
merged 9 commits into from
May 19, 2020
Merged

Process @Parameters method parameters as Spring MergedAnnotations #668

merged 9 commits into from
May 19, 2020

Conversation

jryan128
Copy link
Contributor

@jryan128 jryan128 commented May 13, 2020

I noticed you used merged annotations while reading method annotations but not method parameters.
This allows the creation of Spring Merged annotations to avoid repeating ourselves:

@Target({PARAMETER, ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Parameter(name = "accountId")
public @interface AccountId {
    @AliasFor(annotation = Parameter.class, value = "example")
    String example() default "123456";
}

...

@GetMapping(value = "/example", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "example")
public Mono<Void> example(@PathVariable @AccountId String accountId) ...

I'll add tests if the maintainers think it's a good idea. Thanks!

@jryan128 jryan128 changed the title Process @Parameter annotations in method parameters as MergedAnnotations Process @Parameters method parameters as Spring MergedAnnotations May 13, 2020
@jryan128 jryan128 closed this May 13, 2020
@jryan128 jryan128 reopened this May 13, 2020
Copy link
Collaborator

@bnasslahsen bnasslahsen left a comment

Choose a reason for hiding this comment

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

Hi @jryan128,

Thank you for your contribution.
This feature seems interesting, but we need to keep compatiblity with older versions of spring as well.

Can you also keep the compatibility with spring-boot 1, because MergedAnnotations is only available since spring v5.2.

You can test it against the following example:

@jryan128
Copy link
Contributor Author

jryan128 commented May 17, 2020 via email

@jryan128
Copy link
Contributor Author

jryan128 commented May 18, 2020

After falling back to AnnotatedElementUtils, the Spring Boot 1 demo works fine. Please take a look. If you like the change and want to merge it let me know and I'll add more tests around it.

@bnasslahsen
Copy link
Collaborator

bnasslahsen commented May 18, 2020

Hi @jryan128,

It looks great. Can you please add some tests?
Once its ready, i will do the merge.

@jryan128 jryan128 requested a review from bnasslahsen May 19, 2020 20:46
@jryan128
Copy link
Contributor Author

Ready for review.

@bnasslahsen bnasslahsen merged commit 44acd06 into springdoc:master May 19, 2020
@bnasslahsen
Copy link
Collaborator

Great contribution @jryan128 👍

Thank you for this nice enhancement.
Its now merged with master.

@bnasslahsen bnasslahsen added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants