From 7596fb7119cdd59dd24234d997c3ddd6f62eae6d Mon Sep 17 00:00:00 2001 From: Jakob Schmutz Date: Sun, 9 Sep 2018 16:23:06 +0100 Subject: [PATCH] fix circular import issue in python flask (#946) * fix circular import issue in python flask This is very similar change to 3678eaff87dd95348470c All it intends to do is fix the problem of cirular imports (which was already fixed for python) in the python flask server. * removal of type hints in quotes --- .../resources/flaskConnexion/model.mustache | 12 +- .../.openapi-generator/VERSION | 2 +- .../openapi_server/models/api_response.py | 6 +- .../openapi_server/models/category.py | 4 +- .../openapi_server/models/order.py | 12 +- .../openapi_server/models/pet.py | 14 +- .../openapi_server/models/tag.py | 4 +- .../openapi_server/models/user.py | 16 +- .../openapi_server/openapi/openapi.yaml | 676 +++++++++--------- .../openapi_server/util.py | 2 +- .../flaskConnexion/.openapi-generator/VERSION | 2 +- .../openapi_server/models/api_response.py | 20 +- .../openapi_server/models/category.py | 14 +- .../openapi_server/models/order.py | 38 +- .../openapi_server/models/pet.py | 40 +- .../openapi_server/models/tag.py | 14 +- .../openapi_server/models/user.py | 50 +- .../openapi_server/openapi/openapi.yaml | 676 +++++++++--------- .../flaskConnexion/openapi_server/util.py | 2 +- 19 files changed, 797 insertions(+), 807 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/flaskConnexion/model.mustache b/modules/openapi-generator/src/main/resources/flaskConnexion/model.mustache index 8cf835e5f579..821eaa3a780c 100644 --- a/modules/openapi-generator/src/main/resources/flaskConnexion/model.mustache +++ b/modules/openapi-generator/src/main/resources/flaskConnexion/model.mustache @@ -6,8 +6,6 @@ from datetime import date, datetime # noqa: F401 from typing import List, Dict # noqa: F401 from {{modelPackage}}.base_model_ import Model -{{#imports}}{{import}} # noqa: F401,E501 -{{/imports}} from {{packageName}} import util @@ -27,7 +25,7 @@ class {{classname}}(Model): {{/-last}} {{/enumVars}}{{/allowableValues}} - def __init__(self{{#vars}}, {{name}}{{^supportPython2}}: {{dataType}}{{/supportPython2}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 + def __init__(self{{#vars}}, {{name}}={{#defaultValue}}{{{defaultValue}}}{{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{/vars}}): # noqa: E501 """{{classname}} - a model defined in OpenAPI {{#vars}} @@ -37,7 +35,7 @@ class {{classname}}(Model): """ self.openapi_types = { {{#vars}} - '{{name}}': {{{dataType}}}{{#hasMore}},{{/hasMore}} + '{{name}}': '{{{dataType}}}'{{#hasMore}},{{/hasMore}} {{/vars}} } @@ -64,7 +62,7 @@ class {{classname}}(Model): {{/-first}} @property - def {{name}}(self){{^supportPython2}} -> {{dataType}}{{/supportPython2}}: + def {{name}}(self): """Gets the {{name}} of this {{classname}}. {{#description}} @@ -77,7 +75,7 @@ class {{classname}}(Model): return self._{{name}} @{{name}}.setter - def {{name}}(self, {{name}}{{^supportPython2}}: {{dataType}}{{/supportPython2}}): + def {{name}}(self, {{name}}): """Sets the {{name}} of this {{classname}}. {{#description}} @@ -158,4 +156,4 @@ class {{classname}}(Model): {{/vars}} {{/model}} -{{/models}} \ No newline at end of file +{{/models}} diff --git a/samples/server/petstore/flaskConnexion-python2/.openapi-generator/VERSION b/samples/server/petstore/flaskConnexion-python2/.openapi-generator/VERSION index 096bf47efe31..6d94c9c2e12a 100644 --- a/samples/server/petstore/flaskConnexion-python2/.openapi-generator/VERSION +++ b/samples/server/petstore/flaskConnexion-python2/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/api_response.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/api_response.py index f4f26e834a27..1b740655f7da 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/api_response.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/api_response.py @@ -26,9 +26,9 @@ def __init__(self, code=None, type=None, message=None): # noqa: E501 :type message: str """ self.openapi_types = { - 'code': int, - 'type': str, - 'message': str + 'code': 'int', + 'type': 'str', + 'message': 'str' } self.attribute_map = { diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/category.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/category.py index fc2b224078a3..b11afbf6641e 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/category.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/category.py @@ -24,8 +24,8 @@ def __init__(self, id=None, name=None): # noqa: E501 :type name: str """ self.openapi_types = { - 'id': long, - 'name': str + 'id': 'long', + 'name': 'str' } self.attribute_map = { diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/order.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/order.py index 02ea8c4fd728..d63b9e1d0090 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/order.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/order.py @@ -32,12 +32,12 @@ def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=N :type complete: bool """ self.openapi_types = { - 'id': long, - 'pet_id': long, - 'quantity': int, - 'ship_date': datetime, - 'status': str, - 'complete': bool + 'id': 'long', + 'pet_id': 'long', + 'quantity': 'int', + 'ship_date': 'datetime', + 'status': 'str', + 'complete': 'bool' } self.attribute_map = { diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/pet.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/pet.py index 411e9e12f528..aa880e600f87 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/pet.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/pet.py @@ -6,8 +6,6 @@ from typing import List, Dict # noqa: F401 from openapi_server.models.base_model_ import Model -from openapi_server.models.category import Category # noqa: F401,E501 -from openapi_server.models.tag import Tag # noqa: F401,E501 from openapi_server import util @@ -34,12 +32,12 @@ def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None :type status: str """ self.openapi_types = { - 'id': long, - 'category': Category, - 'name': str, - 'photo_urls': List[str], - 'tags': List[Tag], - 'status': str + 'id': 'long', + 'category': 'Category', + 'name': 'str', + 'photo_urls': 'List[str]', + 'tags': 'List[Tag]', + 'status': 'str' } self.attribute_map = { diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/tag.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/tag.py index 24a262951ed9..0dc7e32f4f1e 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/tag.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/tag.py @@ -24,8 +24,8 @@ def __init__(self, id=None, name=None): # noqa: E501 :type name: str """ self.openapi_types = { - 'id': long, - 'name': str + 'id': 'long', + 'name': 'str' } self.attribute_map = { diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/user.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/user.py index 3807bfe99782..c13e40f518c9 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/models/user.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/models/user.py @@ -36,14 +36,14 @@ def __init__(self, id=None, username=None, first_name=None, last_name=None, emai :type user_status: int """ self.openapi_types = { - 'id': long, - 'username': str, - 'first_name': str, - 'last_name': str, - 'email': str, - 'password': str, - 'phone': str, - 'user_status': int + 'id': 'long', + 'username': 'str', + 'first_name': 'str', + 'last_name': 'str', + 'email': 'str', + 'password': 'str', + 'phone': 'str', + 'user_status': 'int' } self.attribute_map = { diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/openapi/openapi.yaml b/samples/server/petstore/flaskConnexion-python2/openapi_server/openapi/openapi.yaml index cc02c545f9a5..dca523e5557c 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/openapi/openapi.yaml +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/openapi/openapi.yaml @@ -1,163 +1,202 @@ -openapi: 3.0.0 +openapi: 3.0.1 info: - title: OpenAPI Petstore description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. license: name: Apache-2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore version: 1.0.0 -externalDocs: - description: Find out more about Swagger - url: http://swagger.io servers: - url: http://petstore.swagger.io/v2 tags: -- name: pet - description: Everything about your Pets -- name: store - description: Access to Petstore orders -- name: user - description: Operations about user +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user paths: /pet: - put: + post: + operationId: add_pet + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + responses: + 405: + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store tags: - pet - summary: Update an existing pet + x-openapi-router-controller: openapi_server.controllers.pet_controller + put: operationId: update_pet requestBody: - $ref: '#/components/requestBodies/Pet' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true responses: 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Pet not found 405: + content: {} description: Validation exception security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: openapi_server.controllers.pet_controller - post: + summary: Update an existing pet tags: - pet - summary: Add a new pet to the store - operationId: add_pet - requestBody: - $ref: '#/components/requestBodies/Pet' - responses: - 405: - description: Invalid input - security: - - petstore_auth: - - write:pets - - read:pets x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/findByStatus: get: - tags: - - pet - summary: Finds Pets by status description: Multiple status values can be provided with comma separated strings operationId: find_pets_by_status parameters: - - name: status + - description: Status values that need to be considered for filter + explode: false in: query - description: Status values that need to be considered for filter + name: status required: true - style: form - explode: false schema: - type: array items: - type: string default: available enum: - available - pending - sold + type: string + type: array + style: form responses: 200: - description: successful operation content: application/xml: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array + description: successful operation 400: + content: {} description: Invalid status value security: - petstore_auth: - write:pets - read:pets + summary: Finds Pets by status + tags: + - pet x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/findByTags: get: - tags: - - pet - summary: Finds Pets by tags + deprecated: true description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. operationId: find_pets_by_tags parameters: - - name: tags + - description: Tags to filter by + explode: false in: query - description: Tags to filter by + name: tags required: true - style: form - explode: false schema: - type: array items: type: string + type: array + style: form responses: 200: - description: successful operation content: application/xml: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array + description: successful operation 400: + content: {} description: Invalid tag value - deprecated: true security: - petstore_auth: - write:pets - read:pets + summary: Finds Pets by tags + tags: + - pet x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/{petId}: - get: + delete: + operationId: delete_pet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + 400: + content: {} + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet tags: - pet - summary: Find pet by ID + x-openapi-router-controller: openapi_server.controllers.pet_controller + get: description: Returns a single pet operationId: get_pet_by_id parameters: - - name: petId + - description: ID of pet to return in: path - description: ID of pet to return + name: petId required: true - style: simple - explode: false schema: - type: integer format: int64 + type: integer responses: 200: - description: successful operation content: application/xml: schema: @@ -165,140 +204,122 @@ paths: application/json: schema: $ref: '#/components/schemas/Pet' + description: successful operation 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Pet not found security: - api_key: [] - x-openapi-router-controller: openapi_server.controllers.pet_controller - post: + summary: Find pet by ID tags: - pet - summary: Updates a pet in the store with form data + x-openapi-router-controller: openapi_server.controllers.pet_controller + post: operationId: update_pet_with_form parameters: - - name: petId + - description: ID of pet that needs to be updated in: path - description: ID of pet that needs to be updated + name: petId required: true - style: simple - explode: false schema: - type: integer format: int64 + type: integer requestBody: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/body' + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string responses: 405: + content: {} description: Invalid input security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: openapi_server.controllers.pet_controller - delete: + summary: Updates a pet in the store with form data tags: - pet - summary: Deletes a pet - operationId: delete_pet - parameters: - - name: api_key - in: header - required: false - style: simple - explode: false - schema: - type: string - - name: petId - in: path - description: Pet id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - 400: - description: Invalid pet value - security: - - petstore_auth: - - write:pets - - read:pets x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/{petId}/uploadImage: post: - tags: - - pet - summary: uploads an image operationId: upload_file parameters: - - name: petId + - description: ID of pet to update in: path - description: ID of pet to update + name: petId required: true - style: simple - explode: false schema: - type: integer format: int64 + type: integer requestBody: content: multipart/form-data: schema: - $ref: '#/components/schemas/body_1' + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string responses: 200: - description: successful operation content: application/json: schema: $ref: '#/components/schemas/ApiResponse' + description: successful operation security: - petstore_auth: - write:pets - read:pets + summary: uploads an image + tags: + - pet x-openapi-router-controller: openapi_server.controllers.pet_controller /store/inventory: get: - tags: - - store - summary: Returns pet inventories by status description: Returns a map of status codes to quantities operationId: get_inventory responses: 200: - description: successful operation content: application/json: schema: - type: object additionalProperties: - type: integer format: int32 + type: integer + type: object + description: successful operation security: - api_key: [] + summary: Returns pet inventories by status + tags: + - store x-openapi-router-controller: openapi_server.controllers.store_controller /store/order: post: - tags: - - store - summary: Place an order for a pet operationId: place_order requestBody: - description: order placed for purchasing the pet content: - application/json: + '*/*': schema: $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet required: true responses: 200: - description: successful operation content: application/xml: schema: @@ -306,31 +327,51 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: + content: {} description: Invalid Order + summary: Place an order for a pet + tags: + - store x-openapi-router-controller: openapi_server.controllers.store_controller /store/order/{orderId}: - get: + delete: + description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + operationId: delete_order + parameters: + - description: ID of the order that needs to be deleted + in: path + name: orderId + required: true + schema: + type: string + responses: + 400: + content: {} + description: Invalid ID supplied + 404: + content: {} + description: Order not found + summary: Delete purchase order by ID tags: - store - summary: Find purchase order by ID + x-openapi-router-controller: openapi_server.controllers.store_controller + get: description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions operationId: get_order_by_id parameters: - - name: orderId + - description: ID of pet that needs to be fetched in: path - description: ID of pet that needs to be fetched + name: orderId required: true - style: simple - explode: false schema: + format: int64 maximum: 5 minimum: 1 type: integer - format: int64 responses: 200: - description: successful operation content: application/xml: schema: @@ -338,153 +379,164 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Order not found - x-openapi-router-controller: openapi_server.controllers.store_controller - delete: + summary: Find purchase order by ID tags: - store - summary: Delete purchase order by ID - description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - operationId: delete_order - parameters: - - name: orderId - in: path - description: ID of the order that needs to be deleted - required: true - style: simple - explode: false - schema: - type: string - responses: - 400: - description: Invalid ID supplied - 404: - description: Order not found x-openapi-router-controller: openapi_server.controllers.store_controller /user: post: - tags: - - user - summary: Create user description: This can only be done by the logged in user. operationId: create_user requestBody: - description: Created user object content: - application/json: + '*/*': schema: $ref: '#/components/schemas/User' + description: Created user object required: true responses: default: + content: {} description: successful operation + summary: Create user + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/createWithArray: post: - tags: - - user - summary: Creates list of users with given input array operationId: create_users_with_array_input requestBody: - $ref: '#/components/requestBodies/UserArray' + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true responses: default: + content: {} description: successful operation + summary: Creates list of users with given input array + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/createWithList: post: - tags: - - user - summary: Creates list of users with given input array operationId: create_users_with_list_input requestBody: - $ref: '#/components/requestBodies/UserArray' + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true responses: default: + content: {} description: successful operation + summary: Creates list of users with given input array + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/login: get: - tags: - - user - summary: Logs user into the system operationId: login_user parameters: - - name: username + - description: The user name for login in: query - description: The user name for login + name: username required: true - style: form - explode: true schema: type: string - - name: password + - description: The password for login in clear text in: query - description: The password for login in clear text + name: password required: true - style: form - explode: true schema: type: string responses: 200: + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string description: successful operation headers: X-Rate-Limit: description: calls per hour allowed by the user - style: simple - explode: false schema: - type: integer format: int32 + type: integer X-Expires-After: description: date in UTC when toekn expires - style: simple - explode: false schema: - type: string format: date-time - content: - application/xml: - schema: - type: string - application/json: - schema: type: string 400: + content: {} description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/logout: get: - tags: - - user - summary: Logs out current logged in user session operationId: logout_user responses: default: + content: {} description: successful operation + summary: Logs out current logged in user session + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/{username}: - get: + delete: + description: This can only be done by the logged in user. + operationId: delete_user + parameters: + - description: The name that needs to be deleted + in: path + name: username + required: true + schema: + type: string + responses: + 400: + content: {} + description: Invalid username supplied + 404: + content: {} + description: User not found + summary: Delete user tags: - user - summary: Get user by user name + x-openapi-router-controller: openapi_server.controllers.user_controller + get: operationId: get_user_by_name parameters: - - name: username + - description: The name that needs to be fetched. Use user1 for testing. in: path - description: The name that needs to be fetched. Use user1 for testing. + name: username required: true - style: simple - explode: false schema: type: string responses: 200: - description: successful operation content: application/xml: schema: @@ -492,120 +544,113 @@ paths: application/json: schema: $ref: '#/components/schemas/User' + description: successful operation 400: + content: {} description: Invalid username supplied 404: + content: {} description: User not found - x-openapi-router-controller: openapi_server.controllers.user_controller - put: + summary: Get user by user name tags: - user - summary: Updated user + x-openapi-router-controller: openapi_server.controllers.user_controller + put: description: This can only be done by the logged in user. operationId: update_user parameters: - - name: username + - description: name that need to be deleted in: path - description: name that need to be deleted + name: username required: true - style: simple - explode: false schema: type: string requestBody: - description: Updated user object content: - application/json: + '*/*': schema: $ref: '#/components/schemas/User' + description: Updated user object required: true responses: 400: + content: {} description: Invalid user supplied 404: + content: {} description: User not found - x-openapi-router-controller: openapi_server.controllers.user_controller - delete: + summary: Updated user tags: - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: delete_user - parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - style: simple - explode: false - schema: - type: string - responses: - 400: - description: Invalid username supplied - 404: - description: User not found x-openapi-router-controller: openapi_server.controllers.user_controller components: schemas: Order: - title: Pet Order - type: object + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed properties: id: - type: integer format: int64 - petId: type: integer + petId: format: int64 - quantity: type: integer + quantity: format: int32 + type: integer shipDate: - type: string format: date-time - status: type: string + status: description: Order Status enum: - placed - approved - delivered + type: string complete: - type: boolean default: false - description: An order for a pets from the pet store - example: - petId: 6 - quantity: 1 - id: 0 - shipDate: 2000-01-23T04:56:07.000+00:00 - complete: false - status: placed + type: boolean + title: Pet Order + type: object xml: name: Order Category: - title: Pet category - type: object + description: A category for a pet + example: + name: name + id: 6 properties: id: - type: integer format: int64 + type: integer name: type: string - description: A category for a pet - example: - name: name - id: 6 + title: Pet category + type: object xml: name: Category User: - title: a User - type: object + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username properties: id: - type: integer format: int64 + type: integer username: type: string firstName: @@ -619,155 +664,108 @@ components: phone: type: string userStatus: - type: integer description: User Status format: int32 - description: A User who is purchasing from the pet store - example: - firstName: firstName - lastName: lastName - password: password - userStatus: 6 - phone: phone - id: 0 - email: email - username: username + type: integer + title: a User + type: object xml: name: User Tag: - title: Pet Tag - type: object + description: A tag for a pet + example: + name: name + id: 1 properties: id: - type: integer format: int64 + type: integer name: type: string - description: A tag for a pet - example: - name: name - id: 1 + title: Pet Tag + type: object xml: name: Tag Pet: - title: a Pet - required: - - name - - photoUrls - type: object + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available properties: id: - type: integer format: int64 + type: integer category: $ref: '#/components/schemas/Category' name: - type: string example: doggie + type: string photoUrls: + items: + type: string type: array xml: name: photoUrl wrapped: true - items: - type: string tags: + items: + $ref: '#/components/schemas/Tag' type: array xml: name: tag wrapped: true - items: - $ref: '#/components/schemas/Tag' status: - type: string description: pet status in the store enum: - available - pending - sold - description: A pet for sale in the pet store - example: - photoUrls: - - photoUrls - - photoUrls - name: doggie - id: 0 - category: - name: name - id: 6 - tags: - - name: name - id: 1 - - name: name - id: 1 - status: available + type: string + required: + - name + - photoUrls + title: a Pet + type: object xml: name: Pet ApiResponse: - title: An uploaded response - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string description: Describes the result of uploading an image resource example: code: 0 type: type message: message - body: - type: object properties: - name: + code: + format: int32 + type: integer + type: type: string - description: Updated name of the pet - status: + message: type: string - description: Updated status of the pet - body_1: + title: An uploaded response type: object - properties: - additionalMetadata: - type: string - description: Additional data to pass to server - file: - type: string - description: file to upload - format: binary - requestBodies: - UserArray: - description: List of user object - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true - Pet: - description: Pet object that needs to be added to the store - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - required: true securitySchemes: petstore_auth: - type: oauth2 flows: implicit: authorizationUrl: http://petstore.swagger.io/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets + type: oauth2 api_key: - type: apiKey - name: api_key in: header + name: api_key + type: apiKey diff --git a/samples/server/petstore/flaskConnexion-python2/openapi_server/util.py b/samples/server/petstore/flaskConnexion-python2/openapi_server/util.py index 4321570d5a0e..c7340cd00059 100644 --- a/samples/server/petstore/flaskConnexion-python2/openapi_server/util.py +++ b/samples/server/petstore/flaskConnexion-python2/openapi_server/util.py @@ -51,7 +51,7 @@ def _deserialize_primitive(data, klass): def _deserialize_object(value): - """Return a original value. + """Return an original value. :return: object. """ diff --git a/samples/server/petstore/flaskConnexion/.openapi-generator/VERSION b/samples/server/petstore/flaskConnexion/.openapi-generator/VERSION index 096bf47efe31..6d94c9c2e12a 100644 --- a/samples/server/petstore/flaskConnexion/.openapi-generator/VERSION +++ b/samples/server/petstore/flaskConnexion/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +3.3.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/flaskConnexion/openapi_server/models/api_response.py b/samples/server/petstore/flaskConnexion/openapi_server/models/api_response.py index 8d4483699ef9..974c29c6a552 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/models/api_response.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/models/api_response.py @@ -15,7 +15,7 @@ class ApiResponse(Model): Do not edit the class manually. """ - def __init__(self, code: int=None, type: str=None, message: str=None): # noqa: E501 + def __init__(self, code=None, type=None, message=None): # noqa: E501 """ApiResponse - a model defined in OpenAPI :param code: The code of this ApiResponse. # noqa: E501 @@ -26,9 +26,9 @@ def __init__(self, code: int=None, type: str=None, message: str=None): # noqa: :type message: str """ self.openapi_types = { - 'code': int, - 'type': str, - 'message': str + 'code': 'int', + 'type': 'str', + 'message': 'str' } self.attribute_map = { @@ -53,7 +53,7 @@ def from_dict(cls, dikt) -> 'ApiResponse': return util.deserialize_model(dikt, cls) @property - def code(self) -> int: + def code(self): """Gets the code of this ApiResponse. @@ -63,7 +63,7 @@ def code(self) -> int: return self._code @code.setter - def code(self, code: int): + def code(self, code): """Sets the code of this ApiResponse. @@ -74,7 +74,7 @@ def code(self, code: int): self._code = code @property - def type(self) -> str: + def type(self): """Gets the type of this ApiResponse. @@ -84,7 +84,7 @@ def type(self) -> str: return self._type @type.setter - def type(self, type: str): + def type(self, type): """Sets the type of this ApiResponse. @@ -95,7 +95,7 @@ def type(self, type: str): self._type = type @property - def message(self) -> str: + def message(self): """Gets the message of this ApiResponse. @@ -105,7 +105,7 @@ def message(self) -> str: return self._message @message.setter - def message(self, message: str): + def message(self, message): """Sets the message of this ApiResponse. diff --git a/samples/server/petstore/flaskConnexion/openapi_server/models/category.py b/samples/server/petstore/flaskConnexion/openapi_server/models/category.py index 5f4ecd5c8ac7..65ec5bd38866 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/models/category.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/models/category.py @@ -15,7 +15,7 @@ class Category(Model): Do not edit the class manually. """ - def __init__(self, id: int=None, name: str=None): # noqa: E501 + def __init__(self, id=None, name=None): # noqa: E501 """Category - a model defined in OpenAPI :param id: The id of this Category. # noqa: E501 @@ -24,8 +24,8 @@ def __init__(self, id: int=None, name: str=None): # noqa: E501 :type name: str """ self.openapi_types = { - 'id': int, - 'name': str + 'id': 'int', + 'name': 'str' } self.attribute_map = { @@ -48,7 +48,7 @@ def from_dict(cls, dikt) -> 'Category': return util.deserialize_model(dikt, cls) @property - def id(self) -> int: + def id(self): """Gets the id of this Category. @@ -58,7 +58,7 @@ def id(self) -> int: return self._id @id.setter - def id(self, id: int): + def id(self, id): """Sets the id of this Category. @@ -69,7 +69,7 @@ def id(self, id: int): self._id = id @property - def name(self) -> str: + def name(self): """Gets the name of this Category. @@ -79,7 +79,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, name: str): + def name(self, name): """Sets the name of this Category. diff --git a/samples/server/petstore/flaskConnexion/openapi_server/models/order.py b/samples/server/petstore/flaskConnexion/openapi_server/models/order.py index b0587cbe685b..b0bbdd9d5035 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/models/order.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/models/order.py @@ -15,7 +15,7 @@ class Order(Model): Do not edit the class manually. """ - def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date: datetime=None, status: str=None, complete: bool=False): # noqa: E501 + def __init__(self, id=None, pet_id=None, quantity=None, ship_date=None, status=None, complete=False): # noqa: E501 """Order - a model defined in OpenAPI :param id: The id of this Order. # noqa: E501 @@ -32,12 +32,12 @@ def __init__(self, id: int=None, pet_id: int=None, quantity: int=None, ship_date :type complete: bool """ self.openapi_types = { - 'id': int, - 'pet_id': int, - 'quantity': int, - 'ship_date': datetime, - 'status': str, - 'complete': bool + 'id': 'int', + 'pet_id': 'int', + 'quantity': 'int', + 'ship_date': 'datetime', + 'status': 'str', + 'complete': 'bool' } self.attribute_map = { @@ -68,7 +68,7 @@ def from_dict(cls, dikt) -> 'Order': return util.deserialize_model(dikt, cls) @property - def id(self) -> int: + def id(self): """Gets the id of this Order. @@ -78,7 +78,7 @@ def id(self) -> int: return self._id @id.setter - def id(self, id: int): + def id(self, id): """Sets the id of this Order. @@ -89,7 +89,7 @@ def id(self, id: int): self._id = id @property - def pet_id(self) -> int: + def pet_id(self): """Gets the pet_id of this Order. @@ -99,7 +99,7 @@ def pet_id(self) -> int: return self._pet_id @pet_id.setter - def pet_id(self, pet_id: int): + def pet_id(self, pet_id): """Sets the pet_id of this Order. @@ -110,7 +110,7 @@ def pet_id(self, pet_id: int): self._pet_id = pet_id @property - def quantity(self) -> int: + def quantity(self): """Gets the quantity of this Order. @@ -120,7 +120,7 @@ def quantity(self) -> int: return self._quantity @quantity.setter - def quantity(self, quantity: int): + def quantity(self, quantity): """Sets the quantity of this Order. @@ -131,7 +131,7 @@ def quantity(self, quantity: int): self._quantity = quantity @property - def ship_date(self) -> datetime: + def ship_date(self): """Gets the ship_date of this Order. @@ -141,7 +141,7 @@ def ship_date(self) -> datetime: return self._ship_date @ship_date.setter - def ship_date(self, ship_date: datetime): + def ship_date(self, ship_date): """Sets the ship_date of this Order. @@ -152,7 +152,7 @@ def ship_date(self, ship_date: datetime): self._ship_date = ship_date @property - def status(self) -> str: + def status(self): """Gets the status of this Order. Order Status # noqa: E501 @@ -163,7 +163,7 @@ def status(self) -> str: return self._status @status.setter - def status(self, status: str): + def status(self, status): """Sets the status of this Order. Order Status # noqa: E501 @@ -181,7 +181,7 @@ def status(self, status: str): self._status = status @property - def complete(self) -> bool: + def complete(self): """Gets the complete of this Order. @@ -191,7 +191,7 @@ def complete(self) -> bool: return self._complete @complete.setter - def complete(self, complete: bool): + def complete(self, complete): """Sets the complete of this Order. diff --git a/samples/server/petstore/flaskConnexion/openapi_server/models/pet.py b/samples/server/petstore/flaskConnexion/openapi_server/models/pet.py index 7557b576150d..7b384ad983f8 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/models/pet.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/models/pet.py @@ -6,8 +6,6 @@ from typing import List, Dict # noqa: F401 from openapi_server.models.base_model_ import Model -from openapi_server.models.category import Category # noqa: F401,E501 -from openapi_server.models.tag import Tag # noqa: F401,E501 from openapi_server import util @@ -17,7 +15,7 @@ class Pet(Model): Do not edit the class manually. """ - def __init__(self, id: int=None, category: Category=None, name: str=None, photo_urls: List[str]=None, tags: List[Tag]=None, status: str=None): # noqa: E501 + def __init__(self, id=None, category=None, name=None, photo_urls=None, tags=None, status=None): # noqa: E501 """Pet - a model defined in OpenAPI :param id: The id of this Pet. # noqa: E501 @@ -34,12 +32,12 @@ def __init__(self, id: int=None, category: Category=None, name: str=None, photo_ :type status: str """ self.openapi_types = { - 'id': int, - 'category': Category, - 'name': str, - 'photo_urls': List[str], - 'tags': List[Tag], - 'status': str + 'id': 'int', + 'category': 'Category', + 'name': 'str', + 'photo_urls': 'List[str]', + 'tags': 'List[Tag]', + 'status': 'str' } self.attribute_map = { @@ -70,7 +68,7 @@ def from_dict(cls, dikt) -> 'Pet': return util.deserialize_model(dikt, cls) @property - def id(self) -> int: + def id(self): """Gets the id of this Pet. @@ -80,7 +78,7 @@ def id(self) -> int: return self._id @id.setter - def id(self, id: int): + def id(self, id): """Sets the id of this Pet. @@ -91,7 +89,7 @@ def id(self, id: int): self._id = id @property - def category(self) -> Category: + def category(self): """Gets the category of this Pet. @@ -101,7 +99,7 @@ def category(self) -> Category: return self._category @category.setter - def category(self, category: Category): + def category(self, category): """Sets the category of this Pet. @@ -112,7 +110,7 @@ def category(self, category: Category): self._category = category @property - def name(self) -> str: + def name(self): """Gets the name of this Pet. @@ -122,7 +120,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, name: str): + def name(self, name): """Sets the name of this Pet. @@ -135,7 +133,7 @@ def name(self, name: str): self._name = name @property - def photo_urls(self) -> List[str]: + def photo_urls(self): """Gets the photo_urls of this Pet. @@ -145,7 +143,7 @@ def photo_urls(self) -> List[str]: return self._photo_urls @photo_urls.setter - def photo_urls(self, photo_urls: List[str]): + def photo_urls(self, photo_urls): """Sets the photo_urls of this Pet. @@ -158,7 +156,7 @@ def photo_urls(self, photo_urls: List[str]): self._photo_urls = photo_urls @property - def tags(self) -> List[Tag]: + def tags(self): """Gets the tags of this Pet. @@ -168,7 +166,7 @@ def tags(self) -> List[Tag]: return self._tags @tags.setter - def tags(self, tags: List[Tag]): + def tags(self, tags): """Sets the tags of this Pet. @@ -179,7 +177,7 @@ def tags(self, tags: List[Tag]): self._tags = tags @property - def status(self) -> str: + def status(self): """Gets the status of this Pet. pet status in the store # noqa: E501 @@ -190,7 +188,7 @@ def status(self) -> str: return self._status @status.setter - def status(self, status: str): + def status(self, status): """Sets the status of this Pet. pet status in the store # noqa: E501 diff --git a/samples/server/petstore/flaskConnexion/openapi_server/models/tag.py b/samples/server/petstore/flaskConnexion/openapi_server/models/tag.py index dbf79c3a2afc..06063ede9346 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/models/tag.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/models/tag.py @@ -15,7 +15,7 @@ class Tag(Model): Do not edit the class manually. """ - def __init__(self, id: int=None, name: str=None): # noqa: E501 + def __init__(self, id=None, name=None): # noqa: E501 """Tag - a model defined in OpenAPI :param id: The id of this Tag. # noqa: E501 @@ -24,8 +24,8 @@ def __init__(self, id: int=None, name: str=None): # noqa: E501 :type name: str """ self.openapi_types = { - 'id': int, - 'name': str + 'id': 'int', + 'name': 'str' } self.attribute_map = { @@ -48,7 +48,7 @@ def from_dict(cls, dikt) -> 'Tag': return util.deserialize_model(dikt, cls) @property - def id(self) -> int: + def id(self): """Gets the id of this Tag. @@ -58,7 +58,7 @@ def id(self) -> int: return self._id @id.setter - def id(self, id: int): + def id(self, id): """Sets the id of this Tag. @@ -69,7 +69,7 @@ def id(self, id: int): self._id = id @property - def name(self) -> str: + def name(self): """Gets the name of this Tag. @@ -79,7 +79,7 @@ def name(self) -> str: return self._name @name.setter - def name(self, name: str): + def name(self, name): """Sets the name of this Tag. diff --git a/samples/server/petstore/flaskConnexion/openapi_server/models/user.py b/samples/server/petstore/flaskConnexion/openapi_server/models/user.py index 048551da85cf..59b3c6a50b80 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/models/user.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/models/user.py @@ -15,7 +15,7 @@ class User(Model): Do not edit the class manually. """ - def __init__(self, id: int=None, username: str=None, first_name: str=None, last_name: str=None, email: str=None, password: str=None, phone: str=None, user_status: int=None): # noqa: E501 + def __init__(self, id=None, username=None, first_name=None, last_name=None, email=None, password=None, phone=None, user_status=None): # noqa: E501 """User - a model defined in OpenAPI :param id: The id of this User. # noqa: E501 @@ -36,14 +36,14 @@ def __init__(self, id: int=None, username: str=None, first_name: str=None, last_ :type user_status: int """ self.openapi_types = { - 'id': int, - 'username': str, - 'first_name': str, - 'last_name': str, - 'email': str, - 'password': str, - 'phone': str, - 'user_status': int + 'id': 'int', + 'username': 'str', + 'first_name': 'str', + 'last_name': 'str', + 'email': 'str', + 'password': 'str', + 'phone': 'str', + 'user_status': 'int' } self.attribute_map = { @@ -78,7 +78,7 @@ def from_dict(cls, dikt) -> 'User': return util.deserialize_model(dikt, cls) @property - def id(self) -> int: + def id(self): """Gets the id of this User. @@ -88,7 +88,7 @@ def id(self) -> int: return self._id @id.setter - def id(self, id: int): + def id(self, id): """Sets the id of this User. @@ -99,7 +99,7 @@ def id(self, id: int): self._id = id @property - def username(self) -> str: + def username(self): """Gets the username of this User. @@ -109,7 +109,7 @@ def username(self) -> str: return self._username @username.setter - def username(self, username: str): + def username(self, username): """Sets the username of this User. @@ -120,7 +120,7 @@ def username(self, username: str): self._username = username @property - def first_name(self) -> str: + def first_name(self): """Gets the first_name of this User. @@ -130,7 +130,7 @@ def first_name(self) -> str: return self._first_name @first_name.setter - def first_name(self, first_name: str): + def first_name(self, first_name): """Sets the first_name of this User. @@ -141,7 +141,7 @@ def first_name(self, first_name: str): self._first_name = first_name @property - def last_name(self) -> str: + def last_name(self): """Gets the last_name of this User. @@ -151,7 +151,7 @@ def last_name(self) -> str: return self._last_name @last_name.setter - def last_name(self, last_name: str): + def last_name(self, last_name): """Sets the last_name of this User. @@ -162,7 +162,7 @@ def last_name(self, last_name: str): self._last_name = last_name @property - def email(self) -> str: + def email(self): """Gets the email of this User. @@ -172,7 +172,7 @@ def email(self) -> str: return self._email @email.setter - def email(self, email: str): + def email(self, email): """Sets the email of this User. @@ -183,7 +183,7 @@ def email(self, email: str): self._email = email @property - def password(self) -> str: + def password(self): """Gets the password of this User. @@ -193,7 +193,7 @@ def password(self) -> str: return self._password @password.setter - def password(self, password: str): + def password(self, password): """Sets the password of this User. @@ -204,7 +204,7 @@ def password(self, password: str): self._password = password @property - def phone(self) -> str: + def phone(self): """Gets the phone of this User. @@ -214,7 +214,7 @@ def phone(self) -> str: return self._phone @phone.setter - def phone(self, phone: str): + def phone(self, phone): """Sets the phone of this User. @@ -225,7 +225,7 @@ def phone(self, phone: str): self._phone = phone @property - def user_status(self) -> int: + def user_status(self): """Gets the user_status of this User. User Status # noqa: E501 @@ -236,7 +236,7 @@ def user_status(self) -> int: return self._user_status @user_status.setter - def user_status(self, user_status: int): + def user_status(self, user_status): """Sets the user_status of this User. User Status # noqa: E501 diff --git a/samples/server/petstore/flaskConnexion/openapi_server/openapi/openapi.yaml b/samples/server/petstore/flaskConnexion/openapi_server/openapi/openapi.yaml index cc02c545f9a5..dca523e5557c 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/openapi/openapi.yaml +++ b/samples/server/petstore/flaskConnexion/openapi_server/openapi/openapi.yaml @@ -1,163 +1,202 @@ -openapi: 3.0.0 +openapi: 3.0.1 info: - title: OpenAPI Petstore description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. license: name: Apache-2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html + title: OpenAPI Petstore version: 1.0.0 -externalDocs: - description: Find out more about Swagger - url: http://swagger.io servers: - url: http://petstore.swagger.io/v2 tags: -- name: pet - description: Everything about your Pets -- name: store - description: Access to Petstore orders -- name: user - description: Operations about user +- description: Everything about your Pets + name: pet +- description: Access to Petstore orders + name: store +- description: Operations about user + name: user paths: /pet: - put: + post: + operationId: add_pet + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true + responses: + 405: + content: {} + description: Invalid input + security: + - petstore_auth: + - write:pets + - read:pets + summary: Add a new pet to the store tags: - pet - summary: Update an existing pet + x-openapi-router-controller: openapi_server.controllers.pet_controller + put: operationId: update_pet requestBody: - $ref: '#/components/requestBodies/Pet' + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + application/xml: + schema: + $ref: '#/components/schemas/Pet' + description: Pet object that needs to be added to the store + required: true responses: 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Pet not found 405: + content: {} description: Validation exception security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: openapi_server.controllers.pet_controller - post: + summary: Update an existing pet tags: - pet - summary: Add a new pet to the store - operationId: add_pet - requestBody: - $ref: '#/components/requestBodies/Pet' - responses: - 405: - description: Invalid input - security: - - petstore_auth: - - write:pets - - read:pets x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/findByStatus: get: - tags: - - pet - summary: Finds Pets by status description: Multiple status values can be provided with comma separated strings operationId: find_pets_by_status parameters: - - name: status + - description: Status values that need to be considered for filter + explode: false in: query - description: Status values that need to be considered for filter + name: status required: true - style: form - explode: false schema: - type: array items: - type: string default: available enum: - available - pending - sold + type: string + type: array + style: form responses: 200: - description: successful operation content: application/xml: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array + description: successful operation 400: + content: {} description: Invalid status value security: - petstore_auth: - write:pets - read:pets + summary: Finds Pets by status + tags: + - pet x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/findByTags: get: - tags: - - pet - summary: Finds Pets by tags + deprecated: true description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. operationId: find_pets_by_tags parameters: - - name: tags + - description: Tags to filter by + explode: false in: query - description: Tags to filter by + name: tags required: true - style: form - explode: false schema: - type: array items: type: string + type: array + style: form responses: 200: - description: successful operation content: application/xml: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array application/json: schema: - type: array items: $ref: '#/components/schemas/Pet' + type: array + description: successful operation 400: + content: {} description: Invalid tag value - deprecated: true security: - petstore_auth: - write:pets - read:pets + summary: Finds Pets by tags + tags: + - pet x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/{petId}: - get: + delete: + operationId: delete_pet + parameters: + - in: header + name: api_key + schema: + type: string + - description: Pet id to delete + in: path + name: petId + required: true + schema: + format: int64 + type: integer + responses: + 400: + content: {} + description: Invalid pet value + security: + - petstore_auth: + - write:pets + - read:pets + summary: Deletes a pet tags: - pet - summary: Find pet by ID + x-openapi-router-controller: openapi_server.controllers.pet_controller + get: description: Returns a single pet operationId: get_pet_by_id parameters: - - name: petId + - description: ID of pet to return in: path - description: ID of pet to return + name: petId required: true - style: simple - explode: false schema: - type: integer format: int64 + type: integer responses: 200: - description: successful operation content: application/xml: schema: @@ -165,140 +204,122 @@ paths: application/json: schema: $ref: '#/components/schemas/Pet' + description: successful operation 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Pet not found security: - api_key: [] - x-openapi-router-controller: openapi_server.controllers.pet_controller - post: + summary: Find pet by ID tags: - pet - summary: Updates a pet in the store with form data + x-openapi-router-controller: openapi_server.controllers.pet_controller + post: operationId: update_pet_with_form parameters: - - name: petId + - description: ID of pet that needs to be updated in: path - description: ID of pet that needs to be updated + name: petId required: true - style: simple - explode: false schema: - type: integer format: int64 + type: integer requestBody: content: application/x-www-form-urlencoded: schema: - $ref: '#/components/schemas/body' + properties: + name: + description: Updated name of the pet + type: string + status: + description: Updated status of the pet + type: string responses: 405: + content: {} description: Invalid input security: - petstore_auth: - write:pets - read:pets - x-openapi-router-controller: openapi_server.controllers.pet_controller - delete: + summary: Updates a pet in the store with form data tags: - pet - summary: Deletes a pet - operationId: delete_pet - parameters: - - name: api_key - in: header - required: false - style: simple - explode: false - schema: - type: string - - name: petId - in: path - description: Pet id to delete - required: true - style: simple - explode: false - schema: - type: integer - format: int64 - responses: - 400: - description: Invalid pet value - security: - - petstore_auth: - - write:pets - - read:pets x-openapi-router-controller: openapi_server.controllers.pet_controller /pet/{petId}/uploadImage: post: - tags: - - pet - summary: uploads an image operationId: upload_file parameters: - - name: petId + - description: ID of pet to update in: path - description: ID of pet to update + name: petId required: true - style: simple - explode: false schema: - type: integer format: int64 + type: integer requestBody: content: multipart/form-data: schema: - $ref: '#/components/schemas/body_1' + properties: + additionalMetadata: + description: Additional data to pass to server + type: string + file: + description: file to upload + format: binary + type: string responses: 200: - description: successful operation content: application/json: schema: $ref: '#/components/schemas/ApiResponse' + description: successful operation security: - petstore_auth: - write:pets - read:pets + summary: uploads an image + tags: + - pet x-openapi-router-controller: openapi_server.controllers.pet_controller /store/inventory: get: - tags: - - store - summary: Returns pet inventories by status description: Returns a map of status codes to quantities operationId: get_inventory responses: 200: - description: successful operation content: application/json: schema: - type: object additionalProperties: - type: integer format: int32 + type: integer + type: object + description: successful operation security: - api_key: [] + summary: Returns pet inventories by status + tags: + - store x-openapi-router-controller: openapi_server.controllers.store_controller /store/order: post: - tags: - - store - summary: Place an order for a pet operationId: place_order requestBody: - description: order placed for purchasing the pet content: - application/json: + '*/*': schema: $ref: '#/components/schemas/Order' + description: order placed for purchasing the pet required: true responses: 200: - description: successful operation content: application/xml: schema: @@ -306,31 +327,51 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: + content: {} description: Invalid Order + summary: Place an order for a pet + tags: + - store x-openapi-router-controller: openapi_server.controllers.store_controller /store/order/{orderId}: - get: + delete: + description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + operationId: delete_order + parameters: + - description: ID of the order that needs to be deleted + in: path + name: orderId + required: true + schema: + type: string + responses: + 400: + content: {} + description: Invalid ID supplied + 404: + content: {} + description: Order not found + summary: Delete purchase order by ID tags: - store - summary: Find purchase order by ID + x-openapi-router-controller: openapi_server.controllers.store_controller + get: description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions operationId: get_order_by_id parameters: - - name: orderId + - description: ID of pet that needs to be fetched in: path - description: ID of pet that needs to be fetched + name: orderId required: true - style: simple - explode: false schema: + format: int64 maximum: 5 minimum: 1 type: integer - format: int64 responses: 200: - description: successful operation content: application/xml: schema: @@ -338,153 +379,164 @@ paths: application/json: schema: $ref: '#/components/schemas/Order' + description: successful operation 400: + content: {} description: Invalid ID supplied 404: + content: {} description: Order not found - x-openapi-router-controller: openapi_server.controllers.store_controller - delete: + summary: Find purchase order by ID tags: - store - summary: Delete purchase order by ID - description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors - operationId: delete_order - parameters: - - name: orderId - in: path - description: ID of the order that needs to be deleted - required: true - style: simple - explode: false - schema: - type: string - responses: - 400: - description: Invalid ID supplied - 404: - description: Order not found x-openapi-router-controller: openapi_server.controllers.store_controller /user: post: - tags: - - user - summary: Create user description: This can only be done by the logged in user. operationId: create_user requestBody: - description: Created user object content: - application/json: + '*/*': schema: $ref: '#/components/schemas/User' + description: Created user object required: true responses: default: + content: {} description: successful operation + summary: Create user + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/createWithArray: post: - tags: - - user - summary: Creates list of users with given input array operationId: create_users_with_array_input requestBody: - $ref: '#/components/requestBodies/UserArray' + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true responses: default: + content: {} description: successful operation + summary: Creates list of users with given input array + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/createWithList: post: - tags: - - user - summary: Creates list of users with given input array operationId: create_users_with_list_input requestBody: - $ref: '#/components/requestBodies/UserArray' + content: + '*/*': + schema: + items: + $ref: '#/components/schemas/User' + type: array + description: List of user object + required: true responses: default: + content: {} description: successful operation + summary: Creates list of users with given input array + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/login: get: - tags: - - user - summary: Logs user into the system operationId: login_user parameters: - - name: username + - description: The user name for login in: query - description: The user name for login + name: username required: true - style: form - explode: true schema: type: string - - name: password + - description: The password for login in clear text in: query - description: The password for login in clear text + name: password required: true - style: form - explode: true schema: type: string responses: 200: + content: + application/xml: + schema: + type: string + application/json: + schema: + type: string description: successful operation headers: X-Rate-Limit: description: calls per hour allowed by the user - style: simple - explode: false schema: - type: integer format: int32 + type: integer X-Expires-After: description: date in UTC when toekn expires - style: simple - explode: false schema: - type: string format: date-time - content: - application/xml: - schema: - type: string - application/json: - schema: type: string 400: + content: {} description: Invalid username/password supplied + summary: Logs user into the system + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/logout: get: - tags: - - user - summary: Logs out current logged in user session operationId: logout_user responses: default: + content: {} description: successful operation + summary: Logs out current logged in user session + tags: + - user x-openapi-router-controller: openapi_server.controllers.user_controller /user/{username}: - get: + delete: + description: This can only be done by the logged in user. + operationId: delete_user + parameters: + - description: The name that needs to be deleted + in: path + name: username + required: true + schema: + type: string + responses: + 400: + content: {} + description: Invalid username supplied + 404: + content: {} + description: User not found + summary: Delete user tags: - user - summary: Get user by user name + x-openapi-router-controller: openapi_server.controllers.user_controller + get: operationId: get_user_by_name parameters: - - name: username + - description: The name that needs to be fetched. Use user1 for testing. in: path - description: The name that needs to be fetched. Use user1 for testing. + name: username required: true - style: simple - explode: false schema: type: string responses: 200: - description: successful operation content: application/xml: schema: @@ -492,120 +544,113 @@ paths: application/json: schema: $ref: '#/components/schemas/User' + description: successful operation 400: + content: {} description: Invalid username supplied 404: + content: {} description: User not found - x-openapi-router-controller: openapi_server.controllers.user_controller - put: + summary: Get user by user name tags: - user - summary: Updated user + x-openapi-router-controller: openapi_server.controllers.user_controller + put: description: This can only be done by the logged in user. operationId: update_user parameters: - - name: username + - description: name that need to be deleted in: path - description: name that need to be deleted + name: username required: true - style: simple - explode: false schema: type: string requestBody: - description: Updated user object content: - application/json: + '*/*': schema: $ref: '#/components/schemas/User' + description: Updated user object required: true responses: 400: + content: {} description: Invalid user supplied 404: + content: {} description: User not found - x-openapi-router-controller: openapi_server.controllers.user_controller - delete: + summary: Updated user tags: - user - summary: Delete user - description: This can only be done by the logged in user. - operationId: delete_user - parameters: - - name: username - in: path - description: The name that needs to be deleted - required: true - style: simple - explode: false - schema: - type: string - responses: - 400: - description: Invalid username supplied - 404: - description: User not found x-openapi-router-controller: openapi_server.controllers.user_controller components: schemas: Order: - title: Pet Order - type: object + description: An order for a pets from the pet store + example: + petId: 6 + quantity: 1 + id: 0 + shipDate: 2000-01-23T04:56:07.000+00:00 + complete: false + status: placed properties: id: - type: integer format: int64 - petId: type: integer + petId: format: int64 - quantity: type: integer + quantity: format: int32 + type: integer shipDate: - type: string format: date-time - status: type: string + status: description: Order Status enum: - placed - approved - delivered + type: string complete: - type: boolean default: false - description: An order for a pets from the pet store - example: - petId: 6 - quantity: 1 - id: 0 - shipDate: 2000-01-23T04:56:07.000+00:00 - complete: false - status: placed + type: boolean + title: Pet Order + type: object xml: name: Order Category: - title: Pet category - type: object + description: A category for a pet + example: + name: name + id: 6 properties: id: - type: integer format: int64 + type: integer name: type: string - description: A category for a pet - example: - name: name - id: 6 + title: Pet category + type: object xml: name: Category User: - title: a User - type: object + description: A User who is purchasing from the pet store + example: + firstName: firstName + lastName: lastName + password: password + userStatus: 6 + phone: phone + id: 0 + email: email + username: username properties: id: - type: integer format: int64 + type: integer username: type: string firstName: @@ -619,155 +664,108 @@ components: phone: type: string userStatus: - type: integer description: User Status format: int32 - description: A User who is purchasing from the pet store - example: - firstName: firstName - lastName: lastName - password: password - userStatus: 6 - phone: phone - id: 0 - email: email - username: username + type: integer + title: a User + type: object xml: name: User Tag: - title: Pet Tag - type: object + description: A tag for a pet + example: + name: name + id: 1 properties: id: - type: integer format: int64 + type: integer name: type: string - description: A tag for a pet - example: - name: name - id: 1 + title: Pet Tag + type: object xml: name: Tag Pet: - title: a Pet - required: - - name - - photoUrls - type: object + description: A pet for sale in the pet store + example: + photoUrls: + - photoUrls + - photoUrls + name: doggie + id: 0 + category: + name: name + id: 6 + tags: + - name: name + id: 1 + - name: name + id: 1 + status: available properties: id: - type: integer format: int64 + type: integer category: $ref: '#/components/schemas/Category' name: - type: string example: doggie + type: string photoUrls: + items: + type: string type: array xml: name: photoUrl wrapped: true - items: - type: string tags: + items: + $ref: '#/components/schemas/Tag' type: array xml: name: tag wrapped: true - items: - $ref: '#/components/schemas/Tag' status: - type: string description: pet status in the store enum: - available - pending - sold - description: A pet for sale in the pet store - example: - photoUrls: - - photoUrls - - photoUrls - name: doggie - id: 0 - category: - name: name - id: 6 - tags: - - name: name - id: 1 - - name: name - id: 1 - status: available + type: string + required: + - name + - photoUrls + title: a Pet + type: object xml: name: Pet ApiResponse: - title: An uploaded response - type: object - properties: - code: - type: integer - format: int32 - type: - type: string - message: - type: string description: Describes the result of uploading an image resource example: code: 0 type: type message: message - body: - type: object properties: - name: + code: + format: int32 + type: integer + type: type: string - description: Updated name of the pet - status: + message: type: string - description: Updated status of the pet - body_1: + title: An uploaded response type: object - properties: - additionalMetadata: - type: string - description: Additional data to pass to server - file: - type: string - description: file to upload - format: binary - requestBodies: - UserArray: - description: List of user object - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/User' - required: true - Pet: - description: Pet object that needs to be added to the store - content: - application/json: - schema: - $ref: '#/components/schemas/Pet' - application/xml: - schema: - $ref: '#/components/schemas/Pet' - required: true securitySchemes: petstore_auth: - type: oauth2 flows: implicit: authorizationUrl: http://petstore.swagger.io/api/oauth/dialog scopes: write:pets: modify pets in your account read:pets: read your pets + type: oauth2 api_key: - type: apiKey - name: api_key in: header + name: api_key + type: apiKey diff --git a/samples/server/petstore/flaskConnexion/openapi_server/util.py b/samples/server/petstore/flaskConnexion/openapi_server/util.py index 4321570d5a0e..c7340cd00059 100644 --- a/samples/server/petstore/flaskConnexion/openapi_server/util.py +++ b/samples/server/petstore/flaskConnexion/openapi_server/util.py @@ -51,7 +51,7 @@ def _deserialize_primitive(data, klass): def _deserialize_object(value): - """Return a original value. + """Return an original value. :return: object. """