-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid generating invalid Scala identifiers when printing schemas and …
…protocols (#178) * Avoid generating invalid Scala identifiers from OpenAPI specs There is already a `normalize` function which makes an attempt to normalize strings into valid Scala identifiers, but it does not handle all cases correctly, e.g. it does not handle reserved words. Added an `ident` function which does a better job at converting an arbitrary string into a valid identifier, by delegating the logic to scalameta. Rather than fiddling with the contents of the string to make it valid, we just wrap it in backticks if required. Unfortunately, `normalize` is used for a lot of different things, not only generation of valid identifiers, so I then had to go through the code and switch from `normalize` to `ident` in *just* the right places to make the tests pass. The codegen behaviour has changed slightly (for the better I think) in a few cases. See the updated unit tests for the details. * Avoid invalid Scala identifiers when printing Mu schemas/protocols Similar to the previous commit, just wrapping strings in `toValidIdentifier` in all the right places. Extended the existing protobuf printing test to cover this new behaviour. * Use constant for scalameta version Co-Authored-By: Juan Pedro Moreno <4879373+juanpedromoreno@users.noreply.github.com>
- Loading branch information
1 parent
eac3f8d
commit 15e408b
Showing
13 changed files
with
192 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.