Burgyn / MMLib.SwaggerForOcelot

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

Swagger response too slow for big swagger documents #181

Closed namnik closed 2 years ago

namnik commented 3 years ago

I have this issue too #173 . I used this solution "TransformByOcelotConfig" : false, this config correctly worked. But now I have a new problem: when calling my Apis into swagger, it's calling with local IP instead of calling with my domain website name(for example myApp.com/api ). with this config all swagger calling Apis throw with error: 'failed to fetch'.

{ "UpstreamPathTemplate": "/xxx/api/{everything}", "DownstreamPathTemplate": "/api/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "xx.xx.xxx.xx" //local IP "Port": xxxxx } ], "SwaggerKey": "myAppKey", "RouteIsCaseSensitive": "false" }

namnik commented 3 years ago

why anyone don't answer this issue!.

Burgyn commented 3 years ago

Hi, I'm on vacation. I'll look into it tomorrow.

Burgyn commented 3 years ago

Hi,

I'm not sure I understand correctly. Having trouble calling your api via swagger documentation? If so, what address is the swagger documentation trying to call? Is it right?

image

namnik commented 3 years ago

yes, before applying the config "TransformByOcelotConfig" : false , calling my api via swagger correctly worked 123

but after applying the config Having trouble calling my api via swagger:

321

Burgyn commented 3 years ago

Hi, the TransformByOcelotConfig setting does this by taking the documentation from the downstream service and displaying it unchanged. So if you have a Base URL or Servers (OpenApi 3) defined in the downstream documentation, these are not modified and will be used in swagger UI to execute the request (this is the standard behavior of Swashbuckle.AspNetCore). If you do not generate Base URL or Servers in the source service, the gateway address should be used.

Anyway, setting TransformByOcelotConfig is not a suitable, because it will really show you the original documentation without the necessary modification of paths, removal of unnecessary paths, ...

Unfortunately, I know that the modification of large documentation is slow. I plan to fix it, but I don't have time for it right now.

namnik commented 3 years ago

I will waiting for the enhancement. I hope that you get free time for this plan.

Burgyn commented 3 years ago

I'm not going to promise, but I hope in September.

namnik commented 2 years ago

could you working on this issue

Burgyn commented 2 years ago

Hi @namnik, I didn't get to it at all. Next week I'll try to estimate how difficult it is and I'll let you know.

Burgyn commented 2 years ago

Hi @namnik https://github.com/namnik

For easier problem solving, can you please provide your larger swagger json documentation? It would help me.

Thanks.

On Sat, 1 Jan 2022 at 08:23, Saman Namnik @.***> wrote:

could you working on this issue

— Reply to this email directly, view it on GitHub https://github.com/Burgyn/MMLib.SwaggerForOcelot/issues/181#issuecomment-1003519280, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNH6RQMR4LTQSYJWOUH653UT2TVPANCNFSM5AVI4VDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you modified the open/close state.Message ID: @.***>

-- Prajem pekný zvyšok dňa, Ing. Milan Martiniak

namnik commented 2 years ago

Hi @Burgyn Sure, a large swagger json url: https://sandbox.wepod.ir/swagger/docs//XBankMain https://sandbox.wepod.ir/swagger/index.html?urls.primaryName=XBankMain%20-%20

Thanks,

Burgyn commented 2 years ago

Hi @namnik https://github.com/namnik

thanks for your docs. Unfortunately I do not have good news. With a 16MB document, I come across Newonsoft limits. The transition to System.Text.Json is currently impossible because it does not allow modification of an existing document. Switching to that would take a lot of time that I don't have.

In your case, a lot of time is spent removing unused components from the schema. If you don't mind having these components in the resulting documentation, I can make settings that would allow you to turn it off.

Thanks.

On Thu, 20 Jan 2022 at 08:36, Saman Namnik @.***> wrote:

Hi @Burgyn https://github.com/Burgyn Sure, a large swagger json url: https://sandbox.wepod.ir/swagger/docs//XBankMain or https://api.wepod.ir/swagger/docs//XBankMain

Thanks,

— Reply to this email directly, view it on GitHub https://github.com/Burgyn/MMLib.SwaggerForOcelot/issues/181#issuecomment-1017195246, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNH6RXOVKMFTO7LMASP3NLUW63RNANCNFSM5AVI4VDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

-- Prajem pekný zvyšok dňa, Ing. Milan Martiniak

Burgyn commented 2 years ago

Hi @namnik,

In new version 4.8.0 you can use RemoveUnusedComponentsFromScheme switch

"SwaggerEndPoints": [
{
  "Key": "projects",
  "RemoveUnusedComponentsFromScheme": false,
  "Config": [
    {
      "Name": "Projects API",
      "Version": "v1",
      "Service": {
        "Name": "projects",
        "Path": "/swagger/v1/swagger.json"
      }
    }
  ]
}

PR #218

github-actions[bot] commented 2 years ago

Closing after 8 days of waiting for the additional info requested.