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

Support Annotated types in OpenAPIHandler #472

Closed

Conversation

tyzhnenko
Copy link
Contributor

The idea is to support Annotated in building OpenAPI documentation and making type checkers happy as well.

I don't think this implementation is the right way to support such a feature. So, feel free to share any thoughts you have.

Example:

class Cats(APIController):
    @get("/cats/{cat_id}")
    def get_cat_details_annotated(cat_id: int) -> Annotated[Response, CatDetails]:
        ...
        return self.json(
            data=asdict(
                CatDetails(**cat_details)
            )
        )

Example:
```python

@get("/api/cats/{cat_id}")
def get_cat_details_annotated(cat_id: int) -> Annotated[Response, CatDetails]:
    ...

```
@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (bec8e14) 96.37% compared to head (f769e15) 96.40%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
+ Coverage   96.37%   96.40%   +0.02%     
==========================================
  Files          69       69              
  Lines        6487     6501      +14     
==========================================
+ Hits         6252     6267      +15     
+ Misses        235      234       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tyzhnenko tyzhnenko marked this pull request as draft January 23, 2024 22:55
@tyzhnenko tyzhnenko closed this Jan 24, 2024
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