Swagger Generator - can't add server to list
See original GitHub issueI’m using Nswag 13.1.2 in .NET Core 3.0.0. I’m trying to add new Server and Scheme to my swagger document.
services.AddOpenApiDocument(c =>
{
c.PostProcess = d =>
{
d.Schemes.Add(OpenApiSchema.Https);
d.Servers.Add(new OpenApiServer() { Url = "foo.com" });
};
});
Unfortunatelly in my swagger there is still only localhost server option.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Can't generate server/client : TypeError: Cannot read ...
json to swagger.json . Which caused the editor not able to load code gen list for OpenAPI 3.0, and ended up showing list...
Read more >Swagger UI Not Loading
I faced same issue: Swagger works just fine locally, but doesn't show UI once published to IIS. The problem was resolved by adding...
Read more >Swagger Codegen Documentation
The Swagger Codegen is an open source code-generator to build server stubs and client SDKs ... To get a list of languages supported...
Read more >Can not upload file when using a swagger generated ...
I was able to workaround the problem by modifying the generated server code to change the name "file" in @RequestPart("file") to the name ......
Read more >Swagger UI Configuration
The swagger-config.yaml in the project root directory, if it exists, is baked into the application; configuration object passed as an argument to Swagger...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The issue I was facing was that when hosting on multiple endpoints (http, https, proxy, etc…) only the first would be stored in the documentCache. I was able to fix this by doing the following:
This creates a unique document cache per server url instead of the default String.Empty. Works like a charm.
@vic10us / @RicoSuter
I was having this issue as well, and tried this solution. But to actually use
request.GetServerUrl()
, I had to copyHttpRequestExtension
from here into my project, as theHttpRequestExtension
class is internal.After add doing that, the server url is correct both directly and through reverse proxy. But is there a better way to go about this? Since you didn’t mention anything like that @vic10us I assume you didn’t have to copy it into your project?