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

ODataRoutingSample openAPI #1399

Closed
swurzinger opened this issue Jan 29, 2025 · 1 comment
Closed

ODataRoutingSample openAPI #1399

swurzinger opened this issue Jan 29, 2025 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@swurzinger
Copy link

Describe the bug
The openAPI reference implementation in ODataRoutingSample seems to have issues:

  1. there seem to be two different implementations. One as middleware (ODataOpenApiMiddleware) and one as controller (ODataOpenApiController). Not sure if latter is even used?
  2. The middleware implementation seems faulty/incomplete. v2 and v3 models do work, but v1 doesn't.

Reproduce steps
perform a GET request http://localhost:5000/v1/$openapi (other versions work)

Request/Response

System.NotSupportedException: Specified method is not supported.
   at ODataRoutingSample.OpenApi.ODataPathTranslater.Translate(ODataPathTemplate pathTemplate, IEdmModel model) in sample\ODataRoutingSample\OpenApi\ODataPathTranslater.cs:line 107
   at ODataRoutingSample.OpenApi.OpenApiDocumentExtensions.CreateDocument(HttpContext context, String prefixName) in sample\ODataRoutingSample\OpenApi\OpenApiDocumentExtensions.cs:line 70
   at ODataRoutingSample.OpenApi.ODataOpenApiMiddleware.ProcessOpenApiAsync(HttpContext context, String prefixName) in sample\ODataRoutingSample\OpenApi\ODataOpenApiMiddleware.cs:line 82
   at ODataRoutingSample.OpenApi.ODataOpenApiMiddleware.Invoke(HttpContext context) in sample\ODataRoutingSample\OpenApi\ODataOpenApiMiddleware.cs:line 66
   at Microsoft.AspNetCore.OData.Routing.ODataRouteDebugMiddleware.Invoke(HttpContext context) in src\Microsoft.AspNetCore.OData\Routing\ODataRouteDebugMiddleware.cs:line 80
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

Expected behavior
OpenAPI json

some explanation of the OpenAPI implementation would also be nice (e.g.: why do we use a custom IODataPathProvider and what does it do)

@swurzinger swurzinger added the bug Something isn't working label Jan 29, 2025
@xuzhg xuzhg closed this as completed in c860cdc Feb 5, 2025
@xuzhg
Copy link
Member

xuzhg commented Feb 5, 2025

@swurzinger Thanks for reporting this issue.

For your question:

  • middleware and controller are both used to test the OpenAPI raw document. Both are active. By default, 'Middleware' is registered before the EndpointMiddleware in the ODataRoutingSample. So, the "/$openapi" request is always handled by the middlware. you can simply remove middleware register in the startup.cs, then the controller is used to test the openapi.
  • For the v1 issue, I fixed in the latest commit.

Please share more concerns or questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants