Burgyn / MMLib.SwaggerForOcelot

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

Microservices Swagger Files Not Loading Correctly #167

Closed omeruygun closed 3 years ago

omeruygun commented 3 years ago

Describe the bug I made a configuration like examples. I develop multible microservices like User, Project etc. I publish then apps to IIS on 80 port. Gateway project not load other microservices endpoint and swagger file correctly.

Expected behavior I am waiting for the other endpoints to load correctly.

To Reproduce If it is a possible attache: My ocelot.json file is: https://transfer.basarsoft.com.tr/Share/Download/604b496144bd90013c1a105b My IIS Application Hierarchy Image: https://transfer.basarsoft.com.tr/Share/Download/604b49ba44bd90013c1a1070 My Startup.cs Configuration is : https://transfer.basarsoft.com.tr/Share/Download/604b4a1e44bd90013c1a1072

My Gateway Address: http://localhost/Kolin/Pdm/Gateway/swagger/index.htm Example User Service Address: http://localhost/Kolin/Pdm/Microservices/User/swagger/index.html

When browsing gateway listing other endpoints in combobox but when selected gateway shows "No operation defined in spec!" error message.

My Gateway ss: https://transfer.basarsoft.com.tr/Share/Download/604b4a8c44bd90013c1a1074 My User Service ss: https://transfer.basarsoft.com.tr/Share/Download/604b4abe44bd90013c1a1076

Burgyn commented 3 years ago

Hi @omeruygun,

thank for issue. Unfortunately, base on the information provided, I cannot reproduce the problem.

Please can you prepare an executable demo, ideally without IIS hosting, where you will reproduce this problem? Thanks a lot.

omeruygun commented 3 years ago

Hi @Burgyn , I am publishing applications to IIS. Because it is my customer enviroment is windows. Firstly my applications under Default Application (Port 80) and each application structure like MainWebSite/Microservice1, MainWebSite/Microservice2 etc. Each microservices broadcast 80 port but each url like http://localhost/MainWebSite/Microservice1 or http://localhost/MainWebSite/Microservice2

I uploaded images in first post.

Thank you for response.

Burgyn commented 3 years ago

Hi.

I understand. But when I try to simulate your situation it works properly. That's why a demo would help me.

omeruygun commented 3 years ago

Hi, i preparing virtual machine image for demo. It is done then upload and send download link.

omeruygun commented 3 years ago

Hi @Burgyn , I prepare virtual machine on Hyper-V version 8.0. You can download from here http://omeruygun.com/Windows10Ver8.rar

I install iis and push to source code to virtual machine. Then imported and started virtual machine, you test in browser.

And I upload video on youtube https://youtu.be/nW8N8dq8d3A

Burgyn commented 3 years ago

Hi @omeruygun,

thanks. I'll look into it next week

risker91 commented 3 years ago

Hi @Burgyn look here file: SwaggerJsonTransformer.cs start line 137

 string version = paths.Root["info"]["version"].Value<string>();
 string downstreamPath = path.Name.RemoveSlashFromEnd().Replace("v{version}", version);

helped me

Burgyn commented 3 years ago

Hi @omeruygun,

The problem is that in your downstream services swagger documentation is information about the OA3 Server.

I'm not sure why you have it that way. I tried to research it, but it looks like some hidden Swashbuckle.AspNetCore functionality, because if I run the project locally, the information is not there.

As a workaround, I suggest clearing the list of servers in downstream services. (e.g. in Users)

app.UseSwagger(c => {
    c.PreSerializeFilters.Add((swagger, httpReq) =>
    {
        swagger.Servers = new List<OpenApiServer>();
    });
});

It worked in the demo you gave me.

Burgyn commented 3 years ago

Hi @risker91

I'm sorry, but I don't understand your comment.

github-actions[bot] commented 3 years ago

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