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

Add doc on excluding endpoints in controller-based apps #33773

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mikekistler
Copy link
Contributor

@mikekistler mikekistler commented Oct 3, 2024

This PR updates the section of the OpenAPI doc on excluding endpoints to describe how this can be done in controller-based apps.

fixes: dotnet/aspnetcore#57425


Internal previews

📄 File 🔗 Preview link
aspnetcore/fundamentals/openapi/aspnetcore-openapi.md Generate OpenAPI documents


In controller-based apps, the <xref:Microsoft.AspNetCore.Mvc.ApiExplorerSettingsAttribute> attribute can be used to exclude an endpoint from the OpenAPI document.

The following example demonstrates how to exclude an endpoint from the generated OpenAPI document.
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to add that this also applies for committing entire controller classes?

Copy link
Member

@captainsafia captainsafia left a comment

Choose a reason for hiding this comment

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

LGTM outside of one small nit.

Copy link
Contributor

@Rick-Anderson Rick-Anderson left a comment

Choose a reason for hiding this comment

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

Consider my suggestions.
Let me know when we can S&M, or you can merge when you're ready.

Comment on lines +331 to +332
By default, all endpoints that are defined in an app are documented in the generated OpenAPI file,
but endpoints can be excluded from the document using attributes or extension methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
By default, all endpoints that are defined in an app are documented in the generated OpenAPI file,
but endpoints can be excluded from the document using attributes or extension methods.
By default, all endpoints that are defined in an app are documented in the generated OpenAPI file, but endpoints can be excluded from the document using attributes or extension methods.


By default, all endpoints that are defined in an app are documented in the generated OpenAPI file. Minimal APIs support two strategies for excluding a given endpoint from the OpenAPI document, using:
The mechanism for specifying an endpoint should be excluded depends on the type of app being developed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The mechanism for specifying an endpoint should be excluded depends on the type of app being developed.
The mechanism for specifying an endpoint that should be excluded depends on the type of app being developed.


##### [Minimal APIs](#tab/minimal-apis)

Minimal APIs support two strategies for excluding a given endpoint from the OpenAPI document, using:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Minimal APIs support two strategies for excluding a given endpoint from the OpenAPI document, using:
Minimal APIs support two strategies for excluding a given endpoint from the OpenAPI document:


In controller-based apps, the <xref:Microsoft.AspNetCore.Mvc.ApiExplorerSettingsAttribute> attribute can be used to exclude an endpoint from the OpenAPI document.

The following example demonstrates how to exclude an endpoint from the generated OpenAPI document.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The following example demonstrates how to exclude an endpoint from the generated OpenAPI document.
The following example demonstrates how to exclude an endpoint from the generated OpenAPI document:

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

Successfully merging this pull request may close these issues.

ExcludeFromDescriptionAttribute not excluding controller actions from OpenAPI document
3 participants