Skip to content

Add OpenAPI/Swagger support to minimal actions #30662

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
halter73 opened this issue Mar 4, 2021 · 8 comments
Closed

Add OpenAPI/Swagger support to minimal actions #30662

halter73 opened this issue Mar 4, 2021 · 8 comments
Assignees
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-minimal-actions Controller-like actions for endpoint routing Needs: Design This issue requires design work before implementating.
Milestone

Comments

@halter73
Copy link
Member

halter73 commented Mar 4, 2021

  • Ideally done using purely endpoint metadata
  • Might be done by leveraging Mvc.ApiExploer and implementing IApiDescriptionProvider
  • Otherwise, needs design
@halter73 halter73 added Needs: Design This issue requires design work before implementating. area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-minimal-actions Controller-like actions for endpoint routing labels Mar 4, 2021
@JamesNK
Copy link
Member

JamesNK commented Mar 4, 2021

I added Swashbuckle support using endpoint metadata for gRPC HTTP API

See: https://github.com/aspnet/AspLabs/tree/002b32674e5a4ff306158618f9d0789707e70753/src/GrpcHttpApi/src/Microsoft.AspNetCore.Grpc.Swagger

@mkArtakMSFT mkArtakMSFT added this to the Next sprint planning milestone Mar 8, 2021
@ghost
Copy link

ghost commented Mar 8, 2021

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@halter73 halter73 added area-servers and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Mar 30, 2021
@halter73 halter73 changed the title Add OpenAPI/Swagger support to MapAction Add OpenAPI/Swagger support to minimal actions May 7, 2021
@JamesNK JamesNK assigned JamesNK and unassigned jkotalik May 13, 2021
@JamesNK
Copy link
Member

JamesNK commented May 13, 2021

Initial thoughts:

  • Layering is an issue. Minimal actions are in Http.Extensions and Routing. Meanwhile, the ApiExplorer that Swagger integrates with is in Mvc.Abstractions. We don't want to have Http or Routing have a dependency on abstractions. That either means:

    • Recreating ApiExplorer that is independent of MVC (ApiExplorer itself depends on many MVC types like ActionDescriptor. Realistically a lot of Mvc.Abstractions would need to be created for this). If we did this then either swagger libraries like Swashbuckle would need to be extended to support it, or we would need to provide a wrapping over the top of it which populates the existing MVC ApiExplorer using data from the new MVC-less ApiExplorer.
    • Or a new project is created that depends on Route+Http and Mvc.Abstractions that glues them together (this is what I did with gRPC)
  • We need to figure out what a minimal action actually looks like. Right now RequestDelegateFactory is taking the delegate and is applying logic to it to create an opaque RequestDelegate. Either we:

    • Extend RequestDelegateFactory so it turns some kind of model of the request delegate along with the request delegate itself. e.g. how its parameters map to their sources, how its return type is formatted/run. This is good because there is one source of truth about binding and the model.
    • Duplicate much of the factory's logic in a new type that is responsible for generating a model. I worry about duplication and two types going out of sync.
  • If we recreate ApiExplorer+Mvc.Abstractions then the metadata about the minimal action could be a descriptor from this new thing. If we don't then we'll need a metadata descriptor that lives in routing/http.extensions that we figure out and then it is mapped to MVC's ActionDesciption.

@halter73 @davidfowl

@bradygaster
Copy link
Member

bradygaster commented Jun 10, 2021

Notes from our chat:

  • need to provide non-XML-docs method of allowing metadata customization. We'd need to satisfy the absolute minimum OpenAPI v2 metadata to pass a validator
  • okay to optimize for attributes for commentary/metadata over XML doc comments
  • planning on supporting OpenAPI v2 at first, V3 will come later
  • need to support customization of description and operationId
  • operationId should match the method name by default

@YohanSciubukgian
Copy link

@bradygaster is there any issue to track progress on OpenApi v3 support ?

@bradygaster
Copy link
Member

This repository would be the best spot. @halter73 do you think a separate issue for supporting v3 would be good so folks who care could follow it on their own and keep up?

@halter73
Copy link
Member Author

This issue didn't track any work that was specific to any version of OpenAPI/swagger. It's Swashbuckle that takes the ApiExplorer metadata and turns it into OpenAPI/swagger output. It looks like they already support v3 looking at their github. Same for NSwag apparently.

I haven't tested either with v3 though, because I don't even know what I'd be looking for. Are there any new features we'd be able to take advantage of?

@bradygaster
Copy link
Member

Good point @halter73 - if you're using either one of the major OpenAPI outputters, Swashbuckle or NSwag, they both support the output of all the various formats so you should be covered.

@danroth27 danroth27 added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jul 6, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 6, 2021
@amcasey amcasey added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-runtime labels Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-minimal-actions Controller-like actions for endpoint routing Needs: Design This issue requires design work before implementating.
Projects
None yet
Development

No branches or pull requests

9 participants