litestar icon indicating copy to clipboard operation
litestar copied to clipboard

fix(OpenAPI): handle invalid schema keys

Open thiagozf opened this issue 7 months ago • 2 comments

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

thiagozf avatar Jul 17 '24 14:07 thiagozf