Skip to content

Additional responses can be status groups or "default" - #435

Merged
tiangolo merged 3 commits into
fastapi:masterfrom
divums:status_codes
Aug 30, 2019
Merged

tiangolo merged 3 commits into
fastapi:masterfrom
divums:status_codes

Conversation

@divums

@divums divums commented Aug 13, 2019 •

Copy link
Copy Markdown
Contributor

Catching exception when generating OpenAPI specification. Added status groups and "default" as possible key for the additional responses.

If merged, this issue fixes #428

@codecov

codecov Bot commented Aug 13, 2019 •

Copy link
Copy Markdown

Codecov Report

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

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #435   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files         240    244    +4     
  Lines        5626   5707   +81     
=====================================
+ Hits         5626   5707   +81
Impacted Files Coverage Ξ”
fastapi/openapi/utils.py 100% <100%> (ΓΈ) ⬆️
tests/test_additional_responses_bad.py 100% <100%> (ΓΈ)
tests/test_additional_responses_router.py 100% <100%> (ΓΈ) ⬆️
fastapi/dependencies/utils.py 100% <0%> (ΓΈ) ⬆️
fastapi/routing.py 100% <0%> (ΓΈ) ⬆️
tests/test_repeated_dependency_schema.py 100% <0%> (ΓΈ)
tests/test_empty_router.py 100% <0%> (ΓΈ)
tests/test_skip_defaults.py 100% <0%> (ΓΈ)

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 033bc2a...e673787. Read the comment docs.

@codecov

codecov Bot commented Aug 13, 2019

Copy link
Copy Markdown

Codecov Report

Merging #435 into master will decrease coverage by 0.01%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #435      +/-   ##
==========================================
- Coverage     100%   99.98%   -0.02%     
==========================================
  Files         240      240              
  Lines        5626     5632       +6     
==========================================
+ Hits         5626     5631       +5     
- Misses          0        1       +1
Impacted Files Coverage Ξ”
tests/test_additional_responses_router.py 100% <100%> (ΓΈ) ⬆️
fastapi/openapi/utils.py 99.38% <87.5%> (-0.62%) ⬇️

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 033bc2a...7f915cc. Read the comment docs.

Comment thread fastapi/openapi/utils.py Resolved
Comment thread Pipfile Resolved
Comment thread tests/test_additional_responses_bad.py Resolved
@tiangolo
tiangolo merged commit 73dbbea into fastapi:master Aug 30, 2019
@tiangolo

Copy link
Copy Markdown
Member

Awesome, thanks @divums ! Good job! πŸš€ 🍰

I updated it a bit, to use uppercase instead of lowercase, to conform with the spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#patterned-fields-1

And I augmented the tests to include some more of these cases.

And thanks a lot @dmontagu for the code review and help here! πŸ‘ πŸ’ͺ 🍰

@tiangolo

Copy link
Copy Markdown
Member

I realized I introduced a bug making it "DEFAULT" instead of "default", while making the status code ranges uppercase.

But I just fixed it in #489 πŸ›

I also added extra tests there to include "default" and other status codes at the same time and discovered another bug in the models. But it's fixed now. πŸ˜… πŸš€

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.

OpenAPI: response keys are limited to be status codes

3 participants