Skip to content
This repository was archived by the owner on Apr 3, 2023. It is now read-only.

Commit 4295bbd

Browse files
authored
Merge pull request #8 from starlite-api/typing-improvements
Replaces use of `str` with `Literal`.
2 parents 4971638 + 6d919c5 commit 4295bbd

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

mkdocs.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ theme:
2929
- navigation.tracking
3030
- navigation.tabs
3131
- navigation.top
32-
- navigation.expand
3332
- toc.integrate
3433
- search.suggest
3534
- search.highlight

pydantic_openapi_schema/v3_0_3/security_scheme.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional, Union
22

33
from pydantic import AnyUrl, BaseModel, Extra, Field
4+
from typing_extensions import Literal
45

56
from .oauth_flows import OAuthFlows
67

@@ -15,10 +16,9 @@ class SecurityScheme(BaseModel):
1516
and [OpenID Connect Discovery](https://tools.ietf.org/html/draft-ietf-oauth-discovery-06).
1617
"""
1718

18-
type: str
19+
type: Literal["apiKey", "http", "oauth2", "openIdConnect"]
1920
"""
2021
**REQUIRED**. The type of the security scheme.
21-
Valid values are `"apiKey"`, `"http"`, `"oauth2"`, `"openIdConnect"`.
2222
"""
2323

2424
description: Optional[str] = None
@@ -32,9 +32,9 @@ class SecurityScheme(BaseModel):
3232
**REQUIRED** for `apiKey`. The name of the header, query or cookie parameter to be used.
3333
"""
3434

35-
security_scheme_in: Optional[str] = Field(alias="in", default=None)
35+
security_scheme_in: Optional[Literal["query", "header", "cookie"]] = Field(alias="in", default=None)
3636
"""
37-
**REQUIRED** for `apiKey`. The location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`.
37+
**REQUIRED** for `apiKey`. The location of the API key.
3838
"""
3939

4040
scheme: Optional[str] = None

pydantic_openapi_schema/v3_1_0/security_scheme.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import Optional, Union
22

33
from pydantic import AnyUrl, BaseModel, Extra, Field
4+
from typing_extensions import Literal
45

56
from .oauth_flows import OAuthFlows
67

@@ -20,10 +21,9 @@ class SecurityScheme(BaseModel):
2021
Recommended for most use case is Authorization Code Grant flow with PKCE.
2122
"""
2223

23-
type: str
24+
type: Literal["apiKey", "http", "mutualTLS", "oauth2", "openIdConnect"]
2425
"""
2526
**REQUIRED**. The type of the security scheme.
26-
Valid values are `"apiKey"`, `"http"`, "mutualTLS", `"oauth2"`, `"openIdConnect"`.
2727
"""
2828

2929
description: Optional[str] = None
@@ -37,9 +37,9 @@ class SecurityScheme(BaseModel):
3737
**REQUIRED** for `apiKey`. The name of the header, query or cookie parameter to be used.
3838
"""
3939

40-
security_scheme_in: Optional[str] = Field(alias="in", default=None)
40+
security_scheme_in: Optional[Literal["query", "header", "cookie"]] = Field(alias="in", default=None)
4141
"""
42-
**REQUIRED** for `apiKey`. The location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`.
42+
**REQUIRED** for `apiKey`. The location of the API key.
4343
"""
4444

4545
scheme: Optional[str] = None

0 commit comments

Comments
 (0)