Replies: 1 comment 2 replies
-
Maybe this? #61252 (comment) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to transition from using the Swashbuckle nuget to using Microsoft.AspNetCore.OpenApi to generate the OpenAPI json document. What I'm finding is that the exact same web api is generating the document differently on different servers, and as a result either the user experience of the swagger/scalar UI is sub optimal or it doesn't work at all because of how the servers property in the json is populated. On one server, the servers property is populate based on the bindings of the web site, and on another server the server property isn't present at all, which breaks the swagger/scalar UI.
I have two windows 2016 IIS servers. I have deployed a .net 9 web api to both servers to the default web site\POC\WebAPI.
The default web site on both servers has a very similar set of bindings:
Server 1:
Server 2:
I've add OpenAPI document generation using both and Microsoft.AspNetCore.OpenApi and Swashbuckle.AspNetCore.
I've deployed the web api to both servers, and I can invoke their endpoints fine.
When I look at the generated open api documents that are generated by Microsoft.AspNetCore.OpenApi generate differently for each server, and I don't know why.
When I look at the generated open api document that are generated by Swashbuckle.AspNetCore the documents generate the same way for both servers
The result is that if I try to use a UI like Swagger or Scalar, the ui may not work
Microsoft.AspNetCore.OpenAp generated OpenAPI document on server 1:
Microsoft.AspNetCore.OpenAp generated OpenAPI document on server 2:
Swashbuckle.AspNetCore generated OpenAPI document on server 1 and 2:
I like how swashbuckle generates the json because the server url is a relative path to the api, and it doesn't include all the irrelevant bindings. It just works. The Microsoft.AspNetCore.OpenApi seems to populate the servers list based on bindings of the web site, but not in all cases, and some of which might not be relevant for openapi, and it seems to be impacted by server configuration that I am not aware of. Does anyone have any insights on this?
Beta Was this translation helpful? Give feedback.
All reactions