Skip to content

WithOpenApi generates annotations for endpoints without MethodInfo #47346

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

Closed
wants to merge 2 commits into from

Conversation

captainsafia
Copy link
Member

@captainsafia captainsafia commented Mar 21, 2023

Closes #44970.

Our current OpenAPI-implementation does not generate OpenAPI specs from endpoints that are derived from a RequestDelegate. For most scenarios, this is a reasonable approach as developers might not want endpoints used for health-checks to show up in their OpenAPI annotations. In some cases, it's helpful to display OpenAPI specs even if the endpoint is sourced from a RequestDelegate.

This PR makes it so that invoking WithOpenApi on an endpoint will generate OpenAPI info even if it is source from a request delegate.

app.MapGet("/authorize", (HttpContext context) => ...).WithOpenApi();

Will generate an OpenAPI operation that:

  • contains no parameters
  • emits no response
  • respects tags, summary, and annotation attributes

@ghost ghost added the old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Mar 21, 2023
@ilmax
Copy link
Contributor

ilmax commented Mar 21, 2023

Will this allow health check endpoints to be exposed in the Swagger document

@captainsafia
Copy link
Member Author

Will this allow health check endpoints to be exposed in the Swagger document

Not quite. Ran into a hiccup with this that is more or less related to #44209. Need to go back to the drawing board on this one :/....

@captainsafia captainsafia deleted the safia/woa-rd-api branch November 5, 2024 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RequestDelegate-based handlers do not surface in OpenAPI descriptions
2 participants