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

Use OpenApiTagAttribute of class to set tags for those methods where such attribute is not set explicitly #2381

Merged
merged 4 commits into from Oct 8, 2019

Conversation

@korneyev
Copy link
Contributor

commented Aug 29, 2019

Currently OpenApiTagAttribute (and OpenApiTagsAttribute as well) has targets of both AttributeTargets.Class and AttributeTargets.Method.

But setting it as class attribute has no effect because OperationTagsProcessor uses only attributes from method and if no such attributes are present - processor uses controller class name.

Suggested change adds following OperationTagsProcessor logic: if no OpenApiTag atrtributes present at method, then try to get OpenApiTag (and OpenApiTags as well) from class, and if they are not present - then use controller class name as usual.

This can be helpful when controller contains a lot of methods and all of them should have the same tag(s).

…ttribute set for the class if they were not specified for method.
@korneyev korneyev changed the title Use OpenApiTagAttribute of controller to set tags for those methods where such attribute is not set explicitly Use OpenApiTagAttribute of class to set tags for those methods where such attribute is not set explicitly Aug 29, 2019
@RicoSuter

This comment has been minimized.

Copy link
Owner

commented Sep 9, 2019

Please also add a test

Andrey Korneev added 2 commits Sep 17, 2019
@korneyev

This comment has been minimized.

Copy link
Contributor Author

commented Sep 17, 2019

Please also add a test

I've added OperationTagsProcessorTests. Since OperationTagsProcessor is in NSwag.Generation assembly I have to add new test project NSwag.Generation.Tests

@korneyev

This comment has been minimized.

Copy link
Contributor Author

commented Oct 3, 2019

Please also add a test

@RicoSuter ping ;)

@RicoSuter RicoSuter merged commit 9d77bc4 into RicoSuter:master Oct 8, 2019
1 check passed
1 check passed
NSwag - CI Build #20191008.3 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.