Closed jespitae closed 3 weeks ago
@jespitae feel free to provide a PR :v: I don't think the next
version has this solved 🤔 Just remember that enums can be any valid JSON value 🙂
@jonaslagoni In that case maybe it's better to change the parameter type of the To... extension method to dynamic. I'll provide a PR.
Describe the bug.
The C# generator generates a JsonConverter using SystemTextJson, that tries to deserialize the enums as dynamic. The enum looks like this:
Next to the enum an extension method is generated:
The json converter tries to deserialize the enum as follows:
This results in the following error when trying to deserialize the enum:
The best overloaded method match for 'CBS.Viewer.Integration.Events.EnvironmentExtensions.ToEnvironment(string)' has some invalid arguments
Expected behavior
We would expect the resulting json converter to look like this:![image](https://github.com/asyncapi/modelina/assets/23041146/a961bc9b-e9f9-41ee-8d60-743269553f3a)
Screenshots
Screenshot provided throughout.
How to Reproduce
Our asyncapi spec for the enum looks like this:
The property on one of our events:
![image](https://github.com/asyncapi/modelina/assets/23041146/60be3de7-9a70-4937-be02-8f33f8f2b848)
We used version 2.0.2 of the asyncapi cli and version 3.5.3 of modelina and ran the following command:
asyncapi generate models csharp ./asyncapi.json --namespace=Test --output=Models --csharpSystemJson
Our async api specification is defined in version 2.4.0.🥦 Browser
Mozilla Firefox
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
Yes I am willing to submit a PR!