forked from loafle/openapi-generator-original
[python-fastapi]Add an alias keyword parameter for Query parameter (#17111)
* add alias to endpoint_definition * regenerate source code
This commit is contained in:
parent
9970c06f8c
commit
baaf759440
@ -1 +1 @@
|
||||
{{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}({{&defaultValue}}{{^defaultValue}}None{{/defaultValue}}, description="{{description}}"{{#isLong}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isLong}}{{#isInteger}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isInteger}}{{#pattern}}, regex=r"{{.}}"{{/pattern}}{{#minLength}}, min_length={{.}}{{/minLength}}{{#maxLength}}, max_length={{.}}{{/maxLength}})
|
||||
{{#isPathParam}}{{baseName}}{{/isPathParam}}{{^isPathParam}}{{paramName}}{{/isPathParam}}: {{>param_type}} = {{#isPathParam}}Path{{/isPathParam}}{{#isHeaderParam}}Header{{/isHeaderParam}}{{#isFormParam}}Form{{/isFormParam}}{{#isQueryParam}}Query{{/isQueryParam}}{{#isCookieParam}}Cookie{{/isCookieParam}}{{#isBodyParam}}Body{{/isBodyParam}}({{&defaultValue}}{{^defaultValue}}None{{/defaultValue}}, description="{{description}}"{{#isQueryParam}}, alias="{{baseName}}"{{/isQueryParam}}{{#isLong}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isLong}}{{#isInteger}}{{#minimum}}, ge={{.}}{{/minimum}}{{#maximum}}, le={{.}}{{/maximum}}{{/isInteger}}{{#pattern}}, regex=r"{{.}}"{{/pattern}}{{#minLength}}, min_length={{.}}{{/minLength}}{{#maxLength}}, max_length={{.}}{{/maxLength}})
|
@ -577,13 +577,13 @@ paths:
|
||||
description: ''
|
||||
operationId: fake_query_param_default
|
||||
parameters:
|
||||
- name: has_default
|
||||
- name: hasDefault
|
||||
in: query
|
||||
description: has default value
|
||||
schema:
|
||||
type: string
|
||||
default: Hello World
|
||||
- name: no_default
|
||||
- name: noDefault
|
||||
in: query
|
||||
description: no default value
|
||||
schema:
|
||||
|
@ -590,7 +590,7 @@ paths:
|
||||
- description: has default value
|
||||
explode: true
|
||||
in: query
|
||||
name: has_default
|
||||
name: hasDefault
|
||||
required: false
|
||||
schema:
|
||||
default: Hello World
|
||||
@ -599,7 +599,7 @@ paths:
|
||||
- description: no default value
|
||||
explode: true
|
||||
in: query
|
||||
name: no_default
|
||||
name: noDefault
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
|
@ -42,8 +42,8 @@ for _, name, _ in pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + "."):
|
||||
response_model_by_alias=True,
|
||||
)
|
||||
async def fake_query_param_default(
|
||||
has_default: str = Query('Hello World', description="has default value"),
|
||||
no_default: str = Query(None, description="no default value"),
|
||||
has_default: str = Query('Hello World', description="has default value", alias="hasDefault"),
|
||||
no_default: str = Query(None, description="no default value", alias="noDefault"),
|
||||
) -> None:
|
||||
""""""
|
||||
return BaseFakeApi.subclasses[0]().fake_query_param_default(has_default, no_default)
|
||||
|
@ -84,7 +84,7 @@ async def delete_pet(
|
||||
response_model_by_alias=True,
|
||||
)
|
||||
async def find_pets_by_status(
|
||||
status: List[str] = Query(None, description="Status values that need to be considered for filter"),
|
||||
status: List[str] = Query(None, description="Status values that need to be considered for filter", alias="status"),
|
||||
token_petstore_auth: TokenModel = Security(
|
||||
get_token_petstore_auth, scopes=["read:pets"]
|
||||
),
|
||||
@ -104,7 +104,7 @@ async def find_pets_by_status(
|
||||
response_model_by_alias=True,
|
||||
)
|
||||
async def find_pets_by_tags(
|
||||
tags: List[str] = Query(None, description="Tags to filter by"),
|
||||
tags: List[str] = Query(None, description="Tags to filter by", alias="tags"),
|
||||
token_petstore_auth: TokenModel = Security(
|
||||
get_token_petstore_auth, scopes=["read:pets"]
|
||||
),
|
||||
|
@ -138,8 +138,8 @@ async def get_user_by_name(
|
||||
response_model_by_alias=True,
|
||||
)
|
||||
async def login_user(
|
||||
username: str = Query(None, description="The user name for login", regex=r"/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/"),
|
||||
password: str = Query(None, description="The password for login in clear text"),
|
||||
username: str = Query(None, description="The user name for login", alias="username", regex=r"/^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$/"),
|
||||
password: str = Query(None, description="The password for login in clear text", alias="password"),
|
||||
) -> str:
|
||||
""""""
|
||||
return BaseUserApi.subclasses[0]().login_user(username, password)
|
||||
|
Loading…
x
Reference in New Issue
Block a user