OAuth2PasswordRequestForm: set OpenAPI format to password for fields password and client secret

This commit is contained in:
Theodoros Tyrovouzis 2024-01-25 23:15:52 +02:00
parent 92feb73531
commit 0236eb45e6
12 changed files with 24 additions and 13 deletions

View File

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

View File

@ -145,7 +145,7 @@ def test_openapi_schema():
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -161,6 +161,7 @@ def test_openapi_schema():
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -145,7 +145,7 @@ def test_openapi_schema():
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -161,6 +161,7 @@ def test_openapi_schema():
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -161,7 +161,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -177,6 +177,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -161,7 +161,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -177,6 +177,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -161,7 +161,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -177,6 +177,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -339,7 +339,7 @@ def test_openapi_schema():
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -355,6 +355,7 @@ def test_openapi_schema():
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -339,7 +339,7 @@ def test_openapi_schema():
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -355,6 +355,7 @@ def test_openapi_schema():
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(

View File

@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
}
),
"username": {"title": "Username", "type": "string"},
"password": {"title": "Password", "type": "string"},
"password": {"title": "Password", "type": "string", "format": "password"},
"scope": {"title": "Scope", "type": "string", "default": ""},
"client_id": IsDict(
{
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
{
"title": "Client Secret",
"anyOf": [{"type": "string"}, {"type": "null"}],
"format": "password",
}
)
| IsDict(