Open cpjolly opened 5 years ago
No this is not supported. What would you expect as c# output for the property?
Hi @RSuter,
There are two possible approaches I can think of to support oneOf, anyOf & allOf in the generated c#.
In the mean time, the work-around I thought of is something like overriding the calling method in the generated code, pass a custom JsonConverter method to SerializeObject(), where the custom JsonConvertor converts the oneOf part of the json stream ?
Please let me know if I can help further.
Many thanks
Chris Jolly
Yes, and also there is different output when oneOf is used for inheritance vs. your scenario here..
Maybe the simplest solution in this case would be to just generate an object/JToken property...
Hi @RSuter,
Perhaps JToken is the right answer. Sorry, I don't know enough about the inner workings of your code or Newtonsoft to know if that's the right approach... I'd also be interested to know how easy it was to work with the resulting entities after deserialization.
Hmm, I dont like exposing JToken or Newtonsoft.Json specific stuff (leaky abstraction) so maybe it's better to just expose object, but then the property is completely untyped - i.e. in your case not only string and string[] is allowed but everything...
Can you create a new issue in NJsonSchema for this? Because it has to be implemented there (DTO handling is in this library)
OK - I've created a new issue in NJsonSchema. Please let me know if you want me to copy over the example code from the above description
@RicoSuter I believe this should be closed as a duplicate of https://github.com/RicoSuter/NSwag/issues/2313 ?
I didn't read it through, but could it be merged with #2991 ?
Hello @RSuter,
does NSwag.CodeGeneration.CSharp.SwaggerToCSharpClientGenerator currently support oneOf ? It seems to only convert the first item but ignores the second and following items.
Here is the part of the schema in question:
And here is the generated code: