Burgyn / MMLib.SwaggerForOcelot

This repo contains swagger extension for ocelot.
MIT License
352 stars 94 forks source link

Getting 404 when running with KubernetesServiceDiscoveryProvider #251

Closed Arik-Shapiro closed 1 year ago

Arik-Shapiro commented 1 year ago

Describe the bug A clear and concise description of what the bug is. When running a local ocelot.json it's working perfectly. With these settings:

{
    "Routes": [
        {
            "DownstreamPathTemplate": "/api/audit/{everything}",
            "DownstreamHostAndPorts": [
                {
                    "Host": "localhost",
                    "Port": 5135
                }
            ],
            "UpstreamPathTemplate": "/api/audit/{everything}",
            "SwaggerKey": "audit"
        },
        {
            "DownstreamPathTemplate": "/api/audit",
            "DownstreamScheme": "http",
            "DownstreamHostAndPorts": [
                {
                    "Host": "localhost",
                    "Port": 5135
                }
            ],
            "UpstreamPathTemplate": "/api/audit",
            "SwaggerKey": "audit"
        }
    ],
    "SwaggerEndPoints": [
        {
            "Key": "audit",
            "Config": [
                {
                    "Version": "v1",
                    "Name": "Audit API",
                    "Url": "http://localhost:5135/swagger/v1/swagger.json"
                }
            ]
        }
    ]
}

But when using these settings on kubernetes:

{
    "Routes": [
        {
            "DownstreamPathTemplate": "/api/audit/{everything}",
            "UpstreamPathTemplate": "/api/audit/{everything}",
            "ServiceName": "audit-service",
        },
        {
            "DownstreamPathTemplate": "/api/audit",
            "UpstreamPathTemplate": "/api/audit",
            "ServiceName": "audit-service",
            "SwaggerKey": "audit"
        }
    ],
    "GlobalConfiguration": {
        "DownstreamScheme": "http"
    },
    "SwaggerEndPoints": [
        {
            "Key": "audit",
            "Config": [
                {
                    "Name": "Audit API (API Gateway)",
                    "Version": "v1",
                    "Service": {
                        "Name": "audit-service",
                        "Path": "/swagger/v1/swagger.json"
                    }
                }
            ]
        }
    ]
}

I'm getting 404 for /swagger/index.html image

but when I actually route to /swagger/docs/v1/audit I get the swagger.json file perfectly.

The routing works on kuberentes, also seems like getting the swagger.json file from downstream service. For some reason the /swagger endpoint is still showing 404.

Expected behavior Same as with the first settings file, swagger should work.

I would really appreciate some help, thanks!