mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-31 02:00:34 -05:00
Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
628c34e0ca | ||
|
|
8e76d4e5f4 | ||
|
|
2537d9d1c2 | ||
|
|
c08a3e8f22 | ||
|
|
241de23b68 | ||
|
|
4e40e1e85d | ||
|
|
ecf6e7eec2 | ||
|
|
3afd733753 | ||
|
|
8557a88d16 | ||
|
|
e4c1dd799d | ||
|
|
f977da6ae0 | ||
|
|
f077c17e1e | ||
|
|
f9f1d93c58 | ||
|
|
7e33df505a | ||
|
|
f806e03807 | ||
|
|
90d52cfa16 | ||
|
|
7ab1b9edcc | ||
|
|
6859691419 | ||
|
|
d3cfe72cd7 | ||
|
|
e988050f79 | ||
|
|
3565ea00b6 | ||
|
|
643d2845de | ||
|
|
c46e4a1b14 | ||
|
|
79bc28fab4 | ||
|
|
a88a6050a6 | ||
|
|
0c36a7ac05 | ||
|
|
a592e8ad4d | ||
|
|
daf6820307 | ||
|
|
8c94e97c89 | ||
|
|
ab22979dc5 | ||
|
|
316566e40e |
@@ -14,7 +14,7 @@ repos:
|
||||
- id: end-of-file-fixer
|
||||
- id: trailing-whitespace
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.7.4
|
||||
rev: v0.9.4
|
||||
hooks:
|
||||
- id: ruff
|
||||
args:
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
maintainers:
|
||||
- login: tiangolo
|
||||
answers: 1894
|
||||
answers: 1897
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
experts:
|
||||
- login: tiangolo
|
||||
count: 1894
|
||||
count: 1897
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
- login: github-actions
|
||||
@@ -13,11 +13,11 @@ experts:
|
||||
avatarUrl: https://avatars.githubusercontent.com/in/15368?v=4
|
||||
url: https://github.com/apps/github-actions
|
||||
- login: Kludex
|
||||
count: 645
|
||||
count: 654
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
- login: jgould22
|
||||
count: 250
|
||||
count: 263
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: dmontagu
|
||||
@@ -25,7 +25,7 @@ experts:
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/35119617?u=540f30c937a6450812628b9592a1dfe91bbe148e&v=4
|
||||
url: https://github.com/dmontagu
|
||||
- login: YuriiMotov
|
||||
count: 223
|
||||
count: 238
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=e83a39697a2d33ab2ec9bfbced794ee48bc29cec&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
- login: Mause
|
||||
@@ -34,7 +34,7 @@ experts:
|
||||
url: https://github.com/Mause
|
||||
- login: ycd
|
||||
count: 217
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62724709?u=29682e4b6ac7d5293742ccf818188394b9a82972&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/62724709?u=f1e7bae394a315da950912c92dc861a8eaf95d4c&v=4
|
||||
url: https://github.com/ycd
|
||||
- login: JarroVGIT
|
||||
count: 192
|
||||
@@ -46,14 +46,14 @@ experts:
|
||||
url: https://github.com/euri10
|
||||
- login: iudeen
|
||||
count: 128
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10519440?u=2843b3303282bff8b212dcd4d9d6689452e4470c&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10519440?u=f09cdd745e5bf16138f29b42732dd57c7f02bee1&v=4
|
||||
url: https://github.com/iudeen
|
||||
- login: phy25
|
||||
count: 126
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/331403?v=4
|
||||
url: https://github.com/phy25
|
||||
- login: JavierSanchezCastro
|
||||
count: 85
|
||||
count: 91
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
|
||||
url: https://github.com/JavierSanchezCastro
|
||||
- login: raphaelauv
|
||||
@@ -69,7 +69,7 @@ experts:
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31127044?u=b0f2c37142f4b762e41ad65dc49581813422bd71&v=4
|
||||
url: https://github.com/ArcLightSlavik
|
||||
- login: n8sty
|
||||
count: 66
|
||||
count: 67
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2964996?v=4
|
||||
url: https://github.com/n8sty
|
||||
- login: falkben
|
||||
@@ -80,46 +80,46 @@ experts:
|
||||
count: 50
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/685002?u=b5094ab4527fc84b006c0ac9ff54367bdebb2267&v=4
|
||||
url: https://github.com/acidjunk
|
||||
- login: sm-Fifteen
|
||||
count: 49
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/516999?u=437c0c5038558c67e887ccd863c1ba0f846c03da&v=4
|
||||
url: https://github.com/sm-Fifteen
|
||||
- login: yinziyan1206
|
||||
count: 49
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37829370?u=da44ca53aefd5c23f346fab8e9fd2e108294c179&v=4
|
||||
url: https://github.com/yinziyan1206
|
||||
- login: sm-Fifteen
|
||||
count: 49
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/516999?u=437c0c5038558c67e887ccd863c1ba0f846c03da&v=4
|
||||
url: https://github.com/sm-Fifteen
|
||||
- login: luzzodev
|
||||
count: 48
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?u=5607ae1ce75c5f54f09500ca854227f7bfd2033b&v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: adriangb
|
||||
count: 46
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1755071?u=612704256e38d6ac9cbed24f10e4b6ac2da74ecb&v=4
|
||||
url: https://github.com/adriangb
|
||||
- login: Dustyposa
|
||||
count: 45
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27180793?u=5cf2877f50b3eb2bc55086089a78a36f07042889&v=4
|
||||
url: https://github.com/Dustyposa
|
||||
- login: insomnes
|
||||
count: 45
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/16958893?u=f8be7088d5076d963984a21f95f44e559192d912&v=4
|
||||
url: https://github.com/insomnes
|
||||
- login: odiseo0
|
||||
count: 43
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/87550035?u=241a71f6b7068738b81af3e57f45ffd723538401&v=4
|
||||
url: https://github.com/odiseo0
|
||||
- login: Dustyposa
|
||||
count: 45
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27180793?u=5cf2877f50b3eb2bc55086089a78a36f07042889&v=4
|
||||
url: https://github.com/Dustyposa
|
||||
- login: frankie567
|
||||
count: 43
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1144727?u=c159fe047727aedecbbeeaa96a1b03ceb9d39add&v=4
|
||||
url: https://github.com/frankie567
|
||||
- login: odiseo0
|
||||
count: 43
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/87550035?u=241a71f6b7068738b81af3e57f45ffd723538401&v=4
|
||||
url: https://github.com/odiseo0
|
||||
- login: sinisaos
|
||||
count: 40
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30960668?v=4
|
||||
url: https://github.com/sinisaos
|
||||
- login: includeamin
|
||||
count: 40
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/11836741?u=8bd5ef7e62fe6a82055e33c4c0e0a7879ff8cfb6&v=4
|
||||
url: https://github.com/includeamin
|
||||
- login: sinisaos
|
||||
count: 39
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30960668?v=4
|
||||
url: https://github.com/sinisaos
|
||||
- login: luzzodev
|
||||
count: 37
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: chbndrhnns
|
||||
count: 37
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7534547?v=4
|
||||
@@ -160,10 +160,10 @@ experts:
|
||||
count: 22
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4216559?u=360a36fb602cded27273cbfc0afc296eece90662&v=4
|
||||
url: https://github.com/nymous
|
||||
- login: acnebs
|
||||
- login: connebs
|
||||
count: 22
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9054108?v=4
|
||||
url: https://github.com/acnebs
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9054108?u=e151d5f545a3395136d711c227c22032fda67cfa&v=4
|
||||
url: https://github.com/connebs
|
||||
- login: chrisK824
|
||||
count: 22
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/79946379?u=03d85b22d696a58a9603e55fbbbe2de6b0f4face&v=4
|
||||
@@ -188,14 +188,14 @@ experts:
|
||||
count: 19
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10840422?u=45f015f95e1c0f06df602be4ab688d4b854cc8a8&v=4
|
||||
url: https://github.com/estebanx64
|
||||
- login: sehraramiz
|
||||
count: 18
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14166324?u=8fac65e84dfff24245d304a5b5b09f7b5bd69dc9&v=4
|
||||
url: https://github.com/sehraramiz
|
||||
- login: zoliknemet
|
||||
count: 18
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/22326718?u=31ba446ac290e23e56eea8e4f0c558aaf0b40779&v=4
|
||||
url: https://github.com/zoliknemet
|
||||
- login: sehraramiz
|
||||
count: 18
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14166324?u=8fac65e84dfff24245d304a5b5b09f7b5bd69dc9&v=4
|
||||
url: https://github.com/sehraramiz
|
||||
- login: retnikt
|
||||
count: 18
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/24581770?v=4
|
||||
@@ -216,6 +216,10 @@ experts:
|
||||
count: 17
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/28262306?u=e19427d8dc296d6950e9c424adacc92d37496fe9&v=4
|
||||
url: https://github.com/nkhitrov
|
||||
- login: alv2017
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: jonatasoli
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/26334101?u=071c062d2861d3dd127f6b4a5258cd8ef55d4c50&v=4
|
||||
@@ -224,6 +228,10 @@ experts:
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/41964673?u=9f2174f9d61c15c6e3a4c9e3aeee66f711ce311f&v=4
|
||||
url: https://github.com/dstlny
|
||||
- login: abhint
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25699289?u=b5d219277b4d001ac26fb8be357fddd88c29d51b&v=4
|
||||
url: https://github.com/abhint
|
||||
- login: ceb10n
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/235213?u=edcce471814a1eba9f0cdaa4cd0de18921a940a6&v=4
|
||||
@@ -236,100 +244,96 @@ experts:
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/33907262?u=2721fb37014d50daf473267c808aa678ecaefe09&v=4
|
||||
url: https://github.com/simondale00
|
||||
- login: ghost
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10137?u=b1951d34a583cf12ec0d3b0781ba19be97726318&v=4
|
||||
url: https://github.com/ghost
|
||||
- login: abhint
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/25699289?u=b5d219277b4d001ac26fb8be357fddd88c29d51b&v=4
|
||||
url: https://github.com/abhint
|
||||
last_month_experts:
|
||||
- login: Kludex
|
||||
count: 14
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
- login: YuriiMotov
|
||||
count: 10
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=e83a39697a2d33ab2ec9bfbced794ee48bc29cec&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
- login: sehraramiz
|
||||
count: 7
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14166324?u=8fac65e84dfff24245d304a5b5b09f7b5bd69dc9&v=4
|
||||
url: https://github.com/sehraramiz
|
||||
- login: luzzodev
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: yokwejuste
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/71908316?u=592c1e42aa0ee5cb94890e0b863e2acc78cc3bbc&v=4
|
||||
url: https://github.com/yokwejuste
|
||||
- login: jgould22
|
||||
count: 13
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: alv2017
|
||||
count: 3
|
||||
count: 10
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: Trinkes
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9466879?v=4
|
||||
url: https://github.com/Trinkes
|
||||
- login: PREPONDERANCE
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/112809059?u=30ab12dc9ddba2f94ab90e6ad4ad8bc5cfa7fccd&v=4
|
||||
url: https://github.com/PREPONDERANCE
|
||||
- login: nbx3
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/34649527?u=943812f69e0d40adbd3fa1c9b8ef50dd971a2a45&v=4
|
||||
url: https://github.com/nbx3
|
||||
- login: XiaoXinYo
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=b3b7cb758997f283c271a581833e407229dab82c&v=4
|
||||
url: https://github.com/XiaoXinYo
|
||||
- login: iloveitaly
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/150855?v=4
|
||||
url: https://github.com/iloveitaly
|
||||
three_months_experts:
|
||||
- login: luzzodev
|
||||
count: 33
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?v=4
|
||||
count: 8
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?u=5607ae1ce75c5f54f09500ca854227f7bfd2033b&v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: YuriiMotov
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=e83a39697a2d33ab2ec9bfbced794ee48bc29cec&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
- login: Kludex
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
- login: JavierSanchezCastro
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
|
||||
url: https://github.com/JavierSanchezCastro
|
||||
- login: tiangolo
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
- login: Ale-Cas
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/64859146?u=d52a6ecf8d83d2927e2ae270bdfcc83495dba8c9&v=4
|
||||
url: https://github.com/Ale-Cas
|
||||
- login: vtgn
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/112889052?v=4
|
||||
url: https://github.com/vtgn
|
||||
three_months_experts:
|
||||
- login: YuriiMotov
|
||||
count: 31
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=e83a39697a2d33ab2ec9bfbced794ee48bc29cec&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
- login: Kludex
|
||||
count: 24
|
||||
count: 25
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
- login: luzzodev
|
||||
count: 19
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?u=5607ae1ce75c5f54f09500ca854227f7bfd2033b&v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: alv2017
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: jgould22
|
||||
count: 13
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: sehraramiz
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14166324?u=8fac65e84dfff24245d304a5b5b09f7b5bd69dc9&v=4
|
||||
url: https://github.com/sehraramiz
|
||||
- login: estebanx64
|
||||
count: 7
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10840422?u=45f015f95e1c0f06df602be4ab688d4b854cc8a8&v=4
|
||||
url: https://github.com/estebanx64
|
||||
- login: yvallois
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/36999744?v=4
|
||||
url: https://github.com/yvallois
|
||||
- login: JavierSanchezCastro
|
||||
count: 8
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
|
||||
url: https://github.com/JavierSanchezCastro
|
||||
- login: tiangolo
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
- login: yokwejuste
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/71908316?u=592c1e42aa0ee5cb94890e0b863e2acc78cc3bbc&v=4
|
||||
url: https://github.com/yokwejuste
|
||||
- login: jgould22
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: alv2017
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: viniciusCalcantara
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/108818737?u=3d7ffe5808843ee4372f9cc5a559ff1674cf1792&v=4
|
||||
url: https://github.com/viniciusCalcantara
|
||||
- login: SobikXexe
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/87701130?v=4
|
||||
url: https://github.com/SobikXexe
|
||||
- login: Ale-Cas
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/64859146?u=d52a6ecf8d83d2927e2ae270bdfcc83495dba8c9&v=4
|
||||
url: https://github.com/Ale-Cas
|
||||
- login: vtgn
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/112889052?v=4
|
||||
url: https://github.com/vtgn
|
||||
- login: Trinkes
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9466879?v=4
|
||||
@@ -344,117 +348,81 @@ three_months_experts:
|
||||
url: https://github.com/nbx3
|
||||
- login: XiaoXinYo
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=b3b7cb758997f283c271a581833e407229dab82c&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=1eebf5ce25a8067f7bfa6251a24f667be492d9d6&v=4
|
||||
url: https://github.com/XiaoXinYo
|
||||
- login: JavierSanchezCastro
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
|
||||
url: https://github.com/JavierSanchezCastro
|
||||
- login: iloveitaly
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/150855?v=4
|
||||
url: https://github.com/iloveitaly
|
||||
- login: LincolnPuzey
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/18750802?v=4
|
||||
url: https://github.com/LincolnPuzey
|
||||
- login: Knighthawk-Leo
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72437494?u=27c68db94a3107b605e603cc136f4ba83f0106d5&v=4
|
||||
url: https://github.com/Knighthawk-Leo
|
||||
- login: gelezo43
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/40732698?u=611f39d3c1d2f4207a590937a78c1f10eed6232c&v=4
|
||||
url: https://github.com/gelezo43
|
||||
- login: AliYmn
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/18416653?u=98c1fca46c7e4dabe8c39d17b5e55d1511d41cf9&v=4
|
||||
url: https://github.com/AliYmn
|
||||
- login: RichieB2B
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1461970?u=edaa57d1077705244ea5c9244f4783d94ff11f12&v=4
|
||||
url: https://github.com/RichieB2B
|
||||
- login: Synrom
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30272537?v=4
|
||||
url: https://github.com/Synrom
|
||||
- login: iiotsrc
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/131771119?u=bcaf2559ef6266af70b151b7fda31a1ee3dbecb3&v=4
|
||||
url: https://github.com/iiotsrc
|
||||
- login: Kfir-G
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/57500876?u=0cd29db046a17f12f382d398141319fca7ff230a&v=4
|
||||
url: https://github.com/Kfir-G
|
||||
six_months_experts:
|
||||
- login: YuriiMotov
|
||||
count: 72
|
||||
count: 63
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=e83a39697a2d33ab2ec9bfbced794ee48bc29cec&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
- login: luzzodev
|
||||
count: 48
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?u=5607ae1ce75c5f54f09500ca854227f7bfd2033b&v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: Kludex
|
||||
count: 40
|
||||
count: 48
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
- login: luzzodev
|
||||
count: 37
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: sinisaos
|
||||
count: 37
|
||||
count: 23
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30960668?v=4
|
||||
url: https://github.com/sinisaos
|
||||
- login: jgould22
|
||||
count: 17
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: JavierSanchezCastro
|
||||
count: 16
|
||||
count: 17
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
|
||||
url: https://github.com/JavierSanchezCastro
|
||||
- login: alv2017
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: Kfir-G
|
||||
count: 13
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/57500876?u=0cd29db046a17f12f382d398141319fca7ff230a&v=4
|
||||
url: https://github.com/Kfir-G
|
||||
- login: tiangolo
|
||||
count: 12
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
- login: sehraramiz
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14166324?u=8fac65e84dfff24245d304a5b5b09f7b5bd69dc9&v=4
|
||||
url: https://github.com/sehraramiz
|
||||
- login: ceb10n
|
||||
count: 10
|
||||
count: 7
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/235213?u=edcce471814a1eba9f0cdaa4cd0de18921a940a6&v=4
|
||||
url: https://github.com/ceb10n
|
||||
- login: estebanx64
|
||||
count: 7
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10840422?u=45f015f95e1c0f06df602be4ab688d4b854cc8a8&v=4
|
||||
url: https://github.com/estebanx64
|
||||
- login: tiangolo
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
- login: yvallois
|
||||
count: 6
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/36999744?v=4
|
||||
url: https://github.com/yvallois
|
||||
- login: n8sty
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2964996?v=4
|
||||
url: https://github.com/n8sty
|
||||
- login: TomFaulkner
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14956620?v=4
|
||||
url: https://github.com/TomFaulkner
|
||||
- login: yokwejuste
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/71908316?u=592c1e42aa0ee5cb94890e0b863e2acc78cc3bbc&v=4
|
||||
url: https://github.com/yokwejuste
|
||||
- login: jgould22
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: alv2017
|
||||
- login: n8sty
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2964996?v=4
|
||||
url: https://github.com/n8sty
|
||||
- login: viniciusCalcantara
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/108818737?u=3d7ffe5808843ee4372f9cc5a559ff1674cf1792&v=4
|
||||
url: https://github.com/viniciusCalcantara
|
||||
- login: SobikXexe
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/87701130?v=4
|
||||
url: https://github.com/SobikXexe
|
||||
- login: pawelad
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7062874?u=d27dc220545a8401ad21840590a97d474d7101e6&v=4
|
||||
@@ -467,26 +435,18 @@ six_months_experts:
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/48672727?u=34d7b4ade252687d22a27cf53037b735b244bfc1&v=4
|
||||
url: https://github.com/Isuxiz
|
||||
- login: bertomaniac
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10235051?u=14484a96833228a7b29fee4a7916d411c242c4f6&v=4
|
||||
url: https://github.com/bertomaniac
|
||||
- login: PhysicallyActive
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/160476156?u=7a8e44f4a43d3bba636f795bb7d9476c9233b4d8&v=4
|
||||
url: https://github.com/PhysicallyActive
|
||||
- login: Minibrams
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8108085?u=b028dbc308fa8485e0e2e9402b3d03d8deb22bf9&v=4
|
||||
url: https://github.com/Minibrams
|
||||
- login: AIdjis
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/88404339?u=2a80d80b054e9228391e32fb9bb39571509dab6a&v=4
|
||||
url: https://github.com/AIdjis
|
||||
- login: svlandeg
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
|
||||
url: https://github.com/svlandeg
|
||||
- login: Ale-Cas
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/64859146?u=d52a6ecf8d83d2927e2ae270bdfcc83495dba8c9&v=4
|
||||
url: https://github.com/Ale-Cas
|
||||
- login: vtgn
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/112889052?v=4
|
||||
url: https://github.com/vtgn
|
||||
- login: Trinkes
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9466879?v=4
|
||||
@@ -499,26 +459,10 @@ six_months_experts:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/34649527?u=943812f69e0d40adbd3fa1c9b8ef50dd971a2a45&v=4
|
||||
url: https://github.com/nbx3
|
||||
- login: yanggeorge
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2434407?v=4
|
||||
url: https://github.com/yanggeorge
|
||||
- login: XiaoXinYo
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=b3b7cb758997f283c271a581833e407229dab82c&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=1eebf5ce25a8067f7bfa6251a24f667be492d9d6&v=4
|
||||
url: https://github.com/XiaoXinYo
|
||||
- login: pythonweb2
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/32141163?v=4
|
||||
url: https://github.com/pythonweb2
|
||||
- login: slafs
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/210173?v=4
|
||||
url: https://github.com/slafs
|
||||
- login: AmirHmZz
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/38752106?u=07f80e451bda00a9492bbc764e49d24ad3ada8cc&v=4
|
||||
url: https://github.com/AmirHmZz
|
||||
- login: iloveitaly
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/150855?v=4
|
||||
@@ -527,10 +471,6 @@ six_months_experts:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/18750802?v=4
|
||||
url: https://github.com/LincolnPuzey
|
||||
- login: alejsdev
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/90076947?u=356f39ff3f0211c720b06d3dbb060e98884085e3&v=4
|
||||
url: https://github.com/alejsdev
|
||||
- login: Knighthawk-Leo
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72437494?u=27c68db94a3107b605e603cc136f4ba83f0106d5&v=4
|
||||
@@ -559,10 +499,6 @@ six_months_experts:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30272537?v=4
|
||||
url: https://github.com/Synrom
|
||||
- login: ecly
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8410422?v=4
|
||||
url: https://github.com/ecly
|
||||
- login: iiotsrc
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/131771119?u=bcaf2559ef6266af70b151b7fda31a1ee3dbecb3&v=4
|
||||
@@ -575,14 +511,6 @@ six_months_experts:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/47495003?u=6e225cb42c688d0cd70e65c6baedb9f5922b1178&v=4
|
||||
url: https://github.com/jd-solanki
|
||||
- login: AumGupta
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/86357151?u=7d05aa606c0611a18f4db16cf26361ce10a6e195&v=4
|
||||
url: https://github.com/AumGupta
|
||||
- login: DeoLeung
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3764720?u=4c222ef513814de4c7fb3736d0a7adf11d953d43&v=4
|
||||
url: https://github.com/DeoLeung
|
||||
- login: Reemyos
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/44867003?v=4
|
||||
@@ -591,77 +519,61 @@ six_months_experts:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37678115?u=a608798b5bd0034183a9c430ebb42fb266db86ce&v=4
|
||||
url: https://github.com/deight93
|
||||
- login: PhysicallyActive
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/160476156?u=7a8e44f4a43d3bba636f795bb7d9476c9233b4d8&v=4
|
||||
url: https://github.com/PhysicallyActive
|
||||
- login: Jkrox
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/83181939?u=d6a922d97129f7f3916d6a1c166bc011b3a72b7f&v=4
|
||||
url: https://github.com/Jkrox
|
||||
- login: mmzeynalli
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/33568903?u=19efd0c0722730b83a70b7c86c36e5b7d83e07d2&v=4
|
||||
url: https://github.com/mmzeynalli
|
||||
- login: ddahan
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1933516?u=1d200a620e8d6841df017e9f2bb7efb58b580f40&v=4
|
||||
url: https://github.com/ddahan
|
||||
- login: jfeaver
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1091338?u=0bcba366447d8fadad63f6705a52d128da4c7ec2&v=4
|
||||
url: https://github.com/jfeaver
|
||||
- login: Wurstnase
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8709415?u=f479af475a97aee9a1dab302cfc35d07e9ea245f&v=4
|
||||
url: https://github.com/Wurstnase
|
||||
- login: tristan
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1412?u=aab8aaa4cc0f1210ac45fc93873a5909d314c965&v=4
|
||||
url: https://github.com/tristan
|
||||
- login: chandanch
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8663552?u=afc484bc0a952c83f1fb6a1583cda443f807cd66&v=4
|
||||
url: https://github.com/chandanch
|
||||
- login: rvishruth
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/79176273?v=4
|
||||
url: https://github.com/rvishruth
|
||||
- login: mattmess1221
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3409962?u=723662989f2027755e67d200137c13c53ae154ac&v=4
|
||||
url: https://github.com/mattmess1221
|
||||
one_year_experts:
|
||||
- login: YuriiMotov
|
||||
count: 223
|
||||
count: 214
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109919500?u=e83a39697a2d33ab2ec9bfbced794ee48bc29cec&v=4
|
||||
url: https://github.com/YuriiMotov
|
||||
- login: Kludex
|
||||
count: 81
|
||||
count: 66
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7353520?u=df8a3f06ba8f55ae1967a3e2d5ed882903a4e330&v=4
|
||||
url: https://github.com/Kludex
|
||||
- login: luzzodev
|
||||
count: 48
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?u=5607ae1ce75c5f54f09500ca854227f7bfd2033b&v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: sinisaos
|
||||
count: 40
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30960668?v=4
|
||||
url: https://github.com/sinisaos
|
||||
- login: JavierSanchezCastro
|
||||
count: 47
|
||||
count: 39
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72013291?u=ae5679e6bd971d9d98cd5e76e8683f83642ba950&v=4
|
||||
url: https://github.com/JavierSanchezCastro
|
||||
- login: jgould22
|
||||
count: 42
|
||||
count: 35
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4335847?u=ed77f67e0bb069084639b24d812dbb2a2b1dc554&v=4
|
||||
url: https://github.com/jgould22
|
||||
- login: sinisaos
|
||||
count: 39
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30960668?v=4
|
||||
url: https://github.com/sinisaos
|
||||
- login: luzzodev
|
||||
count: 37
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/27291415?v=4
|
||||
url: https://github.com/luzzodev
|
||||
- login: tiangolo
|
||||
count: 24
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1326112?u=cb5d06e73a9e1998141b1641aa88e443c6717651&v=4
|
||||
url: https://github.com/tiangolo
|
||||
- login: alv2017
|
||||
count: 16
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: n8sty
|
||||
count: 23
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2964996?v=4
|
||||
url: https://github.com/n8sty
|
||||
- login: estebanx64
|
||||
count: 19
|
||||
count: 15
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10840422?u=45f015f95e1c0f06df602be4ab688d4b854cc8a8&v=4
|
||||
url: https://github.com/estebanx64
|
||||
- login: ceb10n
|
||||
@@ -682,10 +594,10 @@ one_year_experts:
|
||||
url: https://github.com/Kfir-G
|
||||
- login: mattmess1221
|
||||
count: 11
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3409962?u=723662989f2027755e67d200137c13c53ae154ac&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3409962?u=d22ea18aa8ea688af25a45df306134d593621a44&v=4
|
||||
url: https://github.com/mattmess1221
|
||||
- login: hasansezertasan
|
||||
count: 10
|
||||
count: 8
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/13135006?u=99f0b0f0fc47e88e8abb337b4447357939ef93e7&v=4
|
||||
url: https://github.com/hasansezertasan
|
||||
- login: AIdjis
|
||||
@@ -704,22 +616,18 @@ one_year_experts:
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/32141163?v=4
|
||||
url: https://github.com/pythonweb2
|
||||
- login: acidjunk
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/685002?u=b5094ab4527fc84b006c0ac9ff54367bdebb2267&v=4
|
||||
url: https://github.com/acidjunk
|
||||
- login: gustavosett
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/99373133?u=1739ca547c3d200f1b72450520bce46a97aab184&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/99373133?u=1382fe27034a0179f07cf989f63c4f23017f043c&v=4
|
||||
url: https://github.com/gustavosett
|
||||
- login: binbjz
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8213913?u=22b68b7a0d5bf5e09c02084c0f5f53d7503114cd&v=4
|
||||
url: https://github.com/binbjz
|
||||
- login: chyok
|
||||
count: 5
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/32629225?u=3b7c30e8a09426a1b9284f6e8a0ae53a525596bf&v=4
|
||||
url: https://github.com/chyok
|
||||
- login: svlandeg
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
|
||||
url: https://github.com/svlandeg
|
||||
- login: TomFaulkner
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/14956620?v=4
|
||||
@@ -728,42 +636,34 @@ one_year_experts:
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/71908316?u=592c1e42aa0ee5cb94890e0b863e2acc78cc3bbc&v=4
|
||||
url: https://github.com/yokwejuste
|
||||
- login: DeoLeung
|
||||
- login: acidjunk
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3764720?u=4c222ef513814de4c7fb3736d0a7adf11d953d43&v=4
|
||||
url: https://github.com/DeoLeung
|
||||
- login: flo-at
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/564288?v=4
|
||||
url: https://github.com/flo-at
|
||||
- login: GodMoonGoodman
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/29688727?u=7b251da620d999644c37c1feeb292d033eed7ad6&v=4
|
||||
url: https://github.com/GodMoonGoodman
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/685002?u=b5094ab4527fc84b006c0ac9ff54367bdebb2267&v=4
|
||||
url: https://github.com/acidjunk
|
||||
- login: bertomaniac
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10235051?u=14484a96833228a7b29fee4a7916d411c242c4f6&v=4
|
||||
url: https://github.com/bertomaniac
|
||||
- login: alv2017
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/31544722?v=4
|
||||
url: https://github.com/alv2017
|
||||
- login: msehnout
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9369632?u=8c988f1b008a3f601385a3616f9327820f66e3a5&v=4
|
||||
url: https://github.com/msehnout
|
||||
- login: binbjz
|
||||
count: 4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8213913?u=22b68b7a0d5bf5e09c02084c0f5f53d7503114cd&v=4
|
||||
url: https://github.com/binbjz
|
||||
- login: viniciusCalcantara
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/108818737?u=3d7ffe5808843ee4372f9cc5a559ff1674cf1792&v=4
|
||||
url: https://github.com/viniciusCalcantara
|
||||
- login: SobikXexe
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/87701130?v=4
|
||||
url: https://github.com/SobikXexe
|
||||
- login: DeoLeung
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/3764720?u=4c222ef513814de4c7fb3736d0a7adf11d953d43&v=4
|
||||
url: https://github.com/DeoLeung
|
||||
- login: pawelad
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/7062874?u=d27dc220545a8401ad21840590a97d474d7101e6&v=4
|
||||
url: https://github.com/pawelad
|
||||
- login: ThirVondukr
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/50728601?u=167c0bd655e52817082e50979a86d2f98f95b1a3&v=4
|
||||
url: https://github.com/ThirVondukr
|
||||
- login: dbfreem
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9778569?u=f2f1e9135b5e4f1b0c6821a548b17f97572720fc&v=4
|
||||
@@ -772,10 +672,6 @@ one_year_experts:
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/48672727?u=34d7b4ade252687d22a27cf53037b735b244bfc1&v=4
|
||||
url: https://github.com/Isuxiz
|
||||
- login: angely-dev
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/4362224?v=4
|
||||
url: https://github.com/angely-dev
|
||||
- login: deight93
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/37678115?u=a608798b5bd0034183a9c430ebb42fb266db86ce&v=4
|
||||
@@ -792,42 +688,70 @@ one_year_experts:
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/53449841?v=4
|
||||
url: https://github.com/ryanisn
|
||||
- login: svlandeg
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8796347?u=556c97650c27021911b0b9447ec55e75987b0e8a&v=4
|
||||
url: https://github.com/svlandeg
|
||||
- login: alexandercronin
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/8014288?u=69580504c51a0cdd756fc47b23bb7f404bd694e7&v=4
|
||||
url: https://github.com/alexandercronin
|
||||
- login: aanchlia
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/2835374?u=3c3ed29aa8b09ccaf8d66def0ce82bc2f7e5aab6&v=4
|
||||
url: https://github.com/aanchlia
|
||||
- login: chrisK824
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/79946379?u=03d85b22d696a58a9603e55fbbbe2de6b0f4face&v=4
|
||||
url: https://github.com/chrisK824
|
||||
- login: omarcruzpantoja
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/15116058?u=4b64c643fad49225d854e1aaecd1ffc6f9071a1b&v=4
|
||||
url: https://github.com/omarcruzpantoja
|
||||
- login: ahmedabdou14
|
||||
count: 3
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/104530599?u=d87b866e7c1db970d6f8e8031643818349b046d5&v=4
|
||||
url: https://github.com/ahmedabdou14
|
||||
- login: Wyko
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/467094?v=4
|
||||
url: https://github.com/Wyko
|
||||
- login: ddahan
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1933516?u=1d200a620e8d6841df017e9f2bb7efb58b580f40&v=4
|
||||
url: https://github.com/ddahan
|
||||
- login: Ale-Cas
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/64859146?u=d52a6ecf8d83d2927e2ae270bdfcc83495dba8c9&v=4
|
||||
url: https://github.com/Ale-Cas
|
||||
- login: Trolldemorted
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/10261186?v=4
|
||||
url: https://github.com/Trolldemorted
|
||||
- login: vtgn
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/112889052?v=4
|
||||
url: https://github.com/vtgn
|
||||
- login: SDAravind
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/72403396?v=4
|
||||
url: https://github.com/SDAravind
|
||||
- login: slafs
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/210173?v=4
|
||||
url: https://github.com/slafs
|
||||
- login: redb0
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/30475117?v=4
|
||||
url: https://github.com/redb0
|
||||
- login: pedroconceicao
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/32837064?u=5a0e6559bc391442629a28b6923790b54deb4464&v=4
|
||||
url: https://github.com/pedroconceicao
|
||||
- login: msukmanowsky
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/362755?u=782e6bf5b9f0356c3f74b4d894fda9f179252086&v=4
|
||||
url: https://github.com/msukmanowsky
|
||||
- login: rishabhc32
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/15983714?u=147776509107af8bdf099223e1840d3f40f944da&v=4
|
||||
url: https://github.com/rishabhc32
|
||||
- login: meower1
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/109747197?u=0a5cc2a6ae74e558f0afc2874da85132e5953d8b&v=4
|
||||
url: https://github.com/meower1
|
||||
- login: Trinkes
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/9466879?v=4
|
||||
url: https://github.com/Trinkes
|
||||
- login: Leon0824
|
||||
- login: anantgupta129
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/1922026?v=4
|
||||
url: https://github.com/Leon0824
|
||||
- login: CarlosOliveira-23
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/102637302?u=cf350a4db956f30cbb2c27d3be0d15c282e32b14&v=4
|
||||
url: https://github.com/CarlosOliveira-23
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/66518357?u=6e25dcd84638f17d2c6df5dc26f07fd7c6dc118e&v=4
|
||||
url: https://github.com/anantgupta129
|
||||
- login: nbx3
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/34649527?u=943812f69e0d40adbd3fa1c9b8ef50dd971a2a45&v=4
|
||||
@@ -838,16 +762,8 @@ one_year_experts:
|
||||
url: https://github.com/yanggeorge
|
||||
- login: XiaoXinYo
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=b3b7cb758997f283c271a581833e407229dab82c&v=4
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/56395004?u=1eebf5ce25a8067f7bfa6251a24f667be492d9d6&v=4
|
||||
url: https://github.com/XiaoXinYo
|
||||
- login: anantgupta129
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/66518357?u=6e25dcd84638f17d2c6df5dc26f07fd7c6dc118e&v=4
|
||||
url: https://github.com/anantgupta129
|
||||
- login: slafs
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/210173?v=4
|
||||
url: https://github.com/slafs
|
||||
- login: monchin
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/18521800?v=4
|
||||
@@ -860,11 +776,3 @@ one_year_experts:
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/150855?v=4
|
||||
url: https://github.com/iloveitaly
|
||||
- login: msukmanowsky
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/362755?u=782e6bf5b9f0356c3f74b4d894fda9f179252086&v=4
|
||||
url: https://github.com/msukmanowsky
|
||||
- login: shurshilov
|
||||
count: 2
|
||||
avatarUrl: https://avatars.githubusercontent.com/u/11828278?u=6bcadc5ce4f2f56a514331c9f68eb987d4afe29a&v=4
|
||||
url: https://github.com/shurshilov
|
||||
|
||||
@@ -58,9 +58,9 @@ bronze:
|
||||
- url: https://www.exoflare.com/open-source/?utm_source=FastAPI&utm_campaign=open_source
|
||||
title: Biosecurity risk assessments made easy.
|
||||
img: https://fastapi.tiangolo.com/img/sponsors/exoflare.png
|
||||
- url: https://testdriven.io/courses/tdd-fastapi/
|
||||
title: Learn to build high-quality web apps with best practices
|
||||
img: https://fastapi.tiangolo.com/img/sponsors/testdriven.svg
|
||||
# - url: https://testdriven.io/courses/tdd-fastapi/
|
||||
# title: Learn to build high-quality web apps with best practices
|
||||
# img: https://fastapi.tiangolo.com/img/sponsors/testdriven.svg
|
||||
- url: https://lambdatest.com/?utm_source=fastapi&utm_medium=partner&utm_campaign=sponsor&utm_term=opensource&utm_content=webpage
|
||||
title: LambdaTest, AI-Powered Cloud-based Test Orchestration Platform
|
||||
img: https://fastapi.tiangolo.com/img/sponsors/lambdatest.png
|
||||
|
||||
@@ -19,18 +19,3 @@ And it's possible that for your use case, the solution is in one of them.
|
||||
You could still use most of the features in **FastAPI** with the knowledge from the main [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank}.
|
||||
|
||||
And the next sections assume you already read it, and assume that you know those main ideas.
|
||||
|
||||
## External Courses
|
||||
|
||||
Although the [Tutorial - User Guide](../tutorial/index.md){.internal-link target=_blank} and this **Advanced User Guide** are written as a guided tutorial (like a book) and should be enough for you to **learn FastAPI**, you might want to complement it with additional courses.
|
||||
|
||||
Or it might be the case that you just prefer to take other courses because they adapt better to your learning style.
|
||||
|
||||
Some course providers ✨ [**sponsor FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨, this ensures the continued and healthy **development** of FastAPI and its **ecosystem**.
|
||||
|
||||
And it shows their true commitment to FastAPI and its **community** (you), as they not only want to provide you a **good learning experience** but also want to make sure you have a **good and healthy framework**, FastAPI. 🙇
|
||||
|
||||
You might want to try their courses:
|
||||
|
||||
* <a href="https://training.talkpython.fm/fastapi-courses" class="external-link" target="_blank">Talk Python Training</a>
|
||||
* <a href="https://testdriven.io/courses/tdd-fastapi/" class="external-link" target="_blank">Test-Driven Development</a>
|
||||
|
||||
@@ -7,6 +7,35 @@ hide:
|
||||
|
||||
## Latest Changes
|
||||
|
||||
## 0.115.12
|
||||
|
||||
### Fixes
|
||||
|
||||
* 🐛 Fix `convert_underscores=False` for header Pydantic models. PR [#13515](https://github.com/fastapi/fastapi/pull/13515) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Docs
|
||||
|
||||
* 📝 Update `docs/en/docs/tutorial/middleware.md`. PR [#13444](https://github.com/fastapi/fastapi/pull/13444) by [@Rishat-F](https://github.com/Rishat-F).
|
||||
* 👥 Update FastAPI People - Experts. PR [#13493](https://github.com/fastapi/fastapi/pull/13493) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
### Translations
|
||||
|
||||
* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/metadata.md` page. PR [#13459](https://github.com/fastapi/fastapi/pull/13459) by [@valentinDruzhinin](https://github.com/valentinDruzhinin).
|
||||
* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/response-status-code.md` page. PR [#13462](https://github.com/fastapi/fastapi/pull/13462) by [@valentinDruzhinin](https://github.com/valentinDruzhinin).
|
||||
* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/cookie-param-models.md` page. PR [#13460](https://github.com/fastapi/fastapi/pull/13460) by [@valentinDruzhinin](https://github.com/valentinDruzhinin).
|
||||
* 🌐 Add Ukrainian translation for `docs/uk/docs/tutorial/header-param-models.md` page. PR [#13461](https://github.com/fastapi/fastapi/pull/13461) by [@valentinDruzhinin](https://github.com/valentinDruzhinin).
|
||||
* 🌐 Add Japanese translation for `docs/ja/docs/virtual-environments.md`. PR [#13304](https://github.com/fastapi/fastapi/pull/13304) by [@k94-ishi](https://github.com/k94-ishi).
|
||||
* 🌐 Add Korean translation for `docs/ko/docs/tutorial/security/oauth2-jwt.md`. PR [#13333](https://github.com/fastapi/fastapi/pull/13333) by [@yes0ng](https://github.com/yes0ng).
|
||||
* 🌐 Add Vietnamese translation for `docs/vi/docs/deployment/cloud.md`. PR [#13407](https://github.com/fastapi/fastapi/pull/13407) by [@ptt3199](https://github.com/ptt3199).
|
||||
|
||||
### Internal
|
||||
|
||||
* ⬆ Bump pydantic-ai from 0.0.15 to 0.0.30. PR [#13438](https://github.com/fastapi/fastapi/pull/13438) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump sqlmodel from 0.0.22 to 0.0.23. PR [#13437](https://github.com/fastapi/fastapi/pull/13437) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump black from 24.10.0 to 25.1.0. PR [#13436](https://github.com/fastapi/fastapi/pull/13436) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* ⬆ Bump ruff to 0.9.4. PR [#13299](https://github.com/fastapi/fastapi/pull/13299) by [@dependabot[bot]](https://github.com/apps/dependabot).
|
||||
* 🔧 Update sponsors: pause TestDriven. PR [#13446](https://github.com/fastapi/fastapi/pull/13446) by [@tiangolo](https://github.com/tiangolo).
|
||||
|
||||
## 0.115.11
|
||||
|
||||
### Fixes
|
||||
|
||||
@@ -51,6 +51,22 @@ For example, if the client tries to send a `tool` header with a value of `plumbu
|
||||
}
|
||||
```
|
||||
|
||||
## Disable Convert Underscores
|
||||
|
||||
The same way as with regular header parameters, when you have underscore characters in the parameter names, they are **automatically converted to hyphens**.
|
||||
|
||||
For example, if you have a header parameter `save_data` in the code, the expected HTTP header will be `save-data`, and it will show up like that in the docs.
|
||||
|
||||
If for some reason you need to disable this automatic conversion, you can do it as well for Pydantic models for header parameters.
|
||||
|
||||
{* ../../docs_src/header_param_models/tutorial003_an_py310.py hl[19] *}
|
||||
|
||||
/// warning
|
||||
|
||||
Before setting `convert_underscores` to `False`, bear in mind that some HTTP proxies and servers disallow the usage of headers with underscores.
|
||||
|
||||
///
|
||||
|
||||
## Summary
|
||||
|
||||
You can use **Pydantic models** to declare **headers** in **FastAPI**. 😎
|
||||
|
||||
@@ -15,7 +15,7 @@ A "middleware" is a function that works with every **request** before it is proc
|
||||
|
||||
If you have dependencies with `yield`, the exit code will run *after* the middleware.
|
||||
|
||||
If there were any background tasks (documented later), they will run *after* all the middleware.
|
||||
If there were any background tasks (covered in the [Background Tasks](background-tasks.md){.internal-link target=_blank} section, you will see it later), they will run *after* all the middleware.
|
||||
|
||||
///
|
||||
|
||||
|
||||
831
docs/ja/docs/virtual-environments.md
Normal file
831
docs/ja/docs/virtual-environments.md
Normal file
@@ -0,0 +1,831 @@
|
||||
# 仮想環境
|
||||
|
||||
Pythonプロジェクトの作業では、**仮想環境**(または類似の仕組み)を使用し、プロジェクトごとにインストールするパッケージを分離するべきでしょう。
|
||||
|
||||
/// info | 情報
|
||||
|
||||
もし、仮想環境の概要や作成方法、使用方法について既にご存知なら、このセクションをスキップすることができます。🤓
|
||||
|
||||
///
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
**仮想環境**は、**環境変数**とは異なります。
|
||||
|
||||
**環境変数**は、プログラムが使用できるシステム内の変数です。
|
||||
|
||||
**仮想環境**は、ファイルをまとめたディレクトリのことです。
|
||||
|
||||
///
|
||||
|
||||
/// info | 情報
|
||||
このページでは、**仮想環境**の使用方法と、そのはたらきについて説明します。
|
||||
|
||||
もし**すべてを管理するツール**(Pythonのインストールも含む)を導入する準備ができているなら、<a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">uv</a> をお試しください。
|
||||
|
||||
///
|
||||
|
||||
## プロジェクトの作成
|
||||
|
||||
まず、プロジェクト用のディレクトリを作成します。
|
||||
|
||||
私は通常 home/user ディレクトリの中に `code` というディレクトリを用意していて、プロジェクトごとに1つのディレクトリをその中に作成しています。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
// Go to the home directory
|
||||
$ cd
|
||||
// Create a directory for all your code projects
|
||||
$ mkdir code
|
||||
// Enter into that code directory
|
||||
$ cd code
|
||||
// Create a directory for this project
|
||||
$ mkdir awesome-project
|
||||
// Enter into that project directory
|
||||
$ cd awesome-project
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
## 仮想環境の作成
|
||||
|
||||
Pythonプロジェクトでの**初めての**作業を開始する際には、**<abbr title="他の選択肢もありますが、これはシンプルなガイドラインです">プロジェクト内</abbr>**に仮想環境を作成してください。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
これを行うのは、**プロジェクトごとに1回だけ**です。作業のたびに行う必要はありません。
|
||||
|
||||
///
|
||||
|
||||
//// tab | `venv`
|
||||
|
||||
仮想環境を作成するには、Pythonに付属している `venv` モジュールを使用できます。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python -m venv .venv
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
/// details | このコマンドの意味
|
||||
|
||||
- `python` : `python` というプログラムを呼び出します
|
||||
- `-m` : モジュールをスクリプトとして呼び出します。どのモジュールを呼び出すのか、この次に指定します
|
||||
- `venv` : 通常Pythonに付随してインストールされる `venv`モジュールを使用します
|
||||
- `.venv` : 仮想環境を`.venv`という新しいディレクトリに作成します
|
||||
|
||||
///
|
||||
|
||||
////
|
||||
|
||||
//// tab | `uv`
|
||||
|
||||
もし <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a> をインストール済みなら、仮想環境を作成するために `uv` を使うこともできます。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ uv venv
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
デフォルトでは、 `uv` は `.venv` というディレクトリに仮想環境を作成します。
|
||||
|
||||
ただし、追加の引数にディレクトリ名を与えてカスタマイズすることもできます。
|
||||
|
||||
///
|
||||
|
||||
////
|
||||
|
||||
このコマンドは `.venv` というディレクトリに新しい仮想環境を作成します。
|
||||
|
||||
/// details | `.venv` またはその他の名前
|
||||
|
||||
仮想環境を別のディレクトリに作成することも可能ですが、 `.venv` と名付けるのが一般的な慣習です。
|
||||
|
||||
///
|
||||
|
||||
## 仮想環境の有効化
|
||||
|
||||
実行されるPythonコマンドやインストールされるパッケージが新しく作成した仮想環境を使用するよう、その仮想環境を有効化しましょう。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
そのプロジェクトの作業で**新しいターミナルセッション**を開始する際には、**毎回**有効化が必要です。
|
||||
|
||||
///
|
||||
|
||||
//// tab | Linux, macOS
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ source .venv/bin/activate
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows PowerShell
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ .venv\Scripts\Activate.ps1
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows Bash
|
||||
|
||||
もしWindowsでBashを使用している場合 (<a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>など):
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ source .venv/Scripts/activate
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
**新しいパッケージ**を仮想環境にインストールするときには、再度**有効化**してください。
|
||||
|
||||
こうすることで、そのパッケージがインストールした**ターミナル(<abbr title="command line interface">CLI</abbr>)プログラム**を使用する場合に、仮想環境内のものが確実に使われ、グローバル環境にインストールされている別のもの(おそらく必要なものとは異なるバージョン)を誤って使用することを防ぎます。
|
||||
|
||||
///
|
||||
|
||||
## 仮想環境が有効であることを確認する
|
||||
|
||||
仮想環境が有効である(前のコマンドが正常に機能した)ことを確認します。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
これは**任意**ですが、すべてが期待通りに機能し、意図した仮想環境を使用していることを**確認する**良い方法です。
|
||||
|
||||
///
|
||||
|
||||
//// tab | Linux, macOS, Windows Bash
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ which python
|
||||
|
||||
/home/user/code/awesome-project/.venv/bin/python
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
`.venv/bin/python` にある `python` バイナリが、プロジェクト(この場合は `awesome-project` )内に表示されていれば、正常に動作しています 🎉。
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows PowerShell
|
||||
|
||||
<div class="termy">
|
||||
|
||||
``` console
|
||||
$ Get-Command python
|
||||
|
||||
C:\Users\user\code\awesome-project\.venv\Scripts\python
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
`.venv\Scripts\python` にある `python` バイナリが、プロジェクト(この場合は `awesome-project` )内に表示されていれば、正常に動作しています 🎉。
|
||||
|
||||
////
|
||||
|
||||
## `pip` をアップグレードする
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
もし <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a> を使用している場合は、 `pip` の代わりに `uv` を使ってインストールを行うため、 `pip` をアップグレードする必要はありません 😎。
|
||||
|
||||
///
|
||||
|
||||
もしパッケージのインストールに `pip`(Pythonに標準で付属しています)を使用しているなら、 `pip` を最新バージョンに**アップグレード**しましょう。
|
||||
|
||||
パッケージのインストール中に発生する想定外のエラーの多くは、最初に `pip` をアップグレードしておくだけで解決されます。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
通常、これは仮想環境を作成した直後に**一度だけ**実行します。
|
||||
|
||||
///
|
||||
|
||||
仮想環境が有効であることを(上で説明したコマンドで)確認し、アップグレードを実行しましょう:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python -m pip install --upgrade pip
|
||||
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
## `.gitignore` を追加する
|
||||
|
||||
**Git**を使用している場合(使用するべきでしょう)、 `.gitignore` ファイルを追加して、 `.venv` 内のあらゆるファイルをGitの管理対象から除外します。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
もし <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a> を使用して仮想環境を作成した場合、すでにこの作業は済んでいるので、この手順をスキップできます 😎。
|
||||
|
||||
///
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
これも、仮想環境を作成した直後に**一度だけ**実行します。
|
||||
|
||||
///
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ echo "*" > .venv/.gitignore
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
/// details | このコマンドの意味
|
||||
|
||||
- `echo "*"` : ターミナルに `*` というテキストを「表示」しようとします。(次の部分によってその動作が少し変わります)
|
||||
- `>` : `>` の左側のコマンドがターミナルに表示しようとする内容を、ターミナルには表示せず、 `>` の右側のファイルに書き込みます。
|
||||
- `.gitignore` : `*` を書き込むファイル名。
|
||||
|
||||
ここで、Gitにおける `*` は「すべて」を意味するので、このコマンドによって `.venv` ディレクトリ内のすべてがGitに無視されるようになります。
|
||||
|
||||
このコマンドは以下のテキストを持つ `.gitignore` ファイルを作成します:
|
||||
|
||||
```gitignore
|
||||
*
|
||||
```
|
||||
|
||||
///
|
||||
|
||||
## パッケージのインストール
|
||||
|
||||
仮想環境を有効化した後、その中でパッケージをインストールできます。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
プロジェクトに必要なパッケージをインストールまたはアップグレードする場合、これを**一度**実行します。
|
||||
|
||||
もし新しいパッケージを追加したり、バージョンをアップグレードする必要がある場合は、もう**一度この手順を繰り返し**ます。
|
||||
|
||||
///
|
||||
|
||||
### パッケージを直接インストールする
|
||||
|
||||
急いでいて、プロジェクトのパッケージ要件を宣言するファイルを使いたくない場合、パッケージを直接インストールできます。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
プログラムが必要とするパッケージとバージョンをファイル(例えば `requirements.txt` や `pyproject.toml` )に記載しておくのは、(とても)良い考えです。
|
||||
|
||||
///
|
||||
|
||||
//// tab | `pip`
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ pip install "fastapi[standard]"
|
||||
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | `uv`
|
||||
|
||||
もし <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a> を使用できるなら:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ uv pip install "fastapi[standard]"
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
### `requirements.txt` からインストールする
|
||||
|
||||
もし `requirements.txt` があるなら、パッケージのインストールに使用できます。
|
||||
|
||||
//// tab | `pip`
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ pip install -r requirements.txt
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | `uv`
|
||||
|
||||
もし <a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">`uv`</a> を使用できるなら:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ uv pip install -r requirements.txt
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
/// details | `requirements.txt`
|
||||
|
||||
パッケージが記載された `requirements.txt` は以下のようになっています:
|
||||
|
||||
```requirements.txt
|
||||
fastapi[standard]==0.113.0
|
||||
pydantic==2.8.0
|
||||
```
|
||||
|
||||
///
|
||||
|
||||
## プログラムを実行する
|
||||
|
||||
仮想環境を有効化した後、プログラムを実行できます。この際、仮想環境内のPythonと、そこにインストールしたパッケージが使用されます。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ python main.py
|
||||
|
||||
Hello World
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
## エディタの設定
|
||||
|
||||
プロジェクトではおそらくエディタを使用するでしょう。コード補完やインラインエラーの表示ができるように、作成した仮想環境をエディタでも使えるよう設定してください。(多くの場合、自動検出されます)
|
||||
|
||||
設定例:
|
||||
|
||||
* <a href="https://code.visualstudio.com/docs/python/environments#_select-and-activate-an-environment" class="external-link" target="_blank">VS Code</a>
|
||||
* <a href="https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html" class="external-link" target="_blank">PyCharm</a>
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
この設定は通常、仮想環境を作成した際に**一度だけ**行います。
|
||||
|
||||
///
|
||||
|
||||
## 仮想環境の無効化
|
||||
|
||||
プロジェクトの作業が終了したら、その仮想環境を**無効化**できます。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ deactivate
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
これにより、 `python` コマンドを実行しても、そのプロジェクト用(のパッケージがインストールされた)仮想環境から `python` プログラムを呼び出そうとはしなくなります。
|
||||
|
||||
## 作業準備完了
|
||||
|
||||
ここまでで、プロジェクトの作業を始める準備が整いました。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
上記の内容を理解したいですか?
|
||||
|
||||
もしそうなら、以下を読み進めてください。👇🤓
|
||||
|
||||
///
|
||||
|
||||
## なぜ仮想環境?
|
||||
|
||||
FastAPIを使った作業をするには、 [Python](https://www.python.org/) のインストールが必要です。
|
||||
|
||||
それから、FastAPIや、使用したいその他の**パッケージ**を**インストール**する必要があります。
|
||||
|
||||
パッケージをインストールするには、通常、Python に付属する `pip` コマンド (または同様の代替コマンド) を使用します。
|
||||
|
||||
ただし、`pip` を直接使用すると、パッケージは**グローバルなPython環境**(OS全体にインストールされたPython環境)にインストールされます。
|
||||
|
||||
### 問題点
|
||||
|
||||
では、グローバルPython環境にパッケージをインストールすることの問題点は何でしょうか?
|
||||
|
||||
ある時点で、あなたは**異なるパッケージ**に依存する多くのプログラムを書くことになるでしょう。そして、これらの中には同じパッケージの**異なるバージョン**に依存するものも出てくるでしょう。😱
|
||||
|
||||
例えば、 `philosophers-stone` (賢者の石)というプロジェクトを作成するとします。このプログラムは **`harry` (ハリー)というパッケージのバージョン `1`**に依存しています。そのため、 `harry` (ハリー)をインストールする必要があります。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
stone(philosophers-stone) -->|requires| harry-1[harry v1]
|
||||
```
|
||||
|
||||
それから、 `prisoner-of-azkaban` (アズカバンの囚人)という別のプロジェクトを作成したとします。このプロジェクトも `harry` (ハリー)に依存していますが、**`harry` (ハリー)のバージョン `3`**が必要です。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
azkaban(prisoner-of-azkaban) --> |requires| harry-3[harry v3]
|
||||
```
|
||||
|
||||
しかし、ここで問題になるのは、もしローカルの**仮想環境**ではなくグローバル(環境)にパッケージをインストールするなら、 `harry` (ハリー)のどのバージョンをインストールするか選ばないといけないことです。
|
||||
|
||||
例えば、 `philosophers-stone` (賢者の石)を実行するには、まず `harry` (ハリー)のバージョン `1` をインストールする必要があります:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ pip install "harry==1"
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
これにより、`harry` (ハリー)バージョン1がグローバルなPython環境にインストールされます。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[global env]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone project]
|
||||
stone(philosophers-stone) -->|requires| harry-1
|
||||
end
|
||||
```
|
||||
|
||||
しかし、 `prisoner-of-azkaban` (アズカバンの囚人)を実行したい場合は、`harry` (ハリー)のバージョン `1` をアンインストールし、`harry` (ハリー)のバージョン `3` をインストールし直す必要があります。(あるいは、単に`harry` (ハリー)のバージョン `3` をインストールすることで、自動的にバージョン `1` がアンインストールされます)
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ pip install "harry==3"
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
このようにして、グローバル環境への `harry` (ハリー)のバージョン `3` のインストールが完了します。
|
||||
|
||||
それから、 `philosophers-stone` (賢者の石)を再び実行しようとすると、このプログラムは `harry` (ハリー)のバージョン `1` が必要なため、**動作しなくなる**可能性があります。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
subgraph global[global env]
|
||||
harry-1[<strike>harry v1</strike>]
|
||||
style harry-1 fill:#ccc,stroke-dasharray: 5 5
|
||||
harry-3[harry v3]
|
||||
end
|
||||
subgraph stone-project[philosophers-stone project]
|
||||
stone(philosophers-stone) -.-x|⛔️| harry-1
|
||||
end
|
||||
subgraph azkaban-project[prisoner-of-azkaban project]
|
||||
azkaban(prisoner-of-azkaban) --> |requires| harry-3
|
||||
end
|
||||
```
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
Pythonのパッケージでは、**新しいバージョン**で**互換性を損なう変更を避ける**よう努めるのが一般的ですが、それでも注意が必要です。すべてが正常に動作することをテストで確認してから、意図的に指定して新しいバージョンをインストールするのが良いでしょう。
|
||||
|
||||
///
|
||||
|
||||
あなたのすべての**プロジェクトが依存している**、**多数の**他の**パッケージ**が上記の問題を抱えていると想像してください。これは管理が非常に困難です。そして、**互換性のないバージョン**のパッケージを使ってプロジェクトを実行し、なぜ動作しないのか分からなくなるでしょう。
|
||||
|
||||
また、使用しているOS(Linux、Windows、macOS など)によっては、Pythonがすでにインストールされていることがあります。この場合、特定のバージョンのパッケージが**OSの動作に必要である**ことがあります。グローバル環境にパッケージをインストールすると、OSに付属するプログラムを**壊してしまう**可能性があります。
|
||||
|
||||
## パッケージのインストール先
|
||||
|
||||
Pythonをインストールしたとき、ファイルを含んだいくつかのディレクトリが作成されます。
|
||||
|
||||
これらの中には、インストールされたパッケージを保存するためのものもあります。
|
||||
|
||||
以下のコマンドを実行したとき:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
// Don't run this now, it's just an example 🤓
|
||||
$ pip install "fastapi[standard]"
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
FastAPIのコードを含む圧縮ファイルが、通常は [PyPI](https://pypi.org/project/fastapi/) からダウンロードされます。
|
||||
|
||||
また、FastAPIが依存する他のパッケージも**ダウンロード**されます。
|
||||
|
||||
それから、これらのファイルは**解凍**され、コンピュータのあるディレクトリに配置されます。
|
||||
|
||||
デフォルトでは、これらのファイルはPythonのインストール時に作成されるディレクトリ、つまり**グローバル環境**に配置されます。
|
||||
|
||||
## 仮想環境とは
|
||||
|
||||
すべてのパッケージをグローバル環境に配置することによって生じる問題の解決策は、作業する**プロジェクトごとの仮想環境**を使用することです。
|
||||
|
||||
仮想環境は**ディレクトリ**であり、グローバル環境と非常に似ていて、一つのプロジェクトで使う特定のパッケージ群をインストールできる場所です。
|
||||
|
||||
このようにして、それぞれのプロジェクトが独自の仮想環境(`.venv` ディレクトリ)に独自のパッケージ群を持つことができます。
|
||||
|
||||
```mermaid
|
||||
flowchart TB
|
||||
subgraph stone-project[philosophers-stone project]
|
||||
stone(philosophers-stone) --->|requires| harry-1
|
||||
subgraph venv1[.venv]
|
||||
harry-1[harry v1]
|
||||
end
|
||||
end
|
||||
subgraph azkaban-project[prisoner-of-azkaban project]
|
||||
azkaban(prisoner-of-azkaban) --->|requires| harry-3
|
||||
subgraph venv2[.venv]
|
||||
harry-3[harry v3]
|
||||
end
|
||||
end
|
||||
stone-project ~~~ azkaban-project
|
||||
```
|
||||
|
||||
## 仮想環境の有効化とは
|
||||
|
||||
仮想環境を有効にしたとき、例えば次のコマンドを実行した場合を考えます:
|
||||
|
||||
//// tab | Linux, macOS
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ source .venv/bin/activate
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows PowerShell
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ .venv\Scripts\Activate.ps1
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows Bash
|
||||
|
||||
あるいは、WindowsでBashを使用している場合 (<a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>など):
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ source .venv/Scripts/activate
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
これによって、いくつかの [環境変数](environment-variables.md){.internal-link target=_blank} が作成・修正され、次に実行されるコマンドで使用できるようになります。
|
||||
|
||||
これらの環境変数のひとつに、 `PATH` 変数があります。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
`PATH` 変数についての詳細は [環境変数](environment-variables.md#path環境変数){.internal-link target=_blank} を参照してください。
|
||||
|
||||
///
|
||||
|
||||
仮想環境を有効にすると、その仮想環境のパス `.venv/bin` (LinuxとmacOS)、あるいは `.venv\Scripts` (Windows)が `PATH` 変数に追加されます。
|
||||
|
||||
その環境を有効にする前の `PATH` 変数が次のようになっているとします。
|
||||
|
||||
//// tab | Linux, macOS
|
||||
|
||||
```plaintext
|
||||
/usr/bin:/bin:/usr/sbin:/sbin
|
||||
```
|
||||
|
||||
これは、OSが以下のディレクトリ中でプログラムを探すことを意味します:
|
||||
|
||||
* `/usr/bin`
|
||||
* `/bin`
|
||||
* `/usr/sbin`
|
||||
* `/sbin`
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows
|
||||
|
||||
```plaintext
|
||||
C:\Windows\System32
|
||||
```
|
||||
|
||||
これは、OSが以下のディレクトリ中でプログラムを探すことを意味します:
|
||||
|
||||
* `C:\Windows\System32`
|
||||
|
||||
////
|
||||
|
||||
仮想環境を有効にすると、 `PATH` 変数は次のようになります。
|
||||
|
||||
//// tab | Linux, macOS
|
||||
|
||||
```plaintext
|
||||
/home/user/code/awesome-project/.venv/bin:/usr/bin:/bin:/usr/sbin:/sbin
|
||||
```
|
||||
|
||||
これは、OSが他のディレクトリを探すより前に、最初に以下のディレクトリ中でプログラムを探し始めることを意味します:
|
||||
|
||||
```plaintext
|
||||
/home/user/code/awesome-project/.venv/bin
|
||||
```
|
||||
|
||||
そのため、ターミナルで `python` と入力した際に、OSはPythonプログラムを以下のパスで発見し、使用します。
|
||||
|
||||
```plaintext
|
||||
/home/user/code/awesome-project/.venv/bin/python
|
||||
```
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows
|
||||
|
||||
```plaintext
|
||||
C:\Users\user\code\awesome-project\.venv\Scripts;C:\Windows\System32
|
||||
```
|
||||
|
||||
これは、OSが他のディレクトリを探すより前に、最初に以下のディレクトリ中でプログラムを探し始めることを意味します:
|
||||
|
||||
```plaintext
|
||||
C:\Users\user\code\awesome-project\.venv\Scripts
|
||||
```
|
||||
|
||||
そのため、ターミナルで `python` と入力した際に、OSはPythonプログラムを以下のパスで発見し、使用します。
|
||||
|
||||
```plaintext
|
||||
C:\Users\user\code\awesome-project\.venv\Scripts\python
|
||||
```
|
||||
|
||||
////
|
||||
|
||||
重要な点は、仮想環境のパスを `PATH` 変数の**先頭**に配置することです。OSは利用可能な他のPythonを見つけるより**前に**、この仮想環境のPythonを見つけるようになります。このようにして、 `python` を実行したときに、他の `python` (例えばグローバル環境の `python` )ではなく、**その仮想環境の**Pythonを使用するようになります。
|
||||
|
||||
仮想環境を有効にして変更されることは他にもありますが、これが最も重要な変更のひとつです。
|
||||
|
||||
## 仮想環境の確認
|
||||
|
||||
仮想環境が有効かどうか、例えば次のように確認できます。:
|
||||
|
||||
//// tab | Linux, macOS, Windows Bash
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ which python
|
||||
|
||||
/home/user/code/awesome-project/.venv/bin/python
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
//// tab | Windows PowerShell
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ Get-Command python
|
||||
|
||||
C:\Users\user\code\awesome-project\.venv\Scripts\python
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
////
|
||||
|
||||
これは、使用される `python` プログラムが**その仮想環境の**ものであることを意味します。
|
||||
|
||||
LinuxやmacOSでは `which` を、Windows PowerShellでは `Get-Command` を使用します。
|
||||
|
||||
このコマンドの動作は、 `PATH`変数に設定された**それぞれのパスを順に**確認していき、呼ばれている `python` プログラムを探します。そして、見つかり次第そのプログラムへの**パスを表示します**。
|
||||
|
||||
最も重要なことは、 `python` が呼ばれたときに、まさにこのコマンドで確認した "`python`" が実行されることです。
|
||||
|
||||
こうして、自分が想定通りの仮想環境にいるかを確認できます。
|
||||
|
||||
/// tip | 豆知識
|
||||
|
||||
ある仮想環境を有効にし、そのPythonを使用したまま**他のプロジェクトに移動して**しまうことは簡単に起こり得ます。
|
||||
|
||||
そして、その第二のプロジェクトは動作しないでしょう。なぜなら別のプロジェクトの仮想環境の**誤ったPython**を使用しているからです。
|
||||
|
||||
そのため、どの `python` が使用されているのか確認できることは役立ちます。🤓
|
||||
|
||||
///
|
||||
|
||||
## なぜ仮想環境を無効化するのか
|
||||
|
||||
例えば、`philosophers-stone` (賢者の石)というプロジェクトで作業をしていて、**その仮想環境を有効にし**、必要なパッケージをインストールしてその環境内で作業を進めているとします。
|
||||
|
||||
それから、**別のプロジェクト**、 `prisoner-of-azkaban` (アズカバンの囚人)に取り掛かろうとします。
|
||||
|
||||
そのプロジェクトディレクトリへ移動します:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ cd ~/code/prisoner-of-azkaban
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
もし `philosophers-stone` (賢者の石)の仮想環境を無効化していないと、`python` を実行したとき、 ターミナルは `philosophers-stone` (賢者の石)のPythonを使用しようとします。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ cd ~/code/prisoner-of-azkaban
|
||||
|
||||
$ python main.py
|
||||
|
||||
// Error importing sirius, it's not installed 😱
|
||||
Traceback (most recent call last):
|
||||
File "main.py", line 1, in <module>
|
||||
import sirius
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
しかし、その仮想環境を無効化し、 `prisoner-of-azkaban` (アズカバンの囚人)のための新しい仮想環境を有効にすれば、 `python` を実行したときに `prisoner-of-azkaban` (アズカバンの囚人)の仮想環境の Python が使用されるようになります。
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ cd ~/code/prisoner-of-azkaban
|
||||
|
||||
// You don't need to be in the old directory to deactivate, you can do it wherever you are, even after going to the other project 😎
|
||||
$ deactivate
|
||||
|
||||
// Activate the virtual environment in prisoner-of-azkaban/.venv 🚀
|
||||
$ source .venv/bin/activate
|
||||
|
||||
// Now when you run python, it will find the package sirius installed in this virtual environment ✨
|
||||
$ python main.py
|
||||
|
||||
I solemnly swear 🐺
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
## 代替手段
|
||||
|
||||
これは、あらゆる仕組みを**根本から**学ぶためのシンプルな入門ガイドです。
|
||||
|
||||
仮想環境、パッケージの依存関係(requirements)、プロジェクトの管理には、多くの**代替手段**があります。
|
||||
|
||||
準備が整い、パッケージの依存関係、仮想環境など**プロジェクト全体の管理**ツールを使いたいと考えたら、<a href="https://github.com/astral-sh/uv" class="external-link" target="_blank">uv</a> を試してみることをおすすめします。
|
||||
|
||||
`uv` では以下のような多くのことができます:
|
||||
|
||||
* 異なるバージョンも含めた**Python のインストール**
|
||||
* プロジェクトごとの**仮想環境**の管理
|
||||
* **パッケージ**のインストール
|
||||
* プロジェクトのパッケージの**依存関係やバージョン**の管理
|
||||
* パッケージとそのバージョンの、依存関係を含めた**厳密な**組み合わせを保持し、これによって、本番環境で、開発環境と全く同じようにプロジェクトを実行できる(これは**locking**と呼ばれます)
|
||||
* その他のさまざまな機能
|
||||
|
||||
## まとめ
|
||||
|
||||
ここまで読みすべて理解したなら、世間の多くの開発者と比べて、仮想環境について**あなたはより多くのことを知っています**。🤓
|
||||
|
||||
これらの詳細を知ることは、将来、複雑に見える何かのデバッグにきっと役立つでしょう。しかし、その頃には、あなたは**そのすべての動作を根本から**理解しているでしょう。😎
|
||||
273
docs/ko/docs/tutorial/security/oauth2-jwt.md
Normal file
273
docs/ko/docs/tutorial/security/oauth2-jwt.md
Normal file
@@ -0,0 +1,273 @@
|
||||
# 패스워드 해싱을 이용한 OAuth2, JWT 토큰을 사용하는 Bearer 인증
|
||||
|
||||
모든 보안 흐름을 구성했으므로, 이제 <abbr title="JSON Web Tokens">JWT</abbr> 토큰과 패스워드 해싱을 사용해 애플리케이션을 안전하게 만들 것입니다.
|
||||
|
||||
이 코드는 실제로 애플리케이션에서 패스워드를 해싱하여 DB에 저장하는 등의 작업에 활용할 수 있습니다.
|
||||
|
||||
이전 장에 이어서 시작해 봅시다.
|
||||
|
||||
## JWT
|
||||
|
||||
JWT 는 "JSON Web Tokens" 을 의미합니다.
|
||||
|
||||
JSON 객체를 공백이 없는 긴 문자열로 인코딩하는 표준이며, 다음과 같은 형태입니다:
|
||||
|
||||
```
|
||||
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
|
||||
```
|
||||
|
||||
JWT는 암호화되지 않아 누구든지 토큰에서 정보를 복원할 수 있습니다.
|
||||
|
||||
하지만 JWT는 서명되어 있습니다. 그래서 자신이 발급한 토큰을 받았을 때, 실제로 자신이 발급한게 맞는지 검증할 수 있습니다.
|
||||
|
||||
만료 기간이 일주일인 토큰을 발행했다고 가정해 봅시다. 다음 날 사용자가 토큰을 가져왔을 때, 그 사용자가 시스템에 여전히 로그인되어 있다는 것을 알 수 있습니다.
|
||||
|
||||
일주일 뒤에는 토큰이 만료될 것이고, 사용자는 인가되지 않아 새 토큰을 받기 위해 다시 로그인해야 할 것입니다. 만약 사용자(또는 제3자)가 토큰을 수정하거나 만료일을 변경하면, 서명이 일치하지 않기 때문에 알아챌 수 있을 것입니다.
|
||||
|
||||
만약 JWT 토큰을 다뤄보고, 작동 방식도 알아보고 싶다면 <a href="https://jwt.io/" class="external-link" target="_blank">https://jwt.io</a> 을 확인하십시오.
|
||||
|
||||
## `PyJWT` 설치
|
||||
|
||||
파이썬으로 JWT 토큰을 생성하고 검증하려면 `PyJWT` 를 설치해야 합니다.
|
||||
|
||||
[가상환경](../../virtual-environments.md){.internal-link target=_blank} 을 만들고 활성화한 다음 `pyjwt` 를 설치하십시오:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ pip install pyjwt
|
||||
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
/// info | 참고
|
||||
|
||||
RSA나 ECDSA 같은 전자 서명 알고리즘을 사용하려면, `pyjwt[crypto]`라는 암호화 라이브러리 의존성을 설치해야 합니다.
|
||||
|
||||
더 자세한 내용은 <a href="https://pyjwt.readthedocs.io/en/latest/installation.html" class="external-link" target="_blank">PyJWT 설치</a> 에서 확인할 수 있습니다.
|
||||
|
||||
///
|
||||
|
||||
## 패스워드 해싱
|
||||
|
||||
"해싱(Hashing)"은 어떤 내용(여기서는 패스워드)을 해석할 수 없는 일련의 바이트 집합(단순 문자열)으로 변환하는 것을 의미합니다.
|
||||
|
||||
동일한 내용(똑같은 패스워드)을 해싱하면 동일한 문자열을 얻습니다.
|
||||
|
||||
하지만 그 문자열을 다시 패스워드로 되돌릴 수는 없습니다.
|
||||
|
||||
### 패스워드를 해싱하는 이유
|
||||
|
||||
데이터베이스를 탈취당하더라도, 침입자는 사용자의 평문 패스워드 대신 해시 값만 얻을 수 있습니다.
|
||||
|
||||
따라서 침입자는 훔친 사용자 패스워드를 다른 시스템에서 활용할 수 없습니다. (대다수 사용자가 여러 시스템에서 동일한 패스워드를 사용하기 때문에 평문 패스워드가 유출되면 위험합니다.)
|
||||
|
||||
## `passlib` 설치
|
||||
|
||||
PassLib는 패스워드 해시를 다루는 훌륭한 파이썬 패키지입니다.
|
||||
|
||||
많은 안전한 해시 알고리즘과 도구들을 지원합니다.
|
||||
|
||||
추천하는 알고리즘은 "Bcrypt"입니다.
|
||||
|
||||
[가상환경](../../virtual-environments.md){.internal-link target=_blank} 을 만들고 활성화한 다음 PassLib와 Bcrypt를 설치하십시오:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ pip install "passlib[bcrypt]"
|
||||
|
||||
---> 100%
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
/// tip | 팁
|
||||
|
||||
`passlib`를 사용하여, **Django**, **Flask** 의 보안 플러그인이나 다른 도구로 생성한 패스워드를 읽을 수 있도록 설정할 수도 있습니다.
|
||||
|
||||
예를 들자면, FastAPI 애플리케이션과 Django 애플리케이션이 같은 데이터베이스에서 데이터를 공유할 수 있습니다. 또는 같은 데이터베이스를 사용하여 Django 애플리케이션을 점진적으로 마이그레이션 할 수도 있습니다.
|
||||
|
||||
그리고 사용자는 FastAPI 애플리케이션과 Django 애플리케이션에 동시에 로그인할 수 있습니다.
|
||||
|
||||
///
|
||||
|
||||
## 패스워드의 해시와 검증
|
||||
|
||||
필요한 도구를 `passlib`에서 임포트합니다.
|
||||
|
||||
PassLib "컨텍스트(context)"를 생성합니다. 이것은 패스워드를 해싱하고 검증하는데 사용합니다.
|
||||
|
||||
/// tip | 팁
|
||||
|
||||
PassLib 컨텍스트는 다양한 해싱 알고리즘을 사용할 수 있는 기능을 제공하며, 더 이상 사용이 권장되지 않는 오래된 해싱 알고리즘을 검증하는 기능도 포함되어 있습니다.
|
||||
|
||||
예를 들어, 다른 시스템(Django 같은)에서 생성한 패스워드를 읽고 검증할 수 있으며, 새로운 패스워드를 Bcrypt 같은 다른 알고리즘으로 해싱할 수도 있습니다.
|
||||
|
||||
그리고 동시에 그런 모든 알고리즘과 호환성을 유지합니다.
|
||||
|
||||
///
|
||||
|
||||
사용자로부터 받은 패스워드를 해싱하는 유틸리티 함수를 생성합니다.
|
||||
|
||||
그리고 받은 패스워드가 저장된 해시와 일치하는지 검증하는 또 다른 유틸리티 함수도 생성합니다.
|
||||
|
||||
그리고 사용자를 인증하고 반환하는 또 다른 함수도 생성합니다.
|
||||
|
||||
{* ../../docs_src/security/tutorial004_an_py310.py hl[8,49,56:57,60:61,70:76] *}
|
||||
|
||||
/// note
|
||||
|
||||
새로운 (가짜) 데이터베이스 `fake_users_db`를 확인하면, 해시 처리된 패스워드가 어떻게 생겼는지 볼 수 있습니다: `"$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW"`.
|
||||
|
||||
///
|
||||
|
||||
## JWT 토큰 처리
|
||||
|
||||
설치된 모듈을 임포트 합니다.
|
||||
|
||||
JWT 토큰 서명에 사용될 임의의 비밀키를 생성합니다.
|
||||
|
||||
안전한 임의의 비밀키를 생성하려면 다음 명령어를 사용하십시오:
|
||||
|
||||
<div class="termy">
|
||||
|
||||
```console
|
||||
$ openssl rand -hex 32
|
||||
|
||||
09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
그리고 생성한 비밀키를 복사해 변수 `SECRET_KEY`에 대입합니다. (이 예제의 변수 값을 그대로 사용하지 마십시오.)
|
||||
|
||||
JWT 토큰을 서명하는 데 사용될 알고리즘을 위한 변수 `ALGORITHM` 을 생성하고 `"HS256"` 으로 설정합니다.
|
||||
|
||||
토큰 만료 기간을 위한 변수를 생성합니다.
|
||||
|
||||
응답을 위한 토큰 엔드포인트에 사용될 Pydantic 모델을 정의합니다.
|
||||
|
||||
새 액세스 토큰을 생성하기 위한 유틸리티 함수를 생성합니다.
|
||||
|
||||
{* ../../docs_src/security/tutorial004_an_py310.py hl[4,7,13:15,29:31,79:87] *}
|
||||
|
||||
## 의존성 수정
|
||||
|
||||
`get_current_user` 함수를 이전과 동일한 토큰을 받도록 수정하되, 이번에는 JWT 토큰을 사용하도록 합니다.
|
||||
|
||||
받은 토큰을 디코딩하여 검증한 후 현재 사용자를 반환합니다.
|
||||
|
||||
토큰이 유효하지 않다면 HTTP 오류를 반환합니다.
|
||||
|
||||
{* ../../docs_src/security/tutorial004_an_py310.py hl[90:107] *}
|
||||
|
||||
## `/token` 경로 작업 수정
|
||||
|
||||
토큰의 만료 시각을 설정하기 위해 `timedelta` 를 생성합니다.
|
||||
|
||||
실제 JWT 액세스 토큰을 생성하여 반환합니다.
|
||||
|
||||
{* ../../docs_src/security/tutorial004_an_py310.py hl[118:133] *}
|
||||
|
||||
### JWT "주체(subject)" `sub`에 대한 기술 세부 사항
|
||||
|
||||
JWT 명세에 따르면 토큰의 주체를 포함하는 `sub`라는 키가 있습니다.
|
||||
|
||||
사용 여부는 선택사항이지만, 사용자의 식별 정보를 저장할 수 있으므로 여기서는 이를 사용합니다.
|
||||
|
||||
JWT는 사용자를 식별하고 사용자가 API를 직접 사용할 수 있도록 허용하는 것 외에도 다른 용도로 사용될 수도 있습니다.
|
||||
|
||||
예를 들어 "자동차"나 "블로그 게시물"을 식별하는 데 사용할 수 있습니다.
|
||||
|
||||
그리고 "자동차를 운전하다"나 "블로그 게시물을 수정하다"처럼 해당 엔터티에 대한 권한을 추가할 수 있습니다.
|
||||
|
||||
그 후 이 JWT 토큰을 사용자(또는 봇)에게 제공하면, 그들은 계정을 따로 만들 필요 없이 API가 생성한 JWT 토큰만으로 작업(자동차 운전 또는 블로그 게시물 편집)을 수행할 수 있습니다.
|
||||
|
||||
이러한 개념을 활용하면 JWT는 훨씬 더 복잡한 시나리오에도 사용할 수 있습니다.
|
||||
|
||||
이 경우 여러 엔터티가 동일한 ID를 가질 수 있습니다. 예를 들어 foo라는 ID를 가진 사용자, 자동차, 블로그 게시물이 있을 수 있습니다.
|
||||
|
||||
그래서 ID 충돌을 방지하기 위해, 사용자의 JWT 토큰을 생성할 때 접두사로 `sub` 키를 추가할 수 있습니다. 예를 들어 `username:` 을 붙이는 방식입니다. 이 예제에서는 `sub` 값이 `username:johndoe`이 될 수 있습니다.
|
||||
|
||||
가장 중요한 점은 `sub` 키는 전체 애플리케이션에서 고유한 식별자가 되어야 하며 문자열이어야 한다는 점입니다.
|
||||
|
||||
## 확인해봅시다
|
||||
|
||||
서버를 실행하고 문서로 이동하십시오: <a href="http://127.0.0.1:8000/docs" class="external-link" target="_blank">http://127.0.0.1:8000/docs</a>.
|
||||
|
||||
다음과 같은 사용자 인터페이스를 볼 수 있습니다:
|
||||
|
||||
<img src="/img/tutorial/security/image07.png">
|
||||
|
||||
이전과 같은 방법으로 애플리케이션에 인증하십시오.
|
||||
|
||||
다음 인증 정보를 사용하십시오:
|
||||
|
||||
Username: `johndoe`
|
||||
Password: `secret`
|
||||
|
||||
/// check
|
||||
|
||||
코드 어디에도 평문 패스워드 "`secret`" 이 없다는 점에 유의하십시오. 해시된 버전만 있습니다.
|
||||
|
||||
///
|
||||
|
||||
<img src="/img/tutorial/security/image08.png">
|
||||
|
||||
`/users/me/` 를 호출하면 다음과 같은 응답을 얻을 수 있습니다:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"username": "johndoe",
|
||||
"email": "johndoe@example.com",
|
||||
"full_name": "John Doe",
|
||||
"disabled": false
|
||||
}
|
||||
```
|
||||
|
||||
<img src="/img/tutorial/security/image09.png">
|
||||
|
||||
개발자 도구를 열어보면 전송된 데이터에 토큰만 포함된 것을 확인할 수 있습니다. 패스워드는 사용자를 인증하고 액세스 토큰을 받기 위한 첫 번째 요청에만 전송되며, 이후에는 전송되지 않습니다:
|
||||
|
||||
<img src="/img/tutorial/security/image10.png">
|
||||
|
||||
/// note
|
||||
|
||||
`Bearer `로 시작하는 `Authorization` 헤더에 주목하십시오.
|
||||
|
||||
///
|
||||
|
||||
## `scopes` 의 고급 사용법
|
||||
|
||||
OAuth2는 "스코프(scopes)" 라는 개념을 갖고 있습니다.
|
||||
|
||||
이를 사용하여 JWT 토큰에 특정 권한 집합을 추가할 수 있습니다.
|
||||
|
||||
그 후 이 토큰을 사용자에게 직접 제공하거나 제3자에게 제공하여, 특정 제한사항 하에있는 API와 통신하도록 할 수 있습니다.
|
||||
|
||||
**FastAPI** 에서의 사용 방법과 통합 방식은 **심화 사용자 안내서** 에서 자세히 배울 수 있습니다.
|
||||
|
||||
## 요약
|
||||
|
||||
지금까지 살펴본 내용을 바탕으로, OAuth2와 JWT 같은 표준을 사용하여 안전한 **FastAPI** 애플리케이션을 만들 수 있습니다.
|
||||
|
||||
거의 모든 프레임워크에서 보안 처리는 상당히 복잡한 주제입니다.
|
||||
|
||||
이를 단순화하는 많은 패키지는 데이터 모델, 데이터베이스, 사용 가능한 기능들에 대해 여러 제약이 있습니다. 그리고 지나치게 단순화하는 일부 패키지들은 심각한 보안 결함을 가질 수도 있습니다.
|
||||
|
||||
---
|
||||
|
||||
**FastAPI** 는 어떤 데이터베이스, 데이터 모델, 도구도 강요하지 않습니다.
|
||||
|
||||
프로젝트에 가장 적합한 것을 선택할 수 있는 유연성을 제공합니다.
|
||||
|
||||
그리고 `passlib` 와 `PyJWT` 처럼 잘 관리되고 널리 사용되는 패키지들을 바로 사용할 수 있습니다. **FastAPI** 는 외부 패키지 통합을 위해 복잡한 메커니즘이 필요하지 않기 때문입니다.
|
||||
|
||||
그러나 유연성, 견고성, 보안성을 해치지 않으면서 과정을 단순화할 수 있는 도구들을 제공합니다.
|
||||
|
||||
그리고 OAuth2와 같은 표준 프로토콜을 비교적 간단한 방법으로 구현하고 사용할 수 있습니다.
|
||||
|
||||
더 세분화된 권한 체계를 위해 OAuth2의 "스코프"를 사용하는 방법은 **심화 사용자 안내서**에서 더 자세히 배울 수 있습니다. OAuth2의 스코프는 제3자 애플리케이션이 사용자를 대신해 그들의 API와 상호작용하도록 권한을 부여하기 위해, Facebook, Google, GitHub, Microsoft, Twitter 등의 많은 대형 인증 제공업체들이 사용하는 메커니즘입니다.
|
||||
76
docs/uk/docs/tutorial/cookie-param-models.md
Normal file
76
docs/uk/docs/tutorial/cookie-param-models.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Моделі для Cookie-параметрів
|
||||
|
||||
Якщо у Вас є група **cookies** параметрів, які пов'язані між собою, Ви можете створити **Pydantic-модель**, щоб оголосити їх. 🍪
|
||||
|
||||
Це дозволить Вам повторно **використовувати модель** у **різних місцях**, а також оголосити валідацію та метадані для всіх параметрів одночасно. 😎
|
||||
|
||||
/// note | Нотатки
|
||||
|
||||
Це підтримується з версії FastAPI `0.115.0`. 🤓
|
||||
|
||||
///
|
||||
|
||||
/// tip | Порада
|
||||
|
||||
Ця ж техніка застосовується до `Query`, `Cookie`, та `Header`. 😎
|
||||
|
||||
///
|
||||
|
||||
## Cookie з Pydantic-моделлю
|
||||
|
||||
Оголосіть **cookie-параметри**, які Вам потрібні, у **Pydantic-моделі**, а потім оголосіть параметр як `Cookie`:
|
||||
|
||||
{* ../../docs_src/cookie_param_models/tutorial001_an_py310.py hl[9:12,16] *}
|
||||
|
||||
**FastAPI** буде **витягувати** дані для **кожного поля** з **cookie** параметрів, отриманих у запиті, і передавати Вам Pydantic-модель, яку Ви визначили.
|
||||
|
||||
## Перевірка у документації
|
||||
|
||||
Ви можете побачити визначені cookie в інтерфейсі документації за адресою `/docs`:
|
||||
|
||||
<div class="screenshot">
|
||||
<img src="/img/tutorial/cookie-param-models/image01.png">
|
||||
</div>
|
||||
|
||||
/// info | Інформація
|
||||
|
||||
Майте на увазі, що оскільки **браузери обробляють cookie** особливим чином і "за лаштунками", вони **не** дозволяють **JavaScript** легко з ними працювати.
|
||||
|
||||
Якщо Ви зайдете до **інтерфейсу документації API** за адресою `/docs`, Ви зможете побачити **документацію** для cookie у Ваших **операціях шляху**.
|
||||
|
||||
Але навіть якщо Ви заповните дані й натиснете "Execute", оскільки інтерфейс документації працює з **JavaScript**, cookie не будуть відправлені, і Ви побачите **помилку**, ніби Ви не ввели жодних значень.
|
||||
|
||||
///
|
||||
|
||||
## Заборона додаткових cookie
|
||||
|
||||
У деяких спеціальних випадках (ймовірно, не дуже поширених) Ви можете захотіти **обмежити** список cookie, які хочете отримувати.
|
||||
|
||||
Ваша API тепер має можливість контролювати власну <abbr title="Це жарт, якщо що. Це не має нічого спільного зі згодою на використання cookie, але це кумедно, що навіть API тепер може відхиляти бідні cookie. Ловіть печиво. 🍪">згоду на cookie</abbr>. 🤪🍪
|
||||
|
||||
Ви можете використовувати налаштування моделі Pydantic, щоб `заборонити` будь-які `додаткові` поля:
|
||||
|
||||
{* ../../docs_src/cookie_param_models/tutorial002_an_py39.py hl[10] *}
|
||||
|
||||
Якщо клієнт спробує надіслати якісь **додаткові cookie**, він отримає відповідь з **помилкою**.
|
||||
|
||||
Бідні банери cookie, які так старанно намагаються отримати Вашу згоду, щоб <abbr title="Це ще один жарт. Не звертайте уваги. Візьміть каву для свого печива. ☕">API її відхилила</abbr>. 🍪
|
||||
|
||||
Наприклад, якщо клієнт спробує надіслати cookie `santa_tracker` зі значенням `good-list-please`, він отримає відповідь з помилкою, яка повідомить, що <abbr title="Санта не схвалює відсутність cookie. 🎅 Гаразд, більше жартів не буде.">cookie `santa_tracker` не дозволено</abbr>:
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "extra_forbidden",
|
||||
"loc": ["cookie", "santa_tracker"],
|
||||
"msg": "Extra inputs are not permitted",
|
||||
"input": "good-list-please",
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Підсумок
|
||||
|
||||
Ви можете використовувати **Pydantic-моделі** для оголошення <abbr title="Отримайте останнє печиво перед тим, як піти. 🍪">cookie</abbr> у FastAPI. 😎
|
||||
58
docs/uk/docs/tutorial/header-param-models.md
Normal file
58
docs/uk/docs/tutorial/header-param-models.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# Моделі Параметрів Заголовків
|
||||
|
||||
Якщо у Вас є група пов’язаних параметрів заголовків, Ви можете створити **Pydantic модель** для їх оголошення.
|
||||
|
||||
Це дозволить Вам повторно **використовувати модель** в **різних місцях**, а також оголосити валідації та метадані для всіх параметрів одночасно. 😎
|
||||
|
||||
/// note | Нотатки
|
||||
|
||||
Ця можливість підтримується починаючи з версії FastAPI `0.115.0`. 🤓
|
||||
|
||||
///
|
||||
|
||||
## Параметри Заголовків з Використанням Pydantic Model
|
||||
|
||||
Оголосіть потрібні **параметри заголовків** у **Pydantic моделі**, а потім оголосіть параметр як `Header`:
|
||||
|
||||
{* ../../docs_src/header_param_models/tutorial001_an_py310.py hl[9:14,18] *}
|
||||
|
||||
FastAPI буде витягувати дані для кожного поля з заголовків у запиті та передавати їх у створену Вами Pydantic модель.
|
||||
|
||||
**FastAPI** буде **витягувати** дані для **кожного поля** з **заголовків** у запиті та передавати їх у створену Вами Pydantic модель.
|
||||
|
||||
## Перевірка в Документації
|
||||
|
||||
Ви можете побачити необхідні заголовки в інтерфейсі документації за адресою `/docs`:
|
||||
|
||||
<div class="screenshot">
|
||||
<img src="/img/tutorial/header-param-models/image01.png">
|
||||
</div>
|
||||
|
||||
## Заборона Додаткових Заголовків
|
||||
|
||||
У деяких особливих випадках (ймовірно, не дуже поширених) Ви можете захотіти **обмежити** заголовки, які хочете отримати.
|
||||
|
||||
Ви можете використати конфігурацію моделі Pydantic, щоб `заборонити` будь-які `додаткові` поля:
|
||||
|
||||
{* ../../docs_src/header_param_models/tutorial002_an_py310.py hl[10] *}
|
||||
|
||||
Якщо клієнт спробує надіслати **додаткові заголовки**, він отримає **помилку** у відповіді.
|
||||
|
||||
Наприклад, якщо клієнт спробує надіслати заголовок `tool` зі значенням `plumbus`, він отримає **помилку** з повідомленням про те, що параметр заголовка `tool` не дозволений:
|
||||
|
||||
```json
|
||||
{
|
||||
"detail": [
|
||||
{
|
||||
"type": "extra_forbidden",
|
||||
"loc": ["header", "tool"],
|
||||
"msg": "Extra inputs are not permitted",
|
||||
"input": "plumbus",
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Підсумок
|
||||
|
||||
Ви можете використовувати **Pydantic моделі** для оголошення **заголовків** у **FastAPI**. 😎
|
||||
120
docs/uk/docs/tutorial/metadata.md
Normal file
120
docs/uk/docs/tutorial/metadata.md
Normal file
@@ -0,0 +1,120 @@
|
||||
# Метадані та URL-адреси документації
|
||||
|
||||
Ви можете налаштувати кілька конфігурацій метаданих у Вашому додатку **FastAPI**.
|
||||
|
||||
## Метадані для API
|
||||
|
||||
Ви можете встановити такі поля, які використовуються в специфікації OpenAPI та в автоматично згенерованих інтерфейсах документації API:
|
||||
|
||||
| Параметр | Тип | Опис |
|
||||
|------------|------|-------------|
|
||||
| `title` | `str` | Назва API. |
|
||||
| `summary` | `str` | Короткий опис API. <small>Доступно з OpenAPI 3.1.0, FastAPI 0.99.0.</small> |
|
||||
| `description` | `str` | Більш детальний опис API. Може використовувати Markdown. |
|
||||
| `version` | `string` | Версія API. Це версія Вашого додатка, а не OpenAPI. Наприклад, `2.5.0`. |
|
||||
| `terms_of_service` | `str` | URL до умов використання API. Якщо вказано, має бути у форматі URL. |
|
||||
| `contact` | `dict` | Інформація для контакту з API. Може містити кілька полів. <details><summary><code>contact</code> поля</summary><table><thead><tr><th>Параметр</th><th>Тип</th><th>Опис</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>str</code></td><td>Ім'я контактної особи або організації.</td></tr><tr><td><code>url</code></td><td><code>str</code></td><td>URL з інформацією для контакту. Повинен бути у форматі URL.</td></tr><tr><td><code>email</code></td><td><code>str</code></td><td>Email контактної особи або організації. Повинен бути у форматі електронної пошти.</td></tr></tbody></table></details> |
|
||||
| `license_info` | `dict` | Інформація про ліцензію для API. Може містити кілька полів. <details><summary><code>license_info</code> поля</summary><table><thead><tr><th>Параметр</th><th>Тип</th><th>Опис</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>str</code></td><td><strong>ОБОВ'ЯЗКОВО</strong> (якщо встановлено <code>license_info</code>). Назва ліцензії для API.</td></tr><tr><td><code>identifier</code></td><td><code>str</code></td><td>Ліцензійний вираз за <a href="https://spdx.org/licenses/" class="external-link" target="_blank">SPDX</a> для API. Поле <code>identifier</code> взаємовиключне з полем <code>url</code>. <small>Доступно з OpenAPI 3.1.0, FastAPI 0.99.0.</small></td></tr><tr><td><code>url</code></td><td><code>str</code></td><td>URL до ліцензії, яка використовується для API. Повинен бути у форматі URL.</td></tr></tbody></table></details> |
|
||||
|
||||
Ви можете налаштувати їх наступним чином:
|
||||
|
||||
{* ../../docs_src/metadata/tutorial001.py hl[3:16, 19:32] *}
|
||||
|
||||
/// tip | Підказка
|
||||
|
||||
У полі `description` можна використовувати Markdown, і він буде відображатися у результаті.
|
||||
|
||||
///
|
||||
|
||||
З цією конфігурацією автоматична документація API виглядатиме так:
|
||||
|
||||
<img src="/img/tutorial/metadata/image01.png">
|
||||
|
||||
## Ідентифікатор ліцензії
|
||||
|
||||
З початку використання OpenAPI 3.1.0 та FastAPI 0.99.0 Ви також можете налаштувати `license_info` за допомогою `identifier` замість `url`.
|
||||
|
||||
Наприклад:
|
||||
|
||||
{* ../../docs_src/metadata/tutorial001_1.py hl[31] *}
|
||||
|
||||
## Метадані для тегів
|
||||
|
||||
Ви також можете додати додаткові метадані для різних тегів, які використовуються для групування операцій шляхів, за допомогою параметра `openapi_tags`.
|
||||
|
||||
Він приймає список, який містить один словник для кожного тега.
|
||||
|
||||
Кожен словник може містити:
|
||||
|
||||
* `name` (**обов'язково**): `str` з тією ж назвою тегу, яку Ви використовуєте у параметрі `tags` у Ваших *операціях шляху* та `APIRouter`s.
|
||||
* `description`: `str` з коротким описом тегу. Може містити Markdown і буде відображено в інтерфейсі документації.
|
||||
* `externalDocs`: `dict` який описує зовнішню документацію з такими полями:
|
||||
* `description`: `str` з коротким описом зовнішньої документації.
|
||||
* `url` (**обов'язково**): `str`з URL-адресою зовнішньої документації.
|
||||
|
||||
### Створення метаданих для тегів
|
||||
|
||||
Спробуймо це на прикладі з тегами для `users` та `items`.
|
||||
|
||||
Створіть метадані для своїх тегів і передайте їх у параметр `openapi_tags`:
|
||||
|
||||
{* ../../docs_src/metadata/tutorial004.py hl[3:16,18] *}
|
||||
|
||||
Зверніть увагу, що в описах можна використовувати Markdown, наприклад, "login" буде показано жирним шрифтом (**login**), а "fancy" буде показано курсивом (_fancy_).
|
||||
|
||||
/// tip | Порада
|
||||
|
||||
Не обов'язково додавати метадані для всіх тегів, які Ви використовуєте.
|
||||
|
||||
///
|
||||
|
||||
### Використання тегів
|
||||
|
||||
Використовуйте параметр `tags` зі своїми *операціями шляху* (і `APIRouter`) для призначення їх до різних тегів:
|
||||
|
||||
{* ../../docs_src/metadata/tutorial004.py hl[21,26] *}
|
||||
|
||||
/// info | Інформація
|
||||
|
||||
Детальніше про теги читайте в розділі [Конфігурація шляхів операцій](path-operation-configuration.md#tags){.internal-link target=_blank}.
|
||||
|
||||
///
|
||||
|
||||
### Перевірка документації
|
||||
|
||||
Якщо Ви зараз перевірите документацію, вона покаже всі додаткові метадані:
|
||||
|
||||
<img src="/img/tutorial/metadata/image02.png">
|
||||
|
||||
### Порядок тегів
|
||||
|
||||
Порядок кожного словника метаданих тегу також визначає порядок відображення в інтерфейсі документації.
|
||||
|
||||
Наприклад, хоча `users` мав би йти після `items` в алфавітному порядку, він відображається перед ними, оскільки ми додали його метадані як перший словник у списку.
|
||||
|
||||
## URL для OpenAPI
|
||||
|
||||
За замовчуванням схема OpenAPI надається за адресою `/openapi.json`.
|
||||
|
||||
Але Ви можете налаштувати це за допомогою параметра `openapi_url`.
|
||||
|
||||
Наприклад, щоб налаштувати його на `/api/v1/openapi.json`:
|
||||
|
||||
{* ../../docs_src/metadata/tutorial002.py hl[3] *}
|
||||
|
||||
Якщо Ви хочете повністю вимкнути схему OpenAPI, Ви можете встановити `openapi_url=None`, це також вимкне інтерфейси документації, які її використовують.
|
||||
|
||||
## URL-адреси документації
|
||||
|
||||
Ви можете налаштувати два інтерфейси користувача для документації, які включені:
|
||||
|
||||
* **Swagger UI**: доступний за адресою `/docs`.
|
||||
* Ви можете змінити його URL за допомогою параметра `docs_url`.
|
||||
* Ви можете вимкнути його, встановивши `docs_url=None`.
|
||||
* **ReDoc**: доступний за адресою `/redoc`.
|
||||
* Ви можете змінити його URL за допомогою параметра `redoc_url`.
|
||||
* Ви можете вимкнути його, встановивши `redoc_url=None`.
|
||||
|
||||
Наприклад, щоб налаштувати Swagger UI на `/documentation` і вимкнути ReDoc:
|
||||
|
||||
{* ../../docs_src/metadata/tutorial003.py hl[3] *}
|
||||
100
docs/uk/docs/tutorial/response-status-code.md
Normal file
100
docs/uk/docs/tutorial/response-status-code.md
Normal file
@@ -0,0 +1,100 @@
|
||||
# Статус коди Відповідей
|
||||
|
||||
Так само як Ви можете вказати модель відповіді, Ви також можете оголосити HTTP код статусу для відповіді за допомогою параметра `status_code` в будь-якій з *операцій шляху*:
|
||||
|
||||
* `@app.get()`
|
||||
* `@app.post()`
|
||||
* `@app.put()`
|
||||
* `@app.delete()`
|
||||
* тощо.
|
||||
|
||||
{* ../../docs_src/response_status_code/tutorial001.py hl[6] *}
|
||||
|
||||
/// note | Нотатка
|
||||
|
||||
Зверніть увагу, що `status_code` є параметром методу "декоратора" (`get`, `post` і т.д.), а не Вашої *функції операції шляху*, як усі інші параметри та тіло запиту.
|
||||
|
||||
///
|
||||
|
||||
Параметр `status_code` приймає число, яке відповідає HTTP коду статусу.
|
||||
|
||||
/// info | Інформація
|
||||
`status_code` також може отримувати значення з `IntEnum`, наприклад, з Python <a href="https://docs.python.org/3/library/http.html#http.HTTPStatus" class="external-link" target="_blank">`http.HTTPStatus`</a>.
|
||||
|
||||
///
|
||||
|
||||
Він буде:
|
||||
|
||||
* Повертати вказаний код статусу у відповіді.
|
||||
* Документувати його як такий у схемі OpenAPI (і, таким чином, в інтерфейсі користувача):
|
||||
|
||||
<img src="/img/tutorial/response-status-code/image01.png">
|
||||
|
||||
/// note | Нотатка
|
||||
|
||||
Деякі коди відповіді (див. наступний розділ) вказують, що відповідь не має тіла.
|
||||
|
||||
FastAPI знає про це і створить OpenAPI документацію, яка вказує, що тіла відповіді немає.
|
||||
|
||||
///
|
||||
|
||||
## Про HTTP статус коди
|
||||
|
||||
/// note | Нотатка
|
||||
|
||||
Якщо Ви вже знаєте, що таке HTTP коди статусу, переходьте до наступного розділу.
|
||||
|
||||
///
|
||||
|
||||
В HTTP Ви надсилаєте числовий код статусу з 3 цифр як частину відповіді.
|
||||
|
||||
Ці коди статусу мають пов’язану назву для їх розпізнавання, але найважливішою частиною є саме число.
|
||||
|
||||
Коротко:
|
||||
|
||||
* **`100 - 199`** "Інформаційні" відповіді. Ви рідко використовуєте їх напряму. Відповіді з такими кодами не можуть мати тіла.
|
||||
* **`200 - 299`** "Успішні" відповіді. Це ті, які Ви використовуватимете найчастіше.
|
||||
* `200` - код за замовчуванням, який означає, що все пройшло "OK".
|
||||
* Інший приклад – `201`, "Created" (створено). Його зазвичай використовують після створення нового запису в базі даних.
|
||||
* Особливий випадок – `204`, "No Content" (немає вмісту). Ця відповідь використовується, коли немає даних для повернення клієнту, тому відповідь не повинна мати тіла.
|
||||
* **`300 - 399`** "Перенаправлення". Відповіді з цими кодами можуть мати або не мати тіла, за винятком `304`, "Not Modified" (не змінено), яка не повинна мати тіла.
|
||||
* **`400 - 499`** "Помилка клієнта". Це другий тип, який Ви, ймовірно, будете використовувати найчастіше.
|
||||
* Приклад `404`, "Not Found" (не знайдено).
|
||||
* Для загальних помилок клієнта можна використовувати `400`.
|
||||
* `500 - 599` "Помилки сервера". Ви майже ніколи не використовуєте їх напряму. Якщо в коді Вашого застосунку або на сервері щось пішло не так, автоматично буде повернено один із цих кодів статусу.
|
||||
|
||||
/// tip | Порада
|
||||
|
||||
Щоб дізнатися більше про кожен код статусу і призначення кожного з них, перегляньте документацію <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status" class="external-link" target="_blank"><abbr title="Mozilla Developer Network">MDN</abbr> про HTTP коди статусу</a>.
|
||||
|
||||
///
|
||||
|
||||
## Легкий спосіб запам'ятати назви
|
||||
|
||||
Розглянемо ще раз попередній приклад:
|
||||
|
||||
{* ../../docs_src/response_status_code/tutorial001.py hl[6] *}
|
||||
|
||||
`201` - це код статусу для "Created" (створено).
|
||||
|
||||
Але Вам не потрібно запам'ятовувати, що означає кожен із цих кодів.
|
||||
|
||||
Ви можете використовувати зручні змінні з `fastapi.status`
|
||||
|
||||
{* ../../docs_src/response_status_code/tutorial002.py hl[1,6] *}
|
||||
|
||||
Ці змінні просто для зручності. Вони містять ті ж самі числа, але Ви можете скористатися автозаповненням в редакторі:
|
||||
|
||||
<img src="/img/tutorial/response-status-code/image02.png">
|
||||
|
||||
/// note | Технічні деталі
|
||||
|
||||
Ви також можете використати `from starlette import status`.
|
||||
|
||||
**FastAPI** надає ті ж самі змінні `starlette.status` як `fastapi.status`, просто для зручності розробника. Однак вони походять безпосередньо зі Starlette.
|
||||
|
||||
///
|
||||
|
||||
## Зміна значення за замовчуванням
|
||||
|
||||
Далі, у Посібнику для досвідчених користувачів{.internal-link target=_blank}, Ви дізнаєтесь, як повернути інший код статусу, ніж той, який Ви оголосили тут.
|
||||
17
docs/vi/docs/deployment/cloud.md
Normal file
17
docs/vi/docs/deployment/cloud.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Triển khai FastAPI trên các Dịch vụ Cloud
|
||||
|
||||
Bạn có thể sử dụng **bất kỳ nhà cung cấp dịch vụ cloud** nào để triển khai ứng dụng FastAPI của mình.
|
||||
|
||||
Trong hầu hết các trường hợp, các nhà cung cấp dịch vụ cloud lớn đều có hướng dẫn triển khai FastAPI với họ.
|
||||
|
||||
## Nhà cung cấp dịch vụ Cloud - Nhà tài trợ
|
||||
Một vài nhà cung cấp dịch vụ cloud ✨ [**tài trợ cho FastAPI**](../help-fastapi.md#sponsor-the-author){.internal-link target=_blank} ✨, điều này giúp đảm bảo sự phát triển liên tục và khỏe mạnh của FastAPI và hệ sinh thái của nó.
|
||||
|
||||
Thêm nữa, điều này cũng thể hiện cam kết thực sự của họ đối với FastAPI và **cộng đồng người dùng** (bạn), vì họ không chỉ muốn cung cấp cho bạn một **dịch vụ tốt** mà còn muốn đảm bảo rằng bạn có một **framework tốt và bền vững**, đó chính là FastAPI. 🙇
|
||||
|
||||
Bạn có thể thử các dịch vụ của họ và làm theo hướng dẫn của họ:
|
||||
|
||||
* <a href="https://docs.platform.sh/languages/python.html?utm_source=fastapi-signup&utm_medium=banner&utm_campaign=FastAPI-signup-June-2023" class="external-link" target="_blank">Platform.sh</a>
|
||||
* <a href="https://docs.porter.run/language-specific-guides/fastapi" class="external-link" target="_blank">Porter</a>
|
||||
* <a href="https://www.withcoherence.com/?utm_medium=advertising&utm_source=fastapi&utm_campaign=website" class="external-link" target="_blank">Coherence</a>
|
||||
* <a href="https://docs.render.com/deploy-fastapi?utm_source=deploydoc&utm_medium=referral&utm_campaign=fastapi" class="external-link" target="_blank">Render</a>
|
||||
19
docs_src/header_param_models/tutorial003.py
Normal file
19
docs_src/header_param_models/tutorial003.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import List, Union
|
||||
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: Union[str, None] = None
|
||||
traceparent: Union[str, None] = None
|
||||
x_tag: List[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(headers: CommonHeaders = Header(convert_underscores=False)):
|
||||
return headers
|
||||
22
docs_src/header_param_models/tutorial003_an.py
Normal file
22
docs_src/header_param_models/tutorial003_an.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from typing import List, Union
|
||||
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
from typing_extensions import Annotated
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: Union[str, None] = None
|
||||
traceparent: Union[str, None] = None
|
||||
x_tag: List[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(
|
||||
headers: Annotated[CommonHeaders, Header(convert_underscores=False)],
|
||||
):
|
||||
return headers
|
||||
21
docs_src/header_param_models/tutorial003_an_py310.py
Normal file
21
docs_src/header_param_models/tutorial003_an_py310.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: str | None = None
|
||||
traceparent: str | None = None
|
||||
x_tag: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(
|
||||
headers: Annotated[CommonHeaders, Header(convert_underscores=False)],
|
||||
):
|
||||
return headers
|
||||
21
docs_src/header_param_models/tutorial003_an_py39.py
Normal file
21
docs_src/header_param_models/tutorial003_an_py39.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from typing import Annotated, Union
|
||||
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: Union[str, None] = None
|
||||
traceparent: Union[str, None] = None
|
||||
x_tag: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(
|
||||
headers: Annotated[CommonHeaders, Header(convert_underscores=False)],
|
||||
):
|
||||
return headers
|
||||
17
docs_src/header_param_models/tutorial003_py310.py
Normal file
17
docs_src/header_param_models/tutorial003_py310.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: str | None = None
|
||||
traceparent: str | None = None
|
||||
x_tag: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(headers: CommonHeaders = Header(convert_underscores=False)):
|
||||
return headers
|
||||
19
docs_src/header_param_models/tutorial003_py39.py
Normal file
19
docs_src/header_param_models/tutorial003_py39.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from typing import Union
|
||||
|
||||
from fastapi import FastAPI, Header
|
||||
from pydantic import BaseModel
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class CommonHeaders(BaseModel):
|
||||
host: str
|
||||
save_data: bool
|
||||
if_modified_since: Union[str, None] = None
|
||||
traceparent: Union[str, None] = None
|
||||
x_tag: list[str] = []
|
||||
|
||||
|
||||
@app.get("/items/")
|
||||
async def read_items(headers: CommonHeaders = Header(convert_underscores=False)):
|
||||
return headers
|
||||
@@ -1,6 +1,6 @@
|
||||
"""FastAPI framework, high performance, easy to learn, fast to code, ready for production"""
|
||||
|
||||
__version__ = "0.115.11"
|
||||
__version__ = "0.115.12"
|
||||
|
||||
from starlette import status as status
|
||||
|
||||
|
||||
@@ -133,9 +133,9 @@ def get_param_sub_dependant(
|
||||
|
||||
|
||||
def get_parameterless_sub_dependant(*, depends: params.Depends, path: str) -> Dependant:
|
||||
assert callable(
|
||||
depends.dependency
|
||||
), "A parameter-less dependency must have a callable dependency"
|
||||
assert callable(depends.dependency), (
|
||||
"A parameter-less dependency must have a callable dependency"
|
||||
)
|
||||
return get_sub_dependant(depends=depends, dependency=depends.dependency, path=path)
|
||||
|
||||
|
||||
@@ -302,9 +302,9 @@ def get_dependant(
|
||||
type_annotation=param_details.type_annotation,
|
||||
dependant=dependant,
|
||||
):
|
||||
assert (
|
||||
param_details.field is None
|
||||
), f"Cannot specify multiple FastAPI annotations for {param_name!r}"
|
||||
assert param_details.field is None, (
|
||||
f"Cannot specify multiple FastAPI annotations for {param_name!r}"
|
||||
)
|
||||
continue
|
||||
assert param_details.field is not None
|
||||
if isinstance(param_details.field.field_info, params.Body):
|
||||
@@ -439,9 +439,9 @@ def analyze_param(
|
||||
),
|
||||
):
|
||||
assert depends is None, f"Cannot specify `Depends` for type {type_annotation!r}"
|
||||
assert (
|
||||
field_info is None
|
||||
), f"Cannot specify FastAPI annotation for type {type_annotation!r}"
|
||||
assert field_info is None, (
|
||||
f"Cannot specify FastAPI annotation for type {type_annotation!r}"
|
||||
)
|
||||
# Handle default assignations, neither field_info nor depends was not found in Annotated nor default value
|
||||
elif field_info is None and depends is None:
|
||||
default_value = value if value is not inspect.Signature.empty else RequiredParam
|
||||
@@ -494,9 +494,9 @@ def analyze_param(
|
||||
field_info=field_info,
|
||||
)
|
||||
if is_path_param:
|
||||
assert is_scalar_field(
|
||||
field=field
|
||||
), "Path params must be of one of the supported types"
|
||||
assert is_scalar_field(field=field), (
|
||||
"Path params must be of one of the supported types"
|
||||
)
|
||||
elif isinstance(field_info, params.Query):
|
||||
assert (
|
||||
is_scalar_field(field)
|
||||
@@ -521,9 +521,9 @@ def add_param_to_fields(*, field: ModelField, dependant: Dependant) -> None:
|
||||
elif field_info_in == params.ParamTypes.header:
|
||||
dependant.header_params.append(field)
|
||||
else:
|
||||
assert (
|
||||
field_info_in == params.ParamTypes.cookie
|
||||
), f"non-body parameters must be in path, query, header or cookie: {field.name}"
|
||||
assert field_info_in == params.ParamTypes.cookie, (
|
||||
f"non-body parameters must be in path, query, header or cookie: {field.name}"
|
||||
)
|
||||
dependant.cookie_params.append(field)
|
||||
|
||||
|
||||
@@ -750,9 +750,15 @@ def request_params_to_args(
|
||||
first_field = fields[0]
|
||||
fields_to_extract = fields
|
||||
single_not_embedded_field = False
|
||||
default_convert_underscores = True
|
||||
if len(fields) == 1 and lenient_issubclass(first_field.type_, BaseModel):
|
||||
fields_to_extract = get_cached_model_fields(first_field.type_)
|
||||
single_not_embedded_field = True
|
||||
# If headers are in a Pydantic model, the way to disable convert_underscores
|
||||
# would be with Header(convert_underscores=False) at the Pydantic model level
|
||||
default_convert_underscores = getattr(
|
||||
first_field.field_info, "convert_underscores", True
|
||||
)
|
||||
|
||||
params_to_process: Dict[str, Any] = {}
|
||||
|
||||
@@ -763,7 +769,9 @@ def request_params_to_args(
|
||||
if isinstance(received_params, Headers):
|
||||
# Handle fields extracted from a Pydantic Model for a header, each field
|
||||
# doesn't have a FieldInfo of type Header with the default convert_underscores=True
|
||||
convert_underscores = getattr(field.field_info, "convert_underscores", True)
|
||||
convert_underscores = getattr(
|
||||
field.field_info, "convert_underscores", default_convert_underscores
|
||||
)
|
||||
if convert_underscores:
|
||||
alias = (
|
||||
field.alias
|
||||
@@ -782,9 +790,9 @@ def request_params_to_args(
|
||||
|
||||
if single_not_embedded_field:
|
||||
field_info = first_field.field_info
|
||||
assert isinstance(
|
||||
field_info, params.Param
|
||||
), "Params must be subclasses of Param"
|
||||
assert isinstance(field_info, params.Param), (
|
||||
"Params must be subclasses of Param"
|
||||
)
|
||||
loc: Tuple[str, ...] = (field_info.in_.value,)
|
||||
v_, errors_ = _validate_value_with_model_field(
|
||||
field=first_field, value=params_to_process, values=values, loc=loc
|
||||
@@ -794,9 +802,9 @@ def request_params_to_args(
|
||||
for field in fields:
|
||||
value = _get_multidict_value(field, received_params)
|
||||
field_info = field.field_info
|
||||
assert isinstance(
|
||||
field_info, params.Param
|
||||
), "Params must be subclasses of Param"
|
||||
assert isinstance(field_info, params.Param), (
|
||||
"Params must be subclasses of Param"
|
||||
)
|
||||
loc = (field_info.in_.value, field.alias)
|
||||
v_, errors_ = _validate_value_with_model_field(
|
||||
field=field, value=value, values=values, loc=loc
|
||||
|
||||
@@ -32,6 +32,7 @@ from fastapi.utils import (
|
||||
generate_operation_id_for_path,
|
||||
is_body_allowed_for_status_code,
|
||||
)
|
||||
from pydantic import BaseModel
|
||||
from starlette.responses import JSONResponse
|
||||
from starlette.routing import BaseRoute
|
||||
from starlette.status import HTTP_422_UNPROCESSABLE_ENTITY
|
||||
@@ -113,6 +114,13 @@ def _get_openapi_operation_parameters(
|
||||
(ParamTypes.header, header_params),
|
||||
(ParamTypes.cookie, cookie_params),
|
||||
]
|
||||
default_convert_underscores = True
|
||||
if len(flat_dependant.header_params) == 1:
|
||||
first_field = flat_dependant.header_params[0]
|
||||
if lenient_issubclass(first_field.type_, BaseModel):
|
||||
default_convert_underscores = getattr(
|
||||
first_field.field_info, "convert_underscores", True
|
||||
)
|
||||
for param_type, param_group in parameter_groups:
|
||||
for param in param_group:
|
||||
field_info = param.field_info
|
||||
@@ -126,8 +134,21 @@ def _get_openapi_operation_parameters(
|
||||
field_mapping=field_mapping,
|
||||
separate_input_output_schemas=separate_input_output_schemas,
|
||||
)
|
||||
name = param.alias
|
||||
convert_underscores = getattr(
|
||||
param.field_info,
|
||||
"convert_underscores",
|
||||
default_convert_underscores,
|
||||
)
|
||||
if (
|
||||
param_type == ParamTypes.header
|
||||
and param.alias == param.name
|
||||
and convert_underscores
|
||||
):
|
||||
name = param.name.replace("_", "-")
|
||||
|
||||
parameter = {
|
||||
"name": param.alias,
|
||||
"name": name,
|
||||
"in": param_type.value,
|
||||
"required": param.required,
|
||||
"schema": param_schema,
|
||||
@@ -364,9 +385,9 @@ def get_openapi_path(
|
||||
openapi_response = operation_responses.setdefault(
|
||||
status_code_key, {}
|
||||
)
|
||||
assert isinstance(
|
||||
process_response, dict
|
||||
), "An additional response must be a dict"
|
||||
assert isinstance(process_response, dict), (
|
||||
"An additional response must be a dict"
|
||||
)
|
||||
field = route.response_fields.get(additional_status_code)
|
||||
additional_field_schema: Optional[Dict[str, Any]] = None
|
||||
if field:
|
||||
@@ -434,9 +455,9 @@ def get_fields_from_routes(
|
||||
route, routing.APIRoute
|
||||
):
|
||||
if route.body_field:
|
||||
assert isinstance(
|
||||
route.body_field, ModelField
|
||||
), "A request body must be a Pydantic Field"
|
||||
assert isinstance(route.body_field, ModelField), (
|
||||
"A request body must be a Pydantic Field"
|
||||
)
|
||||
body_fields_from_routes.append(route.body_field)
|
||||
if route.response_field:
|
||||
responses_from_routes.append(route.response_field)
|
||||
|
||||
@@ -504,9 +504,9 @@ class APIRoute(routing.Route):
|
||||
status_code = int(status_code)
|
||||
self.status_code = status_code
|
||||
if self.response_model:
|
||||
assert is_body_allowed_for_status_code(
|
||||
status_code
|
||||
), f"Status code {status_code} must not have a response body"
|
||||
assert is_body_allowed_for_status_code(status_code), (
|
||||
f"Status code {status_code} must not have a response body"
|
||||
)
|
||||
response_name = "Response_" + self.unique_id
|
||||
self.response_field = create_model_field(
|
||||
name=response_name,
|
||||
@@ -537,9 +537,9 @@ class APIRoute(routing.Route):
|
||||
assert isinstance(response, dict), "An additional response must be a dict"
|
||||
model = response.get("model")
|
||||
if model:
|
||||
assert is_body_allowed_for_status_code(
|
||||
additional_status_code
|
||||
), f"Status code {additional_status_code} must not have a response body"
|
||||
assert is_body_allowed_for_status_code(additional_status_code), (
|
||||
f"Status code {additional_status_code} must not have a response body"
|
||||
)
|
||||
response_name = f"Response_{additional_status_code}_{self.unique_id}"
|
||||
response_field = create_model_field(
|
||||
name=response_name, type_=model, mode="serialization"
|
||||
@@ -844,9 +844,9 @@ class APIRouter(routing.Router):
|
||||
)
|
||||
if prefix:
|
||||
assert prefix.startswith("/"), "A path prefix must start with '/'"
|
||||
assert not prefix.endswith(
|
||||
"/"
|
||||
), "A path prefix must not end with '/', as the routes will start with '/'"
|
||||
assert not prefix.endswith("/"), (
|
||||
"A path prefix must not end with '/', as the routes will start with '/'"
|
||||
)
|
||||
self.prefix = prefix
|
||||
self.tags: List[Union[str, Enum]] = tags or []
|
||||
self.dependencies = list(dependencies or [])
|
||||
@@ -1256,9 +1256,9 @@ class APIRouter(routing.Router):
|
||||
"""
|
||||
if prefix:
|
||||
assert prefix.startswith("/"), "A path prefix must start with '/'"
|
||||
assert not prefix.endswith(
|
||||
"/"
|
||||
), "A path prefix must not end with '/', as the routes will start with '/'"
|
||||
assert not prefix.endswith("/"), (
|
||||
"A path prefix must not end with '/', as the routes will start with '/'"
|
||||
)
|
||||
else:
|
||||
for r in router.routes:
|
||||
path = getattr(r, "path") # noqa: B009
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# For mkdocstrings and tests
|
||||
httpx >=0.23.0,<0.28.0
|
||||
# For linting and generating docs versions
|
||||
ruff ==0.6.4
|
||||
ruff ==0.9.4
|
||||
|
||||
@@ -14,6 +14,6 @@ cairosvg==2.7.1
|
||||
mkdocstrings[python]==0.26.1
|
||||
griffe-typingdoc==0.2.7
|
||||
# For griffe, it formats with black
|
||||
black==24.10.0
|
||||
black==25.1.0
|
||||
mkdocs-macros-plugin==1.3.7
|
||||
markdown-include-variants==0.0.4
|
||||
|
||||
@@ -4,7 +4,7 @@ pytest >=7.1.3,<9.0.0
|
||||
coverage[toml] >= 6.5.0,< 8.0
|
||||
mypy ==1.8.0
|
||||
dirty-equals ==0.8.0
|
||||
sqlmodel==0.0.22
|
||||
sqlmodel==0.0.23
|
||||
flask >=1.1.2,<4.0.0
|
||||
anyio[trio] >=3.2.1,<5.0.0
|
||||
PyJWT==2.8.0
|
||||
|
||||
@@ -1 +1 @@
|
||||
pydantic-ai==0.0.15
|
||||
pydantic-ai==0.0.30
|
||||
|
||||
@@ -38,9 +38,9 @@ def get_langs() -> dict[str, str]:
|
||||
|
||||
def generate_lang_path(*, lang: str, path: Path) -> Path:
|
||||
en_docs_path = Path("docs/en/docs")
|
||||
assert str(path).startswith(
|
||||
str(en_docs_path)
|
||||
), f"Path must be inside {en_docs_path}"
|
||||
assert str(path).startswith(str(en_docs_path)), (
|
||||
f"Path must be inside {en_docs_path}"
|
||||
)
|
||||
lang_docs_path = Path(f"docs/{lang}/docs")
|
||||
out_path = Path(str(path).replace(str(en_docs_path), str(lang_docs_path)))
|
||||
return out_path
|
||||
@@ -56,9 +56,9 @@ def translate_page(*, lang: str, path: Path) -> None:
|
||||
lang_prompt_content = lang_prompt_path.read_text()
|
||||
|
||||
en_docs_path = Path("docs/en/docs")
|
||||
assert str(path).startswith(
|
||||
str(en_docs_path)
|
||||
), f"Path must be inside {en_docs_path}"
|
||||
assert str(path).startswith(str(en_docs_path)), (
|
||||
f"Path must be inside {en_docs_path}"
|
||||
)
|
||||
out_path = generate_lang_path(lang=lang, path=path)
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
original_content = path.read_text()
|
||||
|
||||
@@ -48,7 +48,7 @@ expected_schema = {
|
||||
"type": "array",
|
||||
},
|
||||
"msg": {"title": "Message", "type": "string"},
|
||||
"type": {"title": "Error " "Type", "type": "string"},
|
||||
"type": {"title": "Error Type", "type": "string"},
|
||||
},
|
||||
"required": ["loc", "msg", "type"],
|
||||
"title": "ValidationError",
|
||||
@@ -73,7 +73,7 @@ expected_schema = {
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
"description": "Successful " "Response",
|
||||
"description": "Successful Response",
|
||||
},
|
||||
"422": {
|
||||
"content": {
|
||||
@@ -83,7 +83,7 @@ expected_schema = {
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Validation " "Error",
|
||||
"description": "Validation Error",
|
||||
},
|
||||
},
|
||||
"summary": "Foo Handler",
|
||||
|
||||
@@ -55,7 +55,7 @@ def test_openapi_schema():
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
"description": "Successful " "Response",
|
||||
"description": "Successful Response",
|
||||
}
|
||||
},
|
||||
"summary": "A",
|
||||
@@ -67,7 +67,7 @@ def test_openapi_schema():
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
"description": "Successful " "Response",
|
||||
"description": "Successful Response",
|
||||
}
|
||||
},
|
||||
"summary": "B",
|
||||
|
||||
@@ -41,7 +41,7 @@ schema = {
|
||||
"type": "array",
|
||||
},
|
||||
"msg": {"title": "Message", "type": "string"},
|
||||
"type": {"title": "Error " "Type", "type": "string"},
|
||||
"type": {"title": "Error Type", "type": "string"},
|
||||
},
|
||||
"required": ["loc", "msg", "type"],
|
||||
"title": "ValidationError",
|
||||
@@ -66,7 +66,7 @@ schema = {
|
||||
"responses": {
|
||||
"200": {
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
"description": "Successful " "Response",
|
||||
"description": "Successful Response",
|
||||
},
|
||||
"422": {
|
||||
"content": {
|
||||
@@ -76,7 +76,7 @@ schema = {
|
||||
}
|
||||
}
|
||||
},
|
||||
"description": "Validation " "Error",
|
||||
"description": "Validation Error",
|
||||
},
|
||||
},
|
||||
"summary": "Get Deps",
|
||||
|
||||
@@ -8,31 +8,31 @@ client = TestClient(app)
|
||||
def test_swagger_ui():
|
||||
response = client.get("/docs")
|
||||
assert response.status_code == 200, response.text
|
||||
assert (
|
||||
'"syntaxHighlight": false' in response.text
|
||||
), "syntaxHighlight should be included and converted to JSON"
|
||||
assert (
|
||||
'"dom_id": "#swagger-ui"' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert '"syntaxHighlight": false' in response.text, (
|
||||
"syntaxHighlight should be included and converted to JSON"
|
||||
)
|
||||
assert '"dom_id": "#swagger-ui"' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "presets: [" in response.text, "default configs should be preserved"
|
||||
assert (
|
||||
"SwaggerUIBundle.presets.apis," in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
"SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"layout": "BaseLayout",' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"deepLinking": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"showExtensions": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"showCommonExtensions": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert "SwaggerUIBundle.presets.apis," in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"layout": "BaseLayout",' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"deepLinking": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"showExtensions": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"showCommonExtensions": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
|
||||
|
||||
def test_get_users():
|
||||
|
||||
@@ -8,34 +8,34 @@ client = TestClient(app)
|
||||
def test_swagger_ui():
|
||||
response = client.get("/docs")
|
||||
assert response.status_code == 200, response.text
|
||||
assert (
|
||||
'"syntaxHighlight": false' not in response.text
|
||||
), "not used parameters should not be included"
|
||||
assert (
|
||||
'"syntaxHighlight": {"theme": "obsidian"}' in response.text
|
||||
), "parameters with middle dots should be included in a JSON compatible way"
|
||||
assert (
|
||||
'"dom_id": "#swagger-ui"' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert '"syntaxHighlight": false' not in response.text, (
|
||||
"not used parameters should not be included"
|
||||
)
|
||||
assert '"syntaxHighlight": {"theme": "obsidian"}' in response.text, (
|
||||
"parameters with middle dots should be included in a JSON compatible way"
|
||||
)
|
||||
assert '"dom_id": "#swagger-ui"' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "presets: [" in response.text, "default configs should be preserved"
|
||||
assert (
|
||||
"SwaggerUIBundle.presets.apis," in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
"SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"layout": "BaseLayout",' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"deepLinking": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"showExtensions": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"showCommonExtensions": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert "SwaggerUIBundle.presets.apis," in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"layout": "BaseLayout",' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"deepLinking": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"showExtensions": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"showCommonExtensions": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
|
||||
|
||||
def test_get_users():
|
||||
|
||||
@@ -8,34 +8,34 @@ client = TestClient(app)
|
||||
def test_swagger_ui():
|
||||
response = client.get("/docs")
|
||||
assert response.status_code == 200, response.text
|
||||
assert (
|
||||
'"deepLinking": false,' in response.text
|
||||
), "overridden configs should be preserved"
|
||||
assert (
|
||||
'"deepLinking": true' not in response.text
|
||||
), "overridden configs should not include the old value"
|
||||
assert (
|
||||
'"syntaxHighlight": false' not in response.text
|
||||
), "not used parameters should not be included"
|
||||
assert (
|
||||
'"dom_id": "#swagger-ui"' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert '"deepLinking": false,' in response.text, (
|
||||
"overridden configs should be preserved"
|
||||
)
|
||||
assert '"deepLinking": true' not in response.text, (
|
||||
"overridden configs should not include the old value"
|
||||
)
|
||||
assert '"syntaxHighlight": false' not in response.text, (
|
||||
"not used parameters should not be included"
|
||||
)
|
||||
assert '"dom_id": "#swagger-ui"' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "presets: [" in response.text, "default configs should be preserved"
|
||||
assert (
|
||||
"SwaggerUIBundle.presets.apis," in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
"SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"layout": "BaseLayout",' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"showExtensions": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert (
|
||||
'"showCommonExtensions": true,' in response.text
|
||||
), "default configs should be preserved"
|
||||
assert "SwaggerUIBundle.presets.apis," in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"layout": "BaseLayout",' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"showExtensions": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"showCommonExtensions": true,' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
|
||||
|
||||
def test_get_users():
|
||||
|
||||
@@ -129,13 +129,13 @@ def test_openapi_schema(client: TestClient):
|
||||
"schema": {"type": "string", "title": "Host"},
|
||||
},
|
||||
{
|
||||
"name": "save_data",
|
||||
"name": "save-data",
|
||||
"in": "header",
|
||||
"required": True,
|
||||
"schema": {"type": "boolean", "title": "Save Data"},
|
||||
},
|
||||
{
|
||||
"name": "if_modified_since",
|
||||
"name": "if-modified-since",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": IsDict(
|
||||
@@ -171,7 +171,7 @@ def test_openapi_schema(client: TestClient):
|
||||
),
|
||||
},
|
||||
{
|
||||
"name": "x_tag",
|
||||
"name": "x-tag",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": {
|
||||
|
||||
@@ -140,13 +140,13 @@ def test_openapi_schema(client: TestClient):
|
||||
"schema": {"type": "string", "title": "Host"},
|
||||
},
|
||||
{
|
||||
"name": "save_data",
|
||||
"name": "save-data",
|
||||
"in": "header",
|
||||
"required": True,
|
||||
"schema": {"type": "boolean", "title": "Save Data"},
|
||||
},
|
||||
{
|
||||
"name": "if_modified_since",
|
||||
"name": "if-modified-since",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": IsDict(
|
||||
@@ -182,7 +182,7 @@ def test_openapi_schema(client: TestClient):
|
||||
),
|
||||
},
|
||||
{
|
||||
"name": "x_tag",
|
||||
"name": "x-tag",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": {
|
||||
|
||||
285
tests/test_tutorial/test_header_param_models/test_tutorial003.py
Normal file
285
tests/test_tutorial/test_header_param_models/test_tutorial003.py
Normal file
@@ -0,0 +1,285 @@
|
||||
import importlib
|
||||
|
||||
import pytest
|
||||
from dirty_equals import IsDict
|
||||
from fastapi.testclient import TestClient
|
||||
from inline_snapshot import snapshot
|
||||
|
||||
from tests.utils import needs_py39, needs_py310
|
||||
|
||||
|
||||
@pytest.fixture(
|
||||
name="client",
|
||||
params=[
|
||||
"tutorial003",
|
||||
pytest.param("tutorial003_py39", marks=needs_py39),
|
||||
pytest.param("tutorial003_py310", marks=needs_py310),
|
||||
"tutorial003_an",
|
||||
pytest.param("tutorial003_an_py39", marks=needs_py39),
|
||||
pytest.param("tutorial003_an_py310", marks=needs_py310),
|
||||
],
|
||||
)
|
||||
def get_client(request: pytest.FixtureRequest):
|
||||
mod = importlib.import_module(f"docs_src.header_param_models.{request.param}")
|
||||
|
||||
client = TestClient(mod.app)
|
||||
return client
|
||||
|
||||
|
||||
def test_header_param_model(client: TestClient):
|
||||
response = client.get(
|
||||
"/items/",
|
||||
headers=[
|
||||
("save_data", "true"),
|
||||
("if_modified_since", "yesterday"),
|
||||
("traceparent", "123"),
|
||||
("x_tag", "one"),
|
||||
("x_tag", "two"),
|
||||
],
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"host": "testserver",
|
||||
"save_data": True,
|
||||
"if_modified_since": "yesterday",
|
||||
"traceparent": "123",
|
||||
"x_tag": ["one", "two"],
|
||||
}
|
||||
|
||||
|
||||
def test_header_param_model_no_underscore(client: TestClient):
|
||||
response = client.get(
|
||||
"/items/",
|
||||
headers=[
|
||||
("save-data", "true"),
|
||||
("if-modified-since", "yesterday"),
|
||||
("traceparent", "123"),
|
||||
("x-tag", "one"),
|
||||
("x-tag", "two"),
|
||||
],
|
||||
)
|
||||
assert response.status_code == 422
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"detail": [
|
||||
IsDict(
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["header", "save_data"],
|
||||
"msg": "Field required",
|
||||
"input": {
|
||||
"host": "testserver",
|
||||
"traceparent": "123",
|
||||
"x_tag": [],
|
||||
"accept": "*/*",
|
||||
"accept-encoding": "gzip, deflate",
|
||||
"connection": "keep-alive",
|
||||
"user-agent": "testclient",
|
||||
"save-data": "true",
|
||||
"if-modified-since": "yesterday",
|
||||
"x-tag": "two",
|
||||
},
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"type": "value_error.missing",
|
||||
"loc": ["header", "save_data"],
|
||||
"msg": "field required",
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_header_param_model_defaults(client: TestClient):
|
||||
response = client.get("/items/", headers=[("save_data", "true")])
|
||||
assert response.status_code == 200
|
||||
assert response.json() == {
|
||||
"host": "testserver",
|
||||
"save_data": True,
|
||||
"if_modified_since": None,
|
||||
"traceparent": None,
|
||||
"x_tag": [],
|
||||
}
|
||||
|
||||
|
||||
def test_header_param_model_invalid(client: TestClient):
|
||||
response = client.get("/items/")
|
||||
assert response.status_code == 422
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"detail": [
|
||||
IsDict(
|
||||
{
|
||||
"type": "missing",
|
||||
"loc": ["header", "save_data"],
|
||||
"msg": "Field required",
|
||||
"input": {
|
||||
"x_tag": [],
|
||||
"host": "testserver",
|
||||
"accept": "*/*",
|
||||
"accept-encoding": "gzip, deflate",
|
||||
"connection": "keep-alive",
|
||||
"user-agent": "testclient",
|
||||
},
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"type": "value_error.missing",
|
||||
"loc": ["header", "save_data"],
|
||||
"msg": "field required",
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_header_param_model_extra(client: TestClient):
|
||||
response = client.get(
|
||||
"/items/", headers=[("save_data", "true"), ("tool", "plumbus")]
|
||||
)
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"host": "testserver",
|
||||
"save_data": True,
|
||||
"if_modified_since": None,
|
||||
"traceparent": None,
|
||||
"x_tag": [],
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def test_openapi_schema(client: TestClient):
|
||||
response = client.get("/openapi.json")
|
||||
assert response.status_code == 200, response.text
|
||||
assert response.json() == snapshot(
|
||||
{
|
||||
"openapi": "3.1.0",
|
||||
"info": {"title": "FastAPI", "version": "0.1.0"},
|
||||
"paths": {
|
||||
"/items/": {
|
||||
"get": {
|
||||
"summary": "Read Items",
|
||||
"operationId": "read_items_items__get",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "host",
|
||||
"in": "header",
|
||||
"required": True,
|
||||
"schema": {"type": "string", "title": "Host"},
|
||||
},
|
||||
{
|
||||
"name": "save_data",
|
||||
"in": "header",
|
||||
"required": True,
|
||||
"schema": {"type": "boolean", "title": "Save Data"},
|
||||
},
|
||||
{
|
||||
"name": "if_modified_since",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "If Modified Since",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"type": "string",
|
||||
"title": "If Modified Since",
|
||||
}
|
||||
),
|
||||
},
|
||||
{
|
||||
"name": "traceparent",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": IsDict(
|
||||
{
|
||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||
"title": "Traceparent",
|
||||
}
|
||||
)
|
||||
| IsDict(
|
||||
# TODO: remove when deprecating Pydantic v1
|
||||
{
|
||||
"type": "string",
|
||||
"title": "Traceparent",
|
||||
}
|
||||
),
|
||||
},
|
||||
{
|
||||
"name": "x_tag",
|
||||
"in": "header",
|
||||
"required": False,
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"},
|
||||
"default": [],
|
||||
"title": "X Tag",
|
||||
},
|
||||
},
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Successful Response",
|
||||
"content": {"application/json": {"schema": {}}},
|
||||
},
|
||||
"422": {
|
||||
"description": "Validation Error",
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "#/components/schemas/HTTPValidationError"
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"components": {
|
||||
"schemas": {
|
||||
"HTTPValidationError": {
|
||||
"properties": {
|
||||
"detail": {
|
||||
"items": {
|
||||
"$ref": "#/components/schemas/ValidationError"
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Detail",
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"title": "HTTPValidationError",
|
||||
},
|
||||
"ValidationError": {
|
||||
"properties": {
|
||||
"loc": {
|
||||
"items": {
|
||||
"anyOf": [{"type": "string"}, {"type": "integer"}]
|
||||
},
|
||||
"type": "array",
|
||||
"title": "Location",
|
||||
},
|
||||
"msg": {"type": "string", "title": "Message"},
|
||||
"type": {"type": "string", "title": "Error Type"},
|
||||
},
|
||||
"type": "object",
|
||||
"required": ["loc", "msg", "type"],
|
||||
"title": "ValidationError",
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
)
|
||||
@@ -71,9 +71,9 @@ def test_crud_app(client: TestClient):
|
||||
assert response.json() == snapshot(
|
||||
{"age": 30, "id": IsInt(), "name": "Dead Pond"}
|
||||
)
|
||||
assert (
|
||||
response.json()["id"] != 9000
|
||||
), "The ID should be generated by the database"
|
||||
assert response.json()["id"] != 9000, (
|
||||
"The ID should be generated by the database"
|
||||
)
|
||||
|
||||
# Read a hero
|
||||
hero_id = response.json()["id"]
|
||||
|
||||
Reference in New Issue
Block a user