forked from loafle/openapi-generator-original
Python AIOHTTP server generator (#1470)
* Astract factory for generators based on connexion * Add aiohttp server generator * Fix flask tests * Normalize python-flask folder names
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
import connexion
|
||||
import six
|
||||
|
||||
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||
from openapi_server.models.pet import Pet # noqa: E501
|
||||
from openapi_server import util
|
||||
|
||||
|
||||
def add_pet(body): # noqa: E501
|
||||
"""Add a new pet to the store
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param body: Pet object that needs to be added to the store
|
||||
:type body: dict | bytes
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def delete_pet(pet_id, api_key=None): # noqa: E501
|
||||
"""Deletes a pet
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param pet_id: Pet id to delete
|
||||
:type pet_id: int
|
||||
:param api_key:
|
||||
:type api_key: str
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def find_pets_by_status(status): # noqa: E501
|
||||
"""Finds Pets by status
|
||||
|
||||
Multiple status values can be provided with comma separated strings # noqa: E501
|
||||
|
||||
:param status: Status values that need to be considered for filter
|
||||
:type status: List[str]
|
||||
|
||||
:rtype: List[Pet]
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def find_pets_by_tags(tags): # noqa: E501
|
||||
"""Finds Pets by tags
|
||||
|
||||
Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # noqa: E501
|
||||
|
||||
:param tags: Tags to filter by
|
||||
:type tags: List[str]
|
||||
|
||||
:rtype: List[Pet]
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def get_pet_by_id(pet_id): # noqa: E501
|
||||
"""Find pet by ID
|
||||
|
||||
Returns a single pet # noqa: E501
|
||||
|
||||
:param pet_id: ID of pet to return
|
||||
:type pet_id: int
|
||||
|
||||
:rtype: Pet
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def update_pet(body): # noqa: E501
|
||||
"""Update an existing pet
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param body: Pet object that needs to be added to the store
|
||||
:type body: dict | bytes
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = Pet.from_dict(connexion.request.get_json()) # noqa: E501
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def update_pet_with_form(pet_id, name=None, status=None): # noqa: E501
|
||||
"""Updates a pet in the store with form data
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param pet_id: ID of pet that needs to be updated
|
||||
:type pet_id: int
|
||||
:param name: Updated name of the pet
|
||||
:type name: str
|
||||
:param status: Updated status of the pet
|
||||
:type status: str
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def upload_file(pet_id, additional_metadata=None, file=None): # noqa: E501
|
||||
"""uploads an image
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param pet_id: ID of pet to update
|
||||
:type pet_id: int
|
||||
:param additional_metadata: Additional data to pass to server
|
||||
:type additional_metadata: str
|
||||
:param file: file to upload
|
||||
:type file: str
|
||||
|
||||
:rtype: ApiResponse
|
||||
"""
|
||||
return 'do some magic!'
|
||||
@@ -0,0 +1,48 @@
|
||||
from typing import List
|
||||
|
||||
|
||||
def info_from_api_key(api_key, required_scopes):
|
||||
"""
|
||||
Check and retrieve authentication information from api_key.
|
||||
Returned value will be passed in 'token_info' parameter of your operation function, if there is one.
|
||||
'sub' or 'uid' will be set in 'user' parameter of your operation function, if there is one.
|
||||
|
||||
:param api_key API key provided by Authorization header
|
||||
:type api_key: str
|
||||
:param required_scopes Always None. Used for other authentication method
|
||||
:type required_scopes: None
|
||||
:return: Information attached to provided api_key or None if api_key is invalid or does not allow access to called API
|
||||
:rtype: dict | None
|
||||
"""
|
||||
return {'uid': 'user_id'}
|
||||
|
||||
|
||||
def info_from_petstore_auth(token):
|
||||
"""
|
||||
Validate and decode token.
|
||||
Returned value will be passed in 'token_info' parameter of your operation function, if there is one.
|
||||
'sub' or 'uid' will be set in 'user' parameter of your operation function, if there is one.
|
||||
'scope' or 'scopes' will be passed to scope validation function.
|
||||
|
||||
:param token Token provided by Authorization header
|
||||
:type token: str
|
||||
:return: Decoded token information or None if token is invalid
|
||||
:rtype: dict | None
|
||||
"""
|
||||
return {'scopes': ['read:pets', 'write:pets'], 'uid': 'user_id'}
|
||||
|
||||
|
||||
def validate_scope_petstore_auth(required_scopes, token_scopes):
|
||||
"""
|
||||
Validate required scopes are included in token scope
|
||||
|
||||
:param required_scopes Required scope to access called API
|
||||
:type required_scopes: List[str]
|
||||
:param token_scopes Scope present in token
|
||||
:type token_scopes: List[str]
|
||||
:return: True if access to called API is allowed
|
||||
:rtype: bool
|
||||
"""
|
||||
return set(required_scopes).issubset(set(token_scopes))
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import connexion
|
||||
import six
|
||||
|
||||
from openapi_server.models.order import Order # noqa: E501
|
||||
from openapi_server import util
|
||||
|
||||
|
||||
def delete_order(order_id): # noqa: E501
|
||||
"""Delete purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # noqa: E501
|
||||
|
||||
:param order_id: ID of the order that needs to be deleted
|
||||
:type order_id: str
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def get_inventory(): # noqa: E501
|
||||
"""Returns pet inventories by status
|
||||
|
||||
Returns a map of status codes to quantities # noqa: E501
|
||||
|
||||
|
||||
:rtype: Dict[str, int]
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def get_order_by_id(order_id): # noqa: E501
|
||||
"""Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # noqa: E501
|
||||
|
||||
:param order_id: ID of pet that needs to be fetched
|
||||
:type order_id: int
|
||||
|
||||
:rtype: Order
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def place_order(body): # noqa: E501
|
||||
"""Place an order for a pet
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param body: order placed for purchasing the pet
|
||||
:type body: dict | bytes
|
||||
|
||||
:rtype: Order
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = Order.from_dict(connexion.request.get_json()) # noqa: E501
|
||||
return 'do some magic!'
|
||||
@@ -0,0 +1,119 @@
|
||||
import connexion
|
||||
import six
|
||||
|
||||
from openapi_server.models.user import User # noqa: E501
|
||||
from openapi_server import util
|
||||
|
||||
|
||||
def create_user(body): # noqa: E501
|
||||
"""Create user
|
||||
|
||||
This can only be done by the logged in user. # noqa: E501
|
||||
|
||||
:param body: Created user object
|
||||
:type body: dict | bytes
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = User.from_dict(connexion.request.get_json()) # noqa: E501
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def create_users_with_array_input(body): # noqa: E501
|
||||
"""Creates list of users with given input array
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param body: List of user object
|
||||
:type body: list | bytes
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def create_users_with_list_input(body): # noqa: E501
|
||||
"""Creates list of users with given input array
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param body: List of user object
|
||||
:type body: list | bytes
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = [User.from_dict(d) for d in connexion.request.get_json()] # noqa: E501
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def delete_user(username): # noqa: E501
|
||||
"""Delete user
|
||||
|
||||
This can only be done by the logged in user. # noqa: E501
|
||||
|
||||
:param username: The name that needs to be deleted
|
||||
:type username: str
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def get_user_by_name(username): # noqa: E501
|
||||
"""Get user by user name
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param username: The name that needs to be fetched. Use user1 for testing.
|
||||
:type username: str
|
||||
|
||||
:rtype: User
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def login_user(username, password): # noqa: E501
|
||||
"""Logs user into the system
|
||||
|
||||
# noqa: E501
|
||||
|
||||
:param username: The user name for login
|
||||
:type username: str
|
||||
:param password: The password for login in clear text
|
||||
:type password: str
|
||||
|
||||
:rtype: str
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def logout_user(): # noqa: E501
|
||||
"""Logs out current logged in user session
|
||||
|
||||
# noqa: E501
|
||||
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
return 'do some magic!'
|
||||
|
||||
|
||||
def update_user(username, body): # noqa: E501
|
||||
"""Updated user
|
||||
|
||||
This can only be done by the logged in user. # noqa: E501
|
||||
|
||||
:param username: name that need to be deleted
|
||||
:type username: str
|
||||
:param body: Updated user object
|
||||
:type body: dict | bytes
|
||||
|
||||
:rtype: None
|
||||
"""
|
||||
if connexion.request.is_json:
|
||||
body = User.from_dict(connexion.request.get_json()) # noqa: E501
|
||||
return 'do some magic!'
|
||||
Reference in New Issue
Block a user