Burgyn/MMLib.SwaggerForOcelot

Wrong Swagger url generated when using KubernetesServiceDiscoveryProvider

sirdawidd opened this issue · 1 comments

Describe the bug
Im using KubernetesServiceDiscoveryProvider ,
I defined swagger endpoint

 {
      "Key": "starwars",
      "Config": [
        {
          "Name": "starwars API",
          "Version": "v1",
          "Service": {
            "Name": "starwars",
            "Path": "/swagger/docs/v1/swagger.json"
          }
        }
      ]
    }

In routes i have
"UpstreamPathTemplate": "/starwars/{everything}",

By this configuration I only get error that
Failed to match Route configuration for upstream path: /swagger/docs/v1/starwars
Which is true because I didn't know that i need to define extra route

So after adding another rote configuration
"UpstreamPathTemplate": "/swagger/docs/v1/starwars",
It was working fine.

Expected behavior
Dont really know why swagger routes generated by this library are opposed instead starwars/swagger/docs/v1/ what is generated is /swagger/docs/v1/starwars
I assume reason is that my swagger endpoint is not as in documentation domain/swagger but domain/api/swagger

Config file

{
  "Routes": [
    {
      "SwaggerKey": "starwars",
      "DownstreamPathTemplate": "/api/swagger/docs/v1/swagger.json",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "starwars.svc.cluster.local",
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/swagger/docs/v1/starwars",
      "UpstreamHttpMethod": [
        "Options",
        "Head",
        "Get",
        "Post",
        "Put",
        "Patch",
        "Delete"
      ],
      "RouteIsCaseSensitive": false,
      "DangerousAcceptAnyServerCertificateValidator": true,
      "Priority": 1
    },
    {
      "SwaggerKey": "starwars",
      "DownstreamPathTemplate": "/api/{everything}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "starwars.svc.cluster.local",
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/starwars/{everything}",
      "UpstreamHttpMethod": [
        "Options",
        "Head",
        "Get",
        "Post",
        "Put",
        "Patch",
        "Delete"
      ],
      "RouteIsCaseSensitive": false,
      "DangerousAcceptAnyServerCertificateValidator": true,
      "Priority": 0,
      "AuthenticationOptions": {
        "AuthenticationProviderKey": "Admin",
        "AllowedScopes": []
      }
    },
   
  ],
  "GlobalConfiguration": {
    "BaseUrl": ".......",
    "ServiceDiscoveryProvider": {
      "Namespace": "svc...",
      "Type": "kube"
    }
  },
  "SwaggerEndPoints": [
    {
      "Key": "starwars",
      "Config": [
        {
          "Name": "starwars API",
          "Version": "v1",
          "Service": {
            "Name": "starwars",
            "Path": "/swagger/docs/v1/swagger.json"
          }
        }
      ]
    }
  ]
}
stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.