-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support enum with whitespaces #105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks. (Can't tell for generated Swift code)
schemas/SuperProperties.json
Outdated
"appPlatform": { | ||
"description": "Used by web to identify the platform (Web Platform/Electron Platform).", | ||
"type": "string" | ||
}, | ||
|
||
"platformCodeName": { | ||
"description": "Used as a discriminant to breakdown usage per client.", | ||
"type": "string", | ||
"oneOf": [ | ||
{"const": "Web", "description": "Element Web platform code."}, | ||
{"const": "Desktop", "description": "Element Desktop platform code."}, | ||
{"const": "EI", "description": "Element iOS platform code."}, | ||
{"const": "EXI", "description": "Element-X iOS platform code."}, | ||
{"const": "EA", "description": "Element Android platform code."}, | ||
{"const": "EXA", "description": "Element-X Android platform code."}, | ||
{"const": "Other", "description": "Other Platform code."} | ||
{"const": "Web Platform", "description": "Element Web platform."}, | ||
{"const": "Electron Platform", "description": "Element Desktop platform."}, | ||
{"const": "EI", "description": "Element iOS platform."}, | ||
{"const": "EXI", "description": "Element-X iOS platform."}, | ||
{"const": "EA", "description": "Element Android platform."}, | ||
{"const": "EXA", "description": "Element-X Android platform."}, | ||
{"const": "Other", "description": "Other Platform."} | ||
] | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest making changes to the properties definitions in a separate PR to the changes to the script, to make it easier for reviewers and future readers to see what is changing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, but we do not have the bandwidth to ensure 150% quality on all our projects... Also adding a const
with a space in this PR ensure that the change on the script generation works as expected.
I was tempted to tell @BillCarsonFr to better split their commits, for instance I do not like that commit on the script change also contains the generated files. It should be distinct commits, to easily filter out commit with generated code.
But again let's not spend to much time on this.
A better commit history would have been:
- Update the script to support const with spaces
- Run the script
- Update appPlatform names
- Run the script
I guess this can be a better recipe for next time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, but we do not have the bandwidth to ensure 150% quality on all our projects.
I think this is a bit like saying "we don't have time to write tests". You can save time in the short term, but in the longer term, breaking up changes into smaller steps that are easier to verify is an important way of avoiding bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Thanks @BillCarsonFr for breaking this up - I think it's much clearer now)
6df1af0
to
641e66f
Compare
When using white spaces in
oneOf
enum types the generated kotlin and swift code was not valid (white space in the property name).The main changes are in
kotlin.py
andswift.py
, typescript generation was ok with whitespaces.The change will be invisible for users of the library.
Kotlin
For kotlin, a new field
rawValue
is added in the generated enum and is used in thegetProperties
method instead of the enum autogenerated name.Before:
After
Swift
The enum were alreasy
: String
just now explicitely adding the rawvalueBefore:
Now: