Skip to content

Expose a middleware to output Open API description for a certain OData service #62

Open

Description

@xuzhg

Maybe we can have an extension middleware to expose the OpenAPI description for a certain OData service.

For example:

public class ODataOpenApiMiddleware
{
    private readonly RequestDelegate next;

    public ODataOpenApiMiddleware(RequestDelegate next)
    {
        this.next = next;
    }

    public async Task Invoke(HttpContext context)
    {
        // implementation here
    }
}

Extension method:

public static IApplicationBuilder UseODataOpenApi(this IApplicationBuilder app)
{
    return app.UseMiddleware<ODataOpenApiMiddleware>();
}

Configure the Middleware:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{

       app.UseODataOpenApi();

       app.UseRouting();

       app.UseEndpoints(...);
}

Activity

  1. Vaevictus commented on Jan 18, 2022

    @Vaevictus

    This would be a very useful middleware and will help feed swagger.json files to the openapi explorer

  2. darrelmiller commented on Mar 1, 2022

    @darrelmiller
    Member

    Sam Xu (@xuzhg) Wouldn't it make more sense for that middleware to be in here https://github.com/OData/AspNetCoreOData ?

  3. xuzhg commented on Mar 1, 2022

    @xuzhg
    ContributorAuthor

    Darrel (@darrelmiller) actually, we already have a sample for OpenApi OData middelware at https://github.com/OData/AspNetCoreOData/tree/main/sample/ODataRoutingSample/OpenApi.

    It's for raw OpenAPI description of OData. Thanks.

  4. darrelmiller commented on Mar 25, 2023

    @darrelmiller
    Member

    I don't believe that this library should be implementing features that are dependent on ASP.Net.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-discussionAn issue that requires more discussion internally before resolvingtype:enhancementEnhancement request targeting an existing experience.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions