Browse Source

Added password format to Oauth2PasswordRequestFormStrict fields

pull/15099/head
Maheedhar Rao Govada 4 months ago
parent
commit
6ba031db9a
  1. 4
      fastapi/security/oauth2.py
  2. 5
      tests/test_security_oauth2.py

4
fastapi/security/oauth2.py

@ -255,7 +255,7 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm):
], ],
password: Annotated[ password: Annotated[
str, str,
Form(), Form(json_schema_extra={"format": "password"}),
Doc( Doc(
""" """
`password` string. The OAuth2 spec requires the exact field name `password` string. The OAuth2 spec requires the exact field name
@ -306,7 +306,7 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm):
] = None, ] = None,
client_secret: Annotated[ client_secret: Annotated[
str | None, str | None,
Form(), Form(json_schema_extra={"format": "password"}),
Doc( Doc(
""" """
If there's a `client_password` (and a `client_id`), they can be sent If there's a `client_password` (and a `client_id`), they can be sent

5
tests/test_security_oauth2.py

@ -213,7 +213,7 @@ def test_openapi_schema():
"type": "string", "type": "string",
}, },
"username": {"title": "Username", "type": "string"}, "username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"}, "password": {"title": "Password", 'format': 'password', "type": "string"},
"scope": { "scope": {
"title": "Scope", "title": "Scope",
"type": "string", "type": "string",
@ -224,8 +224,7 @@ def test_openapi_schema():
"anyOf": [{"type": "string"}, {"type": "null"}], "anyOf": [{"type": "string"}, {"type": "null"}],
}, },
"client_secret": { "client_secret": {
"title": "Client Secret", "title": "Client Secret", 'format': 'password', "anyOf": [{"type": "string"}, {"type": "null"}],
"anyOf": [{"type": "string"}, {"type": "null"}],
}, },
}, },
}, },

Loading…
Cancel
Save