Skip to content

Commit ead5ae4

Browse files
committed
HTTPBase
1 parent dc78775 commit ead5ae4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

examples/rest_demo.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
from flask_openapi3 import Info, Tag
1010
from flask_openapi3 import OpenAPI
11-
from flask_openapi3.models.security import HTTPBearer, OAuth2, OAuthFlows, OAuthFlowImplicit, APIKey
11+
from flask_openapi3.models.security import HTTPBearer, OAuth2, OAuthFlows, OAuthFlowImplicit, APIKey, HTTPBase
1212

1313
info = Info(title='book API', version='1.0.0')
14-
jwt = HTTPBearer(bearerFormat="JWT")
14+
basic = HTTPBase()
15+
jwt = HTTPBearer()
1516
api_key = APIKey(name='api key')
1617
oauth2 = OAuth2(flows=OAuthFlows(
1718
implicit=OAuthFlowImplicit(
@@ -21,7 +22,7 @@
2122
"read:pets": "read your pets"
2223
}
2324
)))
24-
security_schemes = {"jwt": jwt, "api_key": api_key, "oauth2": oauth2}
25+
security_schemes = {"jwt": jwt, "api_key": api_key, "oauth2": oauth2, "basic": basic}
2526

2627

2728
class NotFoundResponse(BaseModel):
@@ -34,7 +35,8 @@ class NotFoundResponse(BaseModel):
3435
book_tag = Tag(name='book', description='Some Book')
3536
security = [
3637
{"jwt": []},
37-
{"oauth2": ["write:pets", "read:pets"]}
38+
{"oauth2": ["write:pets", "read:pets"]},
39+
{"basic": basic}
3840
]
3941

4042
app.config["VALIDATE_RESPONSE"] = True

flask_openapi3/models/security.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ class APIKey(SecurityBase):
3333

3434
class HTTPBase(SecurityBase):
3535
type_ = Field(default=SecuritySchemeType.http, alias="type")
36-
scheme: str
36+
scheme = 'basic'
3737

3838

3939
class HTTPBearer(HTTPBase):
4040
scheme = "bearer"
41-
bearerFormat: Optional[str] = None
41+
bearerFormat: Optional[str] = Field('JWT')
4242

4343

4444
class OAuthFlow(BaseModel):

0 commit comments

Comments
 (0)