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

BasePath Does not Appear to Work correctly #21

Closed
jondmcelroy opened this issue Apr 26, 2019 · 0 comments
Closed

BasePath Does not Appear to Work correctly #21

jondmcelroy opened this issue Apr 26, 2019 · 0 comments
Assignees

Comments

@jondmcelroy
Copy link
Contributor

jondmcelroy commented Apr 26, 2019

Describe the bug
I am using a downstream swagger service that has a basePath in it. When I set it up through ocelot, i have to add the basePath into the Upstream/Downstream Path Templates in order to get the routing working. When I do that though, it messes up the swagger from SwaggerForOcelot as the route cannot be detected.

Example Original Swagger:

{
    "swagger": "2.0",
    ...
    "host": "localhost:8001",
    "basePath": "/api",
    "paths": {
        "/address/check": {
            "post": {
                ...
            }
        }
    }
}

To Call this it would be localhost:8001/api/address/check.

After adding ocelot:

Ocelot.json

{
 "ReRoutes": [
    {
      "DownstreamPathTemplate": "/api/{everything}",
      "UpstreamPathTemplate": "/api/OM/{everything}",
      ...
    }
 ]
}

Now I can hit the API at localhost:8999/api/OM/address/check

But the problem is that the swagger generated from SwaggerForOcelot does not find those routes and is not generated.

If I remove the basePath. and change the Ocelot.json to:

{
 "ReRoutes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "UpstreamPathTemplate": "/OM/{everything}",
      ...
    }
 ]
}

then the swagger is correctly generated from SwaggerForOcelot.
But the Ocelot reRouting fails, it thinks that I need to hit this endpoint:
localhost:8999/OM/api/address/check

It appears that the base path needs to be considered when working in the SwaggerJsonTransformer when finding the reRoutes.

The tests also seem to hide this issue. For instance: CreateNewJsonWhenConfigurationContainsOnlyOneController has a base path of v2. It appears that if ocelot actually used that reRoute though, that it would not work properly as the v2 would not be matched by ocelot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants