Skip to content
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

[C#] Issue with enum members #635

Closed
albator1932 opened this issue Jul 24, 2018 · 14 comments · Fixed by #774
Closed

[C#] Issue with enum members #635

albator1932 opened this issue Jul 24, 2018 · 14 comments · Fixed by #774

Comments

@albator1932
Copy link
Contributor

I very recently started to study the migration of our API from swagger-codegen to openapi-generator and I encounter a problem with enumeration members.

Our API is C# .NET Core based and the Swagger JSON is generated through the latest swashbuckle-aspnetcore I believe almost everyone is using in this context.

I'm using the latest stable of openapi-generator: 3.1.1

What the swagger-codegen generation looks like:
/// <summary>
/// Enum DataMatrix for value: DataMatrix
/// </summary>
[EnumMember(Value = "DataMatrix")]
DataMatrix = 2
What the openapi-generator generation looks like:
/// <summary>
/// Enum DataMatrix for value: DataMatrix
/// </summary>            
DataMatrix = DataMatrix

This generation does not compile and gives a "The evaluation of the constant value for 'BarcodeInfo.TypeEnum.DataMatrix' involves a circular definition" error.

Any idea what is going on ?

@albator1932 albator1932 changed the title [Csharp] Issue with enum members [C#] Issue with enum members Jul 30, 2018
@albator1932
Copy link
Contributor Author

Nobody even acknowledge that there is indeed an issue with the C# generator being broken?

@wing328
Copy link
Member

wing328 commented Aug 9, 2018

@albator1932 let me look into this...

@albator1932
Copy link
Contributor Author

While browsing the pull requests I found out that Jim made the same observation: #737

@wing328
Copy link
Member

wing328 commented Aug 9, 2018

Yes, he also mentioned that. Let me dig into it and hopefully file a PR shortly.

(sorry I missed your issue report earlier. busy with too many things...)

@wing328 wing328 mentioned this issue Aug 9, 2018
4 tasks
@wing328
Copy link
Member

wing328 commented Aug 9, 2018

@albator1932 I've filed #774. Please review when you've time.

@albator1932
Copy link
Contributor Author

Looks like it's good, I regenerated the client from our project and there is no more enumeration problems, good job!

I do have issues with float values though, they are missing a "f" so it's not confused with double. Not sure if it's related, going to dig this a bit if I have some time today.

@wing328
Copy link
Member

wing328 commented Aug 10, 2018

@albator1932 do you mean float value in enum? or just float in general (model properties, parameters)?

@albator1932
Copy link
Contributor Author

albator1932 commented Aug 10, 2018

It is always in model properties afaik (at least that's where I have the issue), for instance I do have this JSON generated in my API:

FunctionParameters:{  
   description:"Represents the parameters for a function.",
   required:[  
      "dummy"
   ],
   type:"object",
   properties:{  
      dummy:{  
         format:"float",
         description:"Dummy value for illustration.",
         default:15,
         type:"number"
      }
   }
}

And the generated C# result will be:

public FunctionParameters(float? dummy = 15.0)

@wing328
Copy link
Member

wing328 commented Aug 10, 2018

@albator1932 thanks for the details. Please open a separate issue if you don't mind.

For this PR, if @jimschubert has no concern, I'll merge it later tonight.

@albator1932
Copy link
Contributor Author

Sure, will do.

@jimschubert
Copy link
Member

@wing328 what PR are you referring to? Looks like you've merged the enum one, and I don't see one for the float issue mentioned.

@wing328
Copy link
Member

wing328 commented Aug 10, 2018

@jimschubert #774 (still open)

For the float issue, I've not filed any PR yet.

@wing328
Copy link
Member

wing328 commented Aug 11, 2018

@albator1932 PR merged into master. Thanks again for reporting the issue and sorry for the delay in fixing it.

@zdarovka
Copy link

Hello all, the problem seem to be still present in all version above 5.1.1

I have just tried to generate csharp-netcore client from the onfido yml specs available here
https://github.com/onfido/onfido-openapi-spec
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants