Repository navigation
Expand file tree
/
Copy pathsecurity_scheme.py
More file actions
47 lines (42 loc) · 1.78 KB
/
Copy pathsecurity_scheme.py
File metadata and controls
47 lines (42 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from pydantic import BaseModel, ConfigDict, Field
from .oauth_flows import OAuthFlows
class SecurityScheme(BaseModel):
"""
Defines a security scheme that can be used by the operations.
Supported schemes are HTTP authentication,
an API key (either as a header, a cookie parameter or as a query parameter),
OAuth2's common flows (implicit, password, client credentials and authorization code)
as defined in [RFC6749](https://tools.ietf.org/html/rfc6749),
and [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06).
References:
- https://swagger.io/docs/specification/authentication/
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#componentsObject
"""
type: str
description: str | None = None
name: str | None = None
security_scheme_in: str | None = Field(default=None, alias="in")
scheme: str | None = None
bearerFormat: str | None = None
flows: OAuthFlows | None = None
openIdConnectUrl: str | None = None
model_config = ConfigDict(
extra="allow",
populate_by_name=True,
json_schema_extra={
"examples": [
{"type": "http", "scheme": "basic"},
{"type": "apiKey", "name": "api_key", "in": "header"},
{"type": "http", "scheme": "bearer", "bearerFormat": "JWT"},
{
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "https://example.com/api/oauth/dialog",
"scopes": {"write:pets": "modify pets in your account", "read:pets": "read your pets"},
}
},
},
]
},
)