OpenAPI.NET.OData icon indicating copy to clipboard operation
OpenAPI.NET.OData copied to clipboard

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

Open xuzhg opened this issue 4 years ago • 4 comments

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(...);
}

xuzhg avatar May 20 '20 17:05 xuzhg

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

Vaevictus avatar Jan 18 '22 13:01 Vaevictus

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

darrelmiller avatar Mar 01 '22 14:03 darrelmiller

@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.

xuzhg avatar Mar 01 '22 18:03 xuzhg

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

darrelmiller avatar Mar 25 '23 19:03 darrelmiller