jacksmith15 / statham-schema

Statham is a Python Model Parsing Library for JSON Schema.
https://statham-schema.readthedocs.io/en/latest/
MIT License
39 stars 10 forks source link

Title with special character causes a syntax error #77

Closed arthur-proglove closed 4 years ago

arthur-proglove commented 4 years ago

Describe the bug A JSON schema with a special character in its title (non alphanumerical) causes the generated Python code to be incorrect.

Steps to Reproduce Create a JSON schema with the following title: "My Test JSON Schema!"

Expected behaviour A class should be defined without the exclamation mark: class MyTestJSONSchema:

Actual behaviour The class is defined as is: class MyTestJSONSchema!:

arthur-proglove commented 4 years ago

Sanitizing the title with something like re.sub('[^a-zA-Z0-9_\s]', '_', name) should do the trick ;-)

jacksmith15 commented 4 years ago

Well spotted @arthur-proglove - and thanks for providing a clear example! :+1:

arthur-proglove commented 4 years ago

That was fast! :-D

jacksmith15 commented 4 years ago

Fixed in 0.13.0 (PyPI, GitHub)