8000 Add skip_defaults support for path operations (for #242) by wshayes · Pull Request #248 · fastapi/fastapi · GitHub
[go: up one dir, main page]

Skip to content

Uh oh!

There was an error while loading. Please reload this page.

Conversation

@wshayes
Copy link
Contributor
@wshayes wshayes commented May 22, 2019

Running into trouble getting skip_defaults passed correctly. I’m not understanding the full flow of the logic from the route decorators to the response serialization.

This is a Starlette class which has include_in_schema but does not have skip_defaults - how do we handle this? Do we need to?

# From routing.py - line 331
elif isinstance(route, routing.Route):
    self.add_route(
        prefix + route.path,
        route.endpoint,
        methods=route.methods,
        include_in_schema=route.include_in_schema,
        name=route.name,
    )

Haven't done any websocket work - not sure if websocket route needs to be handled for this (probably does)

I would appreciate pointers/help to finish this PR.

Running into trouble getting skip_defaults passed correctly. I’m not understanding the full flow of the logic from the route decorators to the response serialization.

This is a Starlette class which has include_in_schema but does not have skip_defaults - how do we handle this? Do we need to?

    # From routing.py - line 331
    elif isinstance(route, routing.Route):
        self.add_route(
            prefix + route.path,
            route.endpoint,
            methods=route.methods,
            include_in_schema=route.include_in_schema,
            name=route.name,
        )

Not completely sure I'm handling passing skip_defaults through get_app correctly.

Haven't done any websocket work - not sure if websocket route needs to be handled for this (probably so)
@wshayes wshayes changed the title partial skip_defaults implementation (for #242) Partial skip_defaults implementation (for #242) May 22, 2019
@codecov
Copy link
codecov bot commented May 22, 2019

Codecov Report

Merging #248 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #248    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files         177    183     +6     
  Lines        4327   4539   +212     
======================================
+ Hits         4327   4539   +212
Impacted Files Coverage Δ
fastapi/encoders.py 100% <ø> (ø) ⬆️
...t_tutorial/test_response_model/test_tutorial004.py 100% <100%> (ø)
docs/src/response_model/tutorial004.py 100% <100%> (ø)
fastapi/routing.py 100% <100%> (ø) ⬆️
fastapi/applications.py 100% <100%> (ø) ⬆️
fastapi/dependencies/utils.py 100% <0%> (ø) ⬆️
fastapi/dependencies/models.py 100% <0%> (ø) ⬆️
tests/test_ws_router.py 100% <0%> (ø) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fc89eb8...8f0fde9. Read the comment docs.

@tiangolo
Copy link
Member

Thanks @wshayes ! I'll check it soon.

@tiangolo tiangolo merged commit d8716f9 into fastapi:master May 25, 2019
@tiangolo tiangolo changed the title Partial skip_defaults implementation (for #242) Add skip_defaults support for path operations (for #242) May 25, 2019
@tiangolo
Copy link
Member

Thank you @wshayes !

I updated it a bit, added docs, tests, etc.

I renamed the parameter to response_model_skip_defaults to be more explicit and intuitive.

Although I think it's too long, I think we can start with a "too long" completely explicit version and then update it to a shorter version, like response_skip_defaults or model_skip_defaults.

The updated docs are here: https://fastapi.tiangolo.com/tutorial/response-model/#response-model-encoding-parameters

It will be included in the next release.

Thanks! 🎉 🚀 🍰

@wshayes
Copy link
Contributor Author
wshayes commented May 25, 2019

Thank you - sorry I couldn't complete it on my own. Very nice job with the documentation. I'll study the changes you made so I can understand the flow better.

@tiangolo
Copy link
Member

Thanks for starting it @wshayes !

70F8

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

0