-
-
Notifications
You must be signed in to change notification settings - Fork 35
Support for String/Num Enum values #110
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
Comments
This must also be compatible with defaultValue |
That is probably not possible with pure enums. |
Edit: Actually, I dont know how I did it in one project, cant reproduce it now... might be wrong here. Anyway we have it working that way in openapi-generator so it would be nice to 1. convert the enum to proper enum class 2. have it working with numeric/string enums. so the converter map will probably stay with us for a while |
This issue is also the lowest priority of the 3, it's more like "nice to have" than a blocker. |
It has to be properly designed first. It could take some time to nail it down nicely.
inspired by google/json_serializable.dart#778 It's really ambitious, I like it 👍 |
I agree but that's one caveat, different openapi generators have different options for naming conventions, there is no strict standard about it. All styling and naming conventions are just up to what developers of a generator produce. There are some generators that allow users to produce differently formatted code. This schema is pain in the ass for many generators because of the enums. It's really full of edge cases, pain-points, full of unrealistic type structures, types and names. In the end it's up to us openapi-generator developers what naming convention we use, and it's always, 100%, camelCase, but we also shouldn't restrict anyone from adding another generator with kebab-case or HaNAnMONtanACas-E if they wish so.
Yes, that's actually the good thing in json_serializable, but also the bad thing (only used enums have generated builders. Standalone enums that aren't used in any classes do not get the marshaller/unmarshaller code generated. If it only had an annotation for
The check the schema above, it has enum field with default value line 607 |
And again, it's a nice-to-have than a must-have. Your library is solving the blocker we had in json_serializer, so it's already better suited I think. I'm going to try your library in my project over the weekend and try to prepare a PR in openapi-generators if I have enough time. I need to see how it works with maps, list of maps, maps of lists etc. Yes, schema has such fields. |
Have to say, impressive. |
Uh oh!
There was an error while loading. Please reload this page.
Enum needs to be annotated what value we see in code and what name of the value is in JSON. eg
enum Color {Red, Blue}
I need to be able to useColor.Red
in Dart, but serialiseRed
tored
In real life example,(zyx)
or_abc
are valid enum values that can be present in JSON1.1
and-2
are valid valuesValue in code is something we generated in openapi, eg. in spec you see
-1.1
we should generate minusOneDotOne or something similar, but we need a way to tell JSON serialiser to turnminusOneDotOne
into-1.1
in JSON and it has to be-1.1
double value not string value"-1.1"
The text was updated successfully, but these errors were encountered: