litestar
litestar copied to clipboard
fix(OpenAPI): handle invalid schema keys
Description
This PR changes OpenAPI schema key generation function _get_normalized_schema_key
to use valid characters according to the OpenAPI specification, section 4.8.7.1
.
The strategy adopted by this PR was to replace sequences of invalid characters with underscores. Examples:
-
Foo[Bar]
->Foo_Bar
-
dict[str, int]
->dict_str_int_
Some tests had to be changed, because they were expecting the use of invalid characters (like square brackets, spaces and colons).
Closes
Closes #3630