Skip to content

PascalCase mangles schema title #271

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

Closed
kalzoo opened this issue Dec 17, 2020 · 1 comment
Closed

PascalCase mangles schema title #271

kalzoo opened this issue Dec 17, 2020 · 1 comment
Labels
🐞bug Something isn't working
Milestone

Comments

@kalzoo
Copy link
Contributor

kalzoo commented Dec 17, 2020

Describe the bug

parser/properties/__init__.py(242)build_model_property() does not contain the same "hack" that's present at parser/reference.py(23)from_ref(), which removes spaces from the class name to prevent "ugly pascalcase output".

This occurs in my own schema generation when a model has a title and that title has spaces. In this particular case, that's Noise Model which gets pascal-ized to Noisodel.

Two ways to fix:

  1. Same inline hack as in parser/reference.py
  2. Strip the spaces within utils.py(28)pascal_case() itself so the fix is everywhere

To Reproduce

Generate from a schema with an object that has a title with spaces in it.

Expected behavior

Noise Model becomes a python model called NoiseModel rather than Noiseodel

Desktop (please complete the following information):

  • OS: OSX 10.15
  • Python Version: 3.8.2
  • openapi-python-client version: 0.7.2

Additional context

>.../python3.8/site-packages/openapi_python_client/utils.py(32)pascal_case()
-> return fix_keywords(stringcase.pascalcase(sanitize(value)))
(Pdb) value
'Noise Model'
(Pdb) stringcase.pascalcase(sanitize(value))
'Noisodel'
@kalzoo kalzoo added the 🐞bug Something isn't working label Dec 17, 2020
@dbanty dbanty added this to the 0.7.3 milestone Dec 17, 2020
@dbanty
Copy link
Collaborator

dbanty commented Dec 17, 2020

Thanks for reporting the bug! Seems like I have a sweep of issues to wrap up into a 0.7.3 this weekend 😬

dbanty added a commit that referenced this issue Dec 20, 2020

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
@dbanty dbanty closed this as completed in e2d6e27 Dec 21, 2020
dbanty added a commit that referenced this issue Dec 21, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants