Errors in OpenApiDocument.FromUrlAsync when the web server requires a user-agent
See original GitHub issueI’m trying to generate a client for a government API that has their server configured to reject requests that do not specify a User-Agent
header. This seems like an odd thing to do, but I guess they are trying to track usage or detect abuse via that header.
Our workaround is to download the spec and generate from a file, but it would be nice to not need that.
I think we could fix this by specifying a header in DynamicApis before we make the request, but I’m unclear why we use DynamicApis
instead of HttpClient
directly.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
C# (CSharp) OpenApiDocument Examples
C# (CSharp) OpenApiDocument - 33 examples found. These are the top rated real world C# (CSharp) examples of OpenApiDocument extracted from open source ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
Not sure there is something to add here in NSwag. If an option was introduced for setting the user agent, then others wouldn’t understand :
I’d argue to keep the project and options simple, and for complex scenarios like these, download the file with a curl, a dotnet-script, a console app or whatever, and pass that file to NSwag.
Closing this out, there are options to solve the problem outside nswag and all the proposed solutions open up pandora’s box to endless scope/feature creep.
Thanks for consideration @RicoSuter and for the great counterpoint @jeremyVignelles.