Skip to content
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

feature: convert-keys run option #199

Merged
merged 7 commits into from
Apr 16, 2024

Conversation

lo00l
Copy link
Contributor

@lo00l lo00l commented Apr 14, 2024

This PR introduces a new run option called convert-keys as discussed in #129.

Supported values: snake, camel, kebab, none. Default value is none.

Example of running code generation:

asyncapi-codegen -i ./asyncapi.yaml -g types -o ./models.gen.go --convert-keys snake

Also, I suggest to use a separate package for converting to snake, camel, kebab case. I chose iancoleman/strcase as the most popular and well tested.

There was a bug in SnakeCase implementation. For example, SnakeCase("Foo Bar") returned foo _bar instead of foo_bar. So I think it's not necessary to fix it and to implement other conversion functions while we can just use an appropriate package.

@lerenn
Copy link
Owner

lerenn commented Apr 16, 2024

Nice job ! I'll just add a section in the README and tests and we're good to go ! :)

@lerenn lerenn merged commit 946a713 into lerenn:main Apr 16, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants