fastapi icon indicating copy to clipboard operation
fastapi copied to clipboard

⬆ Update HTML for docs/oauth2-redirect using swagger-ui's latest version

Open ypsah opened this issue 1 year ago • 4 comments

When using OpenIDConnect and the "authorization_code with PKCE" flow, swagger-ui will name the flow authorization_code rather than authorizationCode. [0]

The old HTML document generated by fastapi only handled the latter spelling. This meant that trying to authenticate using the swagger UI would fail with:

auth errorError: Bad Request, error: invalid_request, description: Missing parameter: code

This commit updates the HTML used by fastapi for the docs/oauth2-redirect using the latest version published by swagger-ui [1] which brings in a fix for the bug described above.

The rest of the changes relate to improving support for Chrome and Edge. [2]

[0] https://github.com/swagger-api/swagger-ui/blob/626defc839f80f0d08105cb72b8f6b7d3334db9c/src/core/components/auth/oauth2.jsx#L130 [1] https://github.com/swagger-api/swagger-ui/blob/626defc839f80f0d08105cb72b8f6b7d3334db9c/dev-helpers/oauth2-redirect.html [2] https://github.com/swagger-api/swagger-ui/pull/6393

ypsah avatar Jul 24 '22 09:07 ypsah

Codecov Report

Merging #5190 (5559d94) into master (5c576e4) will not change coverage. The diff coverage is n/a.

@@            Coverage Diff            @@
##            master     #5190   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          532       532           
  Lines        13684     13684           
=========================================
  Hits         13684     13684           
Impacted Files Coverage Δ
fastapi/openapi/docs.py 100.00% <ø> (ø)

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 5c576e4...5559d94. Read the comment docs.

codecov[bot] avatar Jul 24 '22 09:07 codecov[bot]

📝 Docs preview for commit 48fe070da9709a564e859d1772ca0a7ecae67354 at: https://62dd17f6705cf93f375b0260--fastapi.netlify.app

github-actions[bot] avatar Jul 24 '22 09:07 github-actions[bot]

📝 Docs preview for commit 5559d94ec5e70a2d5bd7c7218a75ce3bca2ffa51 at: https://62dd19c93e023846a3947097--fastapi.netlify.app

github-actions[bot] avatar Jul 24 '22 10:07 github-actions[bot]

Duplicates https://github.com/tiangolo/fastapi/pull/5189 but I feel like the commit message I wrote gives more context so I'll keep it open for now.

ypsah avatar Jul 24 '22 10:07 ypsah

Thank you @ypsah! :rocket:

This was solved in a recent PR, included in the next release, FastAPI 0.81.0, so I'll close this one. But if you feel there's something else that needs to be done, please create a new PR, to avoid the conflicts.

Thanks for the effort! :coffee:

tiangolo avatar Aug 26 '22 14:08 tiangolo