-
Notifications
You must be signed in to change notification settings - Fork 3
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
Consider adding support of EnumNames
or Enum: Object
#8
Comments
@bruno-f-cruz This seems to be related to #11. I was checking some more examples of enum-like declarations in JSON-schema and to be honest they seem to be all over the place. As an example you can check the OpenAPI specification approach to labeled enums: OAI/OpenAPI-Specification#348 (comment) where at least three different approaches to enum declaration are discussed and proposed. If these patterns are something that NJsonSchema recognizes and can generate C# code for, then we can definitely modify and adapt the underlying model data structures. Otherwise I feel we should probably restrict ourselves to support only constructs that are compatible out-of-the-box with NJsonSchema, as we won't have the resources to diverge and maintain the foundations for a full-blown standards compliant parser/generator ourselves. |
I completely agree, NJsonSchema already recognizes some of these patterns (e.g. https://github.com/RicoSuter/NJsonSchema/wiki/Enums). I would probably leave it "as is" if it is not too much work and if it doesn't break anything. We can think if we want to leverage a different behavior in the future. I would also agree with your general comment of being careful to not veer too far off from the NJsonSchema. |
@bruno-f-cruz can you test if the modifications in #20 are acceptable to close this? |
json-schemas seems to allow enums to be defined as arrays of objects, eg:
Moreover, additional support from some standards have also added a way to use enumNames to refer to these enum entries:
Since csharp Enum only allow for numeric values, it would be great to implement a way to instantiate the enum name with the
enumNames
but still try to support the serialization/deserialization somehow.The text was updated successfully, but these errors were encountered: