-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple issues with generated C# code #1101
Comments
Possible solution for issue 2 Using the extension methods
It's possible to rewrite generated code like: Tested on the code that was generated it now creates a correct webservice call url. |
|
|
What if we generate the following method in each client class:
and use this instead of System.Convert.ToString |
Override the enum's ToString() is probably a better spot for the code. |
How can you override ToString() of an enum? |
Hi You're right about ToString(), but the ToString(CultureInfo ci) you can catch with an extension methods. Your solution also seems pretty ok to me. Btw nice work NSwagStudio. You only have to change the
Using generics also works if you define the method like:
|
Just come across this enum value translation issue on a different swagger definition. |
Please retest with latest CI build, and open new separate issues if needed.. |
Hi
Swagger definition used https://esi.tech.ccp.is/latest/swagger.json (this is a nice & complex one).
It seems to generate 'close' to working code only with SingleClientFroIOperationId as operation mode.
But still some major issues left (for the rest great work that saves a lotta work).
Some of the enums (Color/LabelColor) use names during serialization like #0000fe which are illegal in C#. So better replace these illegal chars by an _.
Quite some enums value (like Language in this example) differ in name from the EnumMember value. When passed into a method they are added to the url/body as text using an ToString() like:
if (language != null) urlBuilder_.Append("language=").Append(Uri.EscapeDataString(System.Convert.ToString(**language**, CultureInfo.InvariantCulture))).Append("&");
This results in for example "EnUs" being appended instead of the EnumMember value of the language "en-us".
Instead of the enum value, reflection should be used to retrieve the correct value to be appended.
It would be nice (for larger definitions like this one) if there was an option to split the current partial client class on the first level of path (so get_alliances/put_alliances etc methods would go into a separate file)
The trailing / of paths is lost in the url's used in code. See for example the path
"/characters/{character_id}/assets/names/"
which should results in
"/characters/{character_id}/assets/names/?"
inside
Post_characters_character_id_assets_namesAsync()
but is emitted as
"/characters/{character_id}/assets/names?"
which fails when calling the webservice.
The text was updated successfully, but these errors were encountered: