Neoteroi / BlackSheep

Fast ASGI web framework for Python
https://www.neoteroi.dev/blacksheep/
MIT License
1.8k stars 75 forks source link

Support Annotated types in OpenAPIHandler #472

Closed tyzhnenko closed 5 months ago

tyzhnenko commented 5 months ago

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)
            )
        )
codecov-commenter commented 5 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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

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

Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.