Skip to content

Commit

Permalink
Specific auth settings
Browse files Browse the repository at this point in the history
  • Loading branch information
multani committed Nov 3, 2024
1 parent 7727588 commit b2fc64f
Show file tree
Hide file tree
Showing 5 changed files with 367 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,113 @@ JSON_SCHEMA_VALIDATION_KEYWORDS = {

ServerVariablesT = Dict[str, str]

AuthSetting = TypedDict(
"AuthSetting",
GenericAuthSetting = TypedDict(
"GenericAuthSetting",
{
"type": str,
"in": str,
"key": str,
"value": str,
},
)


OAuth2AuthSetting = TypedDict(
"OAuth2AuthSetting",
{
"type": Literal["oauth2"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": str,
},
)


APIKeyAuthSetting = TypedDict(
"APIKeyAuthSetting",
{
"type": Literal["api_key"],
"in": str,
"key": str,
"value": Optional[str],
},
)


{{#authMethods}}
{{#isBasic}}
{{#isBasicBearer}}
{{#bearerFormat}}
class AuthSettingJWT(AuthSetting):
format: Literal["JWT"]
{{/bearerFormat}}
{{/isBasicBearer}}
{{/isBasic}}
{{/authMethods}}
BasicAuthSetting = TypedDict(
"BasicAuthSetting",
{
"type": Literal["basic"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": Optional[str],
},
)


BearerFormatAuthSetting = TypedDict(
"BearerFormatAuthSetting",
{
"type": Literal["bearer"],
"in": Literal["header"],
"format": Literal["JWT"],
"key": Literal["Authorization"],
"value": str,
},
)


BearerAuthSetting = TypedDict(
"BearerAuthSetting",
{
"type": Literal["bearer"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": str,
},
)


HTTPSignatureAuthSetting = TypedDict(
"HTTPSignatureAuthSetting",
{
"type": Literal["http-signature"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": None,
},
)


AuthSettings = TypedDict(
"AuthSettings",
{
{{#authMethods}}
{{#isOAuth}}
"{{name}}": NotRequired[AuthSetting],
"{{name}}": OAuth2AuthSetting,
{{/isOAuth}}
{{#isApiKey}}
"{{name}}": NotRequired[AuthSetting],
"{{name}}": APIKeyAuthSetting,
{{/isApiKey}}
{{#isBasic}}
{{#isBasicBasic}}
"{{name}}": NotRequired[AuthSetting],
"{{name}}": BasicAuthSetting,
{{/isBasicBasic}}
{{#isBasicBearer}}
{{#bearerFormat}}
"{{name}}": NotRequired[AuthSettingJWT],
"{{name}}": BearerFormatAuthSetting,
{{/bearerFormat}}
{{^bearerFormat}}
"{{name}}": NotRequired[AuthSetting],
"{{name}}": BearerAuthSetting,
{{/bearerFormat}}
{{/isBasicBearer}}
{{#isHttpSignature}}
"{{name}}": NotRequired[AuthSetting],
"{{name}}": HTTPSignatureAuthSetting,
{{/isHttpSignature}}
{{/isBasic}}
{{/authMethods}}
}
},
total=False,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,91 @@

ServerVariablesT = Dict[str, str]

AuthSetting = TypedDict(
"AuthSetting",
GenericAuthSetting = TypedDict(
"GenericAuthSetting",
{
"type": str,
"in": str,
"key": str,
"value": str,
},
)


OAuth2AuthSetting = TypedDict(
"OAuth2AuthSetting",
{
"type": Literal["oauth2"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": str,
},
)


APIKeyAuthSetting = TypedDict(
"APIKeyAuthSetting",
{
"type": Literal["api_key"],
"in": str,
"key": str,
"value": Optional[str],
},
)


BasicAuthSetting = TypedDict(
"BasicAuthSetting",
{
"type": Literal["basic"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": Optional[str],
},
)


BearerFormatAuthSetting = TypedDict(
"BearerFormatAuthSetting",
{
"type": Literal["bearer"],
"in": Literal["header"],
"format": Literal["JWT"],
"key": Literal["Authorization"],
"value": str,
},
)


BearerAuthSetting = TypedDict(
"BearerAuthSetting",
{
"type": Literal["bearer"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": str,
},
)


HTTPSignatureAuthSetting = TypedDict(
"HTTPSignatureAuthSetting",
{
"type": Literal["http-signature"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": None,
},
)


AuthSettings = TypedDict(
"AuthSettings",
{
"http_auth": NotRequired[AuthSetting],
"http_bearer_auth": NotRequired[AuthSetting],
}
"http_auth": BasicAuthSetting,
"http_bearer_auth": BearerAuthSetting,
},
total=False,
)


Expand Down
76 changes: 71 additions & 5 deletions samples/client/echo_api/python/openapi_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,91 @@

ServerVariablesT = Dict[str, str]

AuthSetting = TypedDict(
"AuthSetting",
GenericAuthSetting = TypedDict(
"GenericAuthSetting",
{
"type": str,
"in": str,
"key": str,
"value": str,
},
)


OAuth2AuthSetting = TypedDict(
"OAuth2AuthSetting",
{
"type": Literal["oauth2"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": str,
},
)


APIKeyAuthSetting = TypedDict(
"APIKeyAuthSetting",
{
"type": Literal["api_key"],
"in": str,
"key": str,
"value": Optional[str],
},
)


BasicAuthSetting = TypedDict(
"BasicAuthSetting",
{
"type": Literal["basic"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": Optional[str],
},
)


BearerFormatAuthSetting = TypedDict(
"BearerFormatAuthSetting",
{
"type": Literal["bearer"],
"in": Literal["header"],
"format": Literal["JWT"],
"key": Literal["Authorization"],
"value": str,
},
)


BearerAuthSetting = TypedDict(
"BearerAuthSetting",
{
"type": Literal["bearer"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": str,
},
)


HTTPSignatureAuthSetting = TypedDict(
"HTTPSignatureAuthSetting",
{
"type": Literal["http-signature"],
"in": Literal["header"],
"key": Literal["Authorization"],
"value": None,
},
)


AuthSettings = TypedDict(
"AuthSettings",
{
"http_auth": NotRequired[AuthSetting],
"http_bearer_auth": NotRequired[AuthSetting],
}
"http_auth": BasicAuthSetting,
"http_bearer_auth": BearerAuthSetting,
},
total=False,
)


Expand Down
Loading

0 comments on commit b2fc64f

Please sign in to comment.