Skip to content

PascalCase mangles schema title #271

Closed
@kalzoo

Description

@kalzoo

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions