You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where 'token' does not allow '/'. Comment is basically "something in parentesis".
Swagger-codegen version
I'm using 2.3.1, but incorrectly formatted user-agent strings can be found in the codebase going back at least two years.
For C# this User-Agent default is present in the templates here and here
However, User-Agent is prevalent in the code base (try git log -G "[Aa]gent.*[Ss]wagger-[Cc]odegen"). At least the template resources and sample code for Android, C#, Eiffel, Go, Java, Perl, PHP, Python, R, Ruby and Rust contains (defaults) to the Swagger-Codegen/version/language format.
Swagger declaration file content or url
Any declaration will probably do, the problem is in the supporting code.
Generate code, then search for "agent" in ./some-csharp/src/Some.Export/Client/Configuration.cs.
Related issues/PRs
Tried a few searches, couldn't find a similar issue reporting this as a problem. However, #2376 and several issues linked from there, encourages the use of Swagger-Codegen/{version}/{language} as a User-Agent.
Suggest a fix/enhancement
Replacing the actual user-agent defeats the fields purpose:
... often used by servers to help identify the scope of reported
interoperability problems, to work around or tailor responses to avoid
particular user agent limitations, and for analytics regarding browser or
operating system use.
So if self-promotion is desired, it would be more appropriate to append Swagger-Codegen as a less significant part of the User-Agent, and include the language used as a comment. For example using C# and RestSharp v105.2.3, the User-Agent could be;
This way, any workarounds necessary for RestSharp can still be applied, self-promotion still there, and the format is RFC 7231-compliant.
As for the annoying warning in Akka HTTP server logs, there's an Akka configuration option to turn that off. I can also explicitly set User-Agent using --http-user-agent=Something/1.0 when calling swagger-codegen.
The text was updated successfully, but these errors were encountered:
Description
Supporting code generated for C# (but also many other languages) default to an invalid User-Agent string according to RFC 7231 HTTP/1.1 Semantics and Content. We noticed this because Akka HTTP Server issues a warning about the incorrect format. It doesn't seem to cause any other ill effects beside the warning, however, apart from the feeling one gets around RFC violations.
For example C# sets
UserAgent = "Swagger-Codegen/1.0.0/csharp";
Replacing the actual user-agent (RestSharp in this case) not only defeats the fields purpose, but in this case also violates the specification.
RFC 7231 says the format of the User-Agent string should be:
where 'token' does not allow '/'. Comment is basically "something in parentesis".
Swagger-codegen version
I'm using 2.3.1, but incorrectly formatted user-agent strings can be found in the codebase going back at least two years.
For C# this User-Agent default is present in the templates here and here
However, User-Agent is prevalent in the code base (try
git log -G "[Aa]gent.*[Ss]wagger-[Cc]odegen"
). At least the template resources and sample code for Android, C#, Eiffel, Go, Java, Perl, PHP, Python, R, Ruby and Rust contains (defaults) to theSwagger-Codegen/version/language
format.Swagger declaration file content or url
Any declaration will probably do, the problem is in the supporting code.
Command line used for generation
Steps to reproduce
Generate code, then search for "agent" in ./some-csharp/src/Some.Export/Client/Configuration.cs.
Related issues/PRs
Tried a few searches, couldn't find a similar issue reporting this as a problem. However, #2376 and several issues linked from there, encourages the use of
Swagger-Codegen/{version}/{language}
as a User-Agent.Suggest a fix/enhancement
Replacing the actual user-agent defeats the fields purpose:
So if self-promotion is desired, it would be more appropriate to append Swagger-Codegen as a less significant part of the User-Agent, and include the language used as a comment. For example using C# and RestSharp v105.2.3, the User-Agent could be;
This way, any workarounds necessary for RestSharp can still be applied, self-promotion still there, and the format is RFC 7231-compliant.
As for the annoying warning in Akka HTTP server logs, there's an Akka configuration option to turn that off. I can also explicitly set User-Agent using
--http-user-agent=Something/1.0
when calling swagger-codegen.The text was updated successfully, but these errors were encountered: