mirror of https://github.com/tiangolo/fastapi.git
OAuth2PasswordRequestForm: set OpenAPI format to password for fields password and client secret
This commit is contained in:
parent
92feb73531
commit
0236eb45e6
|
|
@ -85,7 +85,7 @@ class 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
|
||||||
|
|
@ -130,7 +130,7 @@ class OAuth2PasswordRequestForm:
|
||||||
] = None,
|
] = None,
|
||||||
client_secret: Annotated[
|
client_secret: Annotated[
|
||||||
Union[str, None],
|
Union[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
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ def test_openapi_schema():
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -161,6 +161,7 @@ def test_openapi_schema():
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ def test_openapi_schema():
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -161,6 +161,7 @@ def test_openapi_schema():
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -177,6 +177,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -177,6 +177,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -177,6 +177,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ def test_openapi_schema():
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -355,6 +355,7 @@ def test_openapi_schema():
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -339,7 +339,7 @@ def test_openapi_schema():
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -355,6 +355,7 @@ def test_openapi_schema():
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
|
|
@ -367,7 +367,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
"username": {"title": "Username", "type": "string"},
|
"username": {"title": "Username", "type": "string"},
|
||||||
"password": {"title": "Password", "type": "string"},
|
"password": {"title": "Password", "type": "string", "format": "password"},
|
||||||
"scope": {"title": "Scope", "type": "string", "default": ""},
|
"scope": {"title": "Scope", "type": "string", "default": ""},
|
||||||
"client_id": IsDict(
|
"client_id": IsDict(
|
||||||
{
|
{
|
||||||
|
|
@ -383,6 +383,7 @@ def test_openapi_schema(client: TestClient):
|
||||||
{
|
{
|
||||||
"title": "Client Secret",
|
"title": "Client Secret",
|
||||||
"anyOf": [{"type": "string"}, {"type": "null"}],
|
"anyOf": [{"type": "string"}, {"type": "null"}],
|
||||||
|
"format": "password",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
| IsDict(
|
| IsDict(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue