8000 Merge method-level and class-level @ApiResponses annotations. by sworisbreathing · Pull Request #1474 · springfox/springfox · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Merge method-level and class-level @ApiResponses annotations. #1474

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

Merged
merged 2 commits into from
Aug 31, 2016
Merged

Merge method-level and class-level @ApiResponses annotations. #1474

merged 2 commits into from
Aug 31, 2016

Conversation

sworisbreathing
Copy link
Contributor
@sworisbreathing sworisbreathing commented Aug 30, 2016

What's this PR do/fix?

Merges @ApiResponses annotations from method-level and type-level (at least, when annotated in the same class). Method-level annotations take priority over type-level annotations.

Are there unit tests? If not how should this be manually tested?

I have updated AnnotationsSpec to verify the behavior when the annotations are defined in the same class. I have not tested subclassing behavior. I have also manually tested against the example project I created for #1465 (https://github.com/sworisbreathing/springfox-issues)

Any background context you want to provide?

See #1465.

What are the relevant issues?

#1465

@@ -52,8 +53,16 @@ private Annotations() {
return fromNullable(findAnnotation(annotated, ApiOperation.class));
}

public static Optional<ApiResponses> findApiResponsesAnnotations(Method annotated) {
return fromNullable(findAnnotation(annotated, ApiResponses.class));
public static List<Optional<ApiResponses>> findApiResponsesAnnotations(AnnotatedElement annotated) {
Copy link
Member

Choose a reason for hiding this comment

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

List is monadic in itself, so just a returning a list of ApiResponses would suffice. i.e. don't add it to the list of the getAnnotation method returns a null. makes sense?

It'll make consumption in downstream processes easier, for e.g. we won't need a if (apiResponses.isPresent()) {...} block.

@dilipkrish
Copy link
Member

👍 looks good except for a minor nit! thanks for the PR! Super appreciated!

@dilipkrish dilipkrish added the PR label Aug 30, 2016
@dilipkrish dilipkrish added this to the 2.6.0 milestone Aug 30, 2016
@sworisbreathing
Copy link
Contributor Author
sworisbreathing commented Aug 31, 2016

Okay I've updated the PR to get rid of the Optionals in the List. Let me know what you think!

@dilipkrish dilipkrish merged commit 67c16f2 into springfox:master Aug 31, 2016
@dilipkrish
Copy link
Member

Thanks it looks great! Its in!! 🙇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0