Skip to content
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

bugfix for gneerics class #107

Merged
merged 5 commits into from
Sep 24, 2023

Conversation

ota42y
Copy link
Contributor

@ota42y ota42y commented Sep 6, 2023

Checklist:

  • Run pytest tests and no failed.
  • Run flake8 flask_openapi3 tests examples and no failed.
  • Run mypy flask_openapi3 and no failed.
  • Run mkdocs serve and no failed.

When we use generics in responses, the schema name include [] but OpenAPI 3 doesn't allow it.

All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.

The pydantic normalize all $ref but the schema name ( components.schemas ) set by this library so we shuld normalize name using pydantic's function.

@ota42y ota42y force-pushed the feat/support_generics_class branch from 75d3f5c to a41f82e Compare September 11, 2023 16:21


class ListGenericResponse(GenericModel, Generic[T]):
items: List[GenericResponse[T]]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used list here last time, but in python 3.7 etc. it has to be List, so I modified it

@luolingchun
Copy link
Owner

luolingchun commented Sep 17, 2023

@ota42y Hi, there seems to be somewhere else that needs to normalize the name, such as the parse_form and parse_body functions in utils.py.

Also, I would like to add normalize_name function to utils.py, which is not tied to pydantic v1 and v2.

And can you write a unit test in new test_file.py that will be lesser conflict?

Can you continue to complete it?

When we use generics in responses, the schema name include `[]` but [OpenAPI 3 doesn't allow it](https://spec.openapis.org/oas/v3.1.0#components-object).

```
All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.
```

The pydantic normalize all `$ref` but the schema name ( `components.schemas` ) set by this library so we shuld normalize name using pydantic's function.
@ota42y ota42y force-pushed the feat/support_generics_class branch from a41f82e to a99a495 Compare September 22, 2023 13:32
@ota42y ota42y mentioned this pull request Sep 22, 2023
@ota42y
Copy link
Contributor Author

ota42y commented Sep 22, 2023

@luolingchun
Hi, I have completed some fix.

  • add normalize_name to util.py and tests
  • normalize name in parse_form and parse_body

This PR changes will be conflict to this PR #106 but I think thease test should be in the tests/test_openapi.py
I have created #112 which include this PR and #106 ( I already fix conflict in it) so please use it.

@luolingchun luolingchun merged commit 060eb9d into luolingchun:v2.x Sep 24, 2023
5 checks passed
luolingchun pushed a commit that referenced this pull request Sep 24, 2023
@ota42y ota42y deleted the feat/support_generics_class branch September 24, 2023 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants