Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
351 stars 93 forks source link

Match multiple ocelot routes for given downstream endpoint #284

Closed satano closed 9 months ago

satano commented 9 months ago

Downstream paths are matched against all relevant Ocelot routes and used all routes that fit. Consider following downstream API:

Which is represented in OpenApi JSON as:

"paths": {
    "/api/test": {
        "get": {

        },
        "post": {

        }
    }
}

And this ocelot.json:

"Routes": [
    {
        "UpstreamPathTemplate": "/post/ocelot",
        "UpstreamHttpMethod": [ "POST" ],
        "DownstreamPathTemplate": "/api/test"
        "SwaggerKey": "test"
    },
    {
        "UpstreamPathTemplate": "/all/ocelot",
        "DownstreamPathTemplate": "/api/test"
        "SwaggerKey": "test"
    }
]

So both API endpoints are mapped to /all/ocelot route, but POST endpoint is also mapped to /post/ocelot.

Former implementation of generating Swagger JSON file worked this way

New implementation in this PR

Key changes in implementation are:

So the previous example works this way:

update-docs[bot] commented 9 months ago

Thanks for opening this pull request! If you have implemented new functions, write about them in the readme file.

request-info[bot] commented 9 months ago

We would appreciate it if you could provide us with more info about this issue/pr!