forked from loafle/openapi-generator-original
Use the dataType if the baseType is not set (#5372)
* Use the dataType if the baseType is not set * add tests for passing enum as parameter * updated requirements file in samples * Update spec to explicitly name objects and prevent `inline_object` * use the correct scripts to generate samples (`bin/openapi3/python-flask*`)
This commit is contained in:
parent
4603061c17
commit
857a4bf5d9
@ -26,7 +26,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
input=modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
input=modules/openapi-generator/src/test/resources/3_0/petstore-with-object-as-parameter.yaml
|
||||||
out_folder=samples/openapi3/server/petstore/python-flask-python2
|
out_folder=samples/openapi3/server/petstore/python-flask-python2
|
||||||
resources=modules/openapi-generator/src/main/resources/python-flask
|
resources=modules/openapi-generator/src/main/resources/python-flask
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# if you've executed sbt assembly previously it will use that instead.
|
# if you've executed sbt assembly previously it will use that instead.
|
||||||
input=modules/openapi-generator/src/test/resources/3_0/petstore.yaml
|
input=modules/openapi-generator/src/test/resources/3_0/petstore-with-object-as-parameter.yaml
|
||||||
out_folder=samples/openapi3/server/petstore/python-flask
|
out_folder=samples/openapi3/server/petstore/python-flask
|
||||||
resources=modules/openapi-generator/src/main/resources/python-flask
|
resources=modules/openapi-generator/src/main/resources/python-flask
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ def {{operationId}}({{#allParams}}{{paramName}}{{^required}}=None{{/required}}{{
|
|||||||
{{^isFile}}
|
{{^isFile}}
|
||||||
{{^isUuid}}
|
{{^isUuid}}
|
||||||
if connexion.request.is_json:
|
if connexion.request.is_json:
|
||||||
{{paramName}} = {{baseType}}.from_dict(connexion.request.get_json()) # noqa: E501
|
{{paramName}} = {{#baseType}}{{baseType}}{{/baseType}}{{^baseType}}{{#dataType}} {{dataType}}{{/dataType}}{{/baseType}}.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
{{/isUuid}}
|
{{/isUuid}}
|
||||||
{{/isFile}}
|
{{/isFile}}
|
||||||
{{/isPrimitiveType}}
|
{{/isPrimitiveType}}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
connexion >= 2.5.0; python_version>="3.6"
|
connexion >= 2.6.0; python_version>="3.6"
|
||||||
connexion >= 2.3.0; python_version=="3.5"
|
connexion >= 2.3.0; python_version=="3.5"
|
||||||
connexion >= 2.3.0; python_version=="3.4"
|
connexion >= 2.3.0; python_version=="3.4"
|
||||||
connexion == 2.4.0; python_version<="2.7"
|
connexion == 2.4.0; python_version<="2.7"
|
||||||
|
@ -0,0 +1,793 @@
|
|||||||
|
openapi: 3.0.1
|
||||||
|
servers:
|
||||||
|
- url: 'http://petstore.swagger.io/v2'
|
||||||
|
info:
|
||||||
|
description: >-
|
||||||
|
This is a sample server Petstore server. For this sample, you can use the api key
|
||||||
|
`special-key` to test the authorization filters.
|
||||||
|
version: 1.0.0
|
||||||
|
title: OpenAPI Petstore
|
||||||
|
license:
|
||||||
|
name: Apache-2.0
|
||||||
|
url: 'https://www.apache.org/licenses/LICENSE-2.0.html'
|
||||||
|
tags:
|
||||||
|
- name: pet
|
||||||
|
description: Everything about your Pets
|
||||||
|
- name: store
|
||||||
|
description: Access to Petstore orders
|
||||||
|
- name: user
|
||||||
|
description: Operations about user
|
||||||
|
paths:
|
||||||
|
/pet:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Add a new pet to the store
|
||||||
|
description: ''
|
||||||
|
operationId: addPet
|
||||||
|
responses:
|
||||||
|
'405':
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/Pet'
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Update an existing pet
|
||||||
|
description: ''
|
||||||
|
operationId: updatePet
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
'405':
|
||||||
|
description: Validation exception
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/Pet'
|
||||||
|
/pet/findByStatus:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by status
|
||||||
|
description: Multiple status values can be provided with comma separated strings
|
||||||
|
operationId: findPetsByStatus
|
||||||
|
parameters:
|
||||||
|
- name: status
|
||||||
|
in: query
|
||||||
|
description: Status values that need to be considered for filter
|
||||||
|
required: true
|
||||||
|
style: form
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
default: available
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
'400':
|
||||||
|
description: Invalid status value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'read:pets'
|
||||||
|
/pet/findByTags:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Finds Pets by tags
|
||||||
|
description: >-
|
||||||
|
Multiple tags can be provided with comma separated strings. Use tag1,
|
||||||
|
tag2, tag3 for testing.
|
||||||
|
operationId: findPetsByTags
|
||||||
|
parameters:
|
||||||
|
- name: tags
|
||||||
|
in: query
|
||||||
|
description: Tags to filter by
|
||||||
|
required: true
|
||||||
|
style: form
|
||||||
|
explode: false
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
'400':
|
||||||
|
description: Invalid tag value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'read:pets'
|
||||||
|
deprecated: true
|
||||||
|
'/pet/{petId}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Find pet by ID
|
||||||
|
description: Returns a single pet
|
||||||
|
operationId: getPetById
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to return
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
patch:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Set the status of a pet in the store using an enum
|
||||||
|
description: ''
|
||||||
|
operationId: updatePetStatusWithEnum
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to return
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
- $ref: '#/components/parameters/statusEnum'
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Updates a pet in the store with form data
|
||||||
|
description: ''
|
||||||
|
operationId: updatePetWithForm
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be updated
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'405':
|
||||||
|
description: Invalid input
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/PetForm'
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: Deletes a pet
|
||||||
|
description: ''
|
||||||
|
operationId: deletePet
|
||||||
|
parameters:
|
||||||
|
- name: api_key
|
||||||
|
in: header
|
||||||
|
required: false
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: Pet id to delete
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid pet value
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
'/pet/{petId}/uploadImage':
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
summary: uploads an image
|
||||||
|
description: ''
|
||||||
|
operationId: uploadFile
|
||||||
|
parameters:
|
||||||
|
- name: petId
|
||||||
|
in: path
|
||||||
|
description: ID of pet to update
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ApiResponse'
|
||||||
|
security:
|
||||||
|
- petstore_auth:
|
||||||
|
- 'write:pets'
|
||||||
|
- 'read:pets'
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UploadForm'
|
||||||
|
/store/inventory:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Returns pet inventories by status
|
||||||
|
description: Returns a map of status codes to quantities
|
||||||
|
operationId: getInventory
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
additionalProperties:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
security:
|
||||||
|
- api_key: []
|
||||||
|
/store/order:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Place an order for a pet
|
||||||
|
description: ''
|
||||||
|
operationId: placeOrder
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
'400':
|
||||||
|
description: Invalid Order
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
description: order placed for purchasing the pet
|
||||||
|
required: true
|
||||||
|
'/store/order/{orderId}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- store
|
||||||
|
summary: Find purchase order by ID
|
||||||
|
description: >-
|
||||||
|
For valid response try integer IDs with value <= 5 or > 10. Other values
|
||||||
|
will generated exceptions
|
||||||
|
operationId: getOrderById
|
||||||
|
parameters:
|
||||||
|
- name: orderId
|
||||||
|
in: path
|
||||||
|
description: ID of pet that needs to be fetched
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
minimum: 1
|
||||||
|
maximum: 5
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Order'
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Order not found
|
||||||
|
delete:
|
||||||
|
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: deleteOrder
|
||||||
|
parameters:
|
||||||
|
- name: orderId
|
||||||
|
in: path
|
||||||
|
description: ID of the order that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Order not found
|
||||||
|
/user:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Create user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: createUser
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- auth_cookie: []
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: Created user object
|
||||||
|
required: true
|
||||||
|
/user/createWithArray:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
description: ''
|
||||||
|
operationId: createUsersWithArrayInput
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- auth_cookie: []
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UserArray'
|
||||||
|
/user/createWithList:
|
||||||
|
post:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Creates list of users with given input array
|
||||||
|
description: ''
|
||||||
|
operationId: createUsersWithListInput
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- auth_cookie: []
|
||||||
|
requestBody:
|
||||||
|
$ref: '#/components/requestBodies/UserArray'
|
||||||
|
/user/login:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Logs user into the system
|
||||||
|
description: ''
|
||||||
|
operationId: loginUser
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: query
|
||||||
|
description: The user name for login
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$'
|
||||||
|
- name: password
|
||||||
|
in: query
|
||||||
|
description: The password for login in clear text
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
headers:
|
||||||
|
Set-Cookie:
|
||||||
|
description: >-
|
||||||
|
Cookie authentication key for use with the `auth_cookie`
|
||||||
|
apiKey authentication.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
example: AUTH_KEY=abcde12345; Path=/; HttpOnly
|
||||||
|
X-Rate-Limit:
|
||||||
|
description: calls per hour allowed by the user
|
||||||
|
schema:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
X-Expires-After:
|
||||||
|
description: date in UTC when toekn expires
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
'400':
|
||||||
|
description: Invalid username/password supplied
|
||||||
|
/user/logout:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Logs out current logged in user session
|
||||||
|
description: ''
|
||||||
|
operationId: logoutUser
|
||||||
|
responses:
|
||||||
|
default:
|
||||||
|
description: successful operation
|
||||||
|
security:
|
||||||
|
- auth_cookie: []
|
||||||
|
'/user/{username}':
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Get user by user name
|
||||||
|
description: ''
|
||||||
|
operationId: getUserByName
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: The name that needs to be fetched. Use user1 for testing.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: successful operation
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
'400':
|
||||||
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Updated user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: updateUser
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: name that need to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid user supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
security:
|
||||||
|
- auth_cookie: []
|
||||||
|
requestBody:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: Updated user object
|
||||||
|
required: true
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- user
|
||||||
|
summary: Delete user
|
||||||
|
description: This can only be done by the logged in user.
|
||||||
|
operationId: deleteUser
|
||||||
|
parameters:
|
||||||
|
- name: username
|
||||||
|
in: path
|
||||||
|
description: The name that needs to be deleted
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
responses:
|
||||||
|
'400':
|
||||||
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
|
security:
|
||||||
|
- auth_cookie: []
|
||||||
|
externalDocs:
|
||||||
|
description: Find out more about Swagger
|
||||||
|
url: 'http://swagger.io'
|
||||||
|
components:
|
||||||
|
requestBodies:
|
||||||
|
UserArray:
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/User'
|
||||||
|
description: List of user objects
|
||||||
|
required: true
|
||||||
|
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
|
||||||
|
PetForm:
|
||||||
|
content:
|
||||||
|
application/x-www-form-urlencoded:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/PetForm'
|
||||||
|
example:
|
||||||
|
name: fluffy
|
||||||
|
status: available
|
||||||
|
UploadForm:
|
||||||
|
content:
|
||||||
|
multipart/form-data:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/UploadForm'
|
||||||
|
example:
|
||||||
|
additionalMetadata: additional metadata example
|
||||||
|
file: c29tZSB0ZXN0IGRhdGEK
|
||||||
|
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
|
||||||
|
api_key:
|
||||||
|
type: apiKey
|
||||||
|
name: api_key
|
||||||
|
in: header
|
||||||
|
auth_cookie:
|
||||||
|
type: apiKey
|
||||||
|
name: AUTH_KEY
|
||||||
|
in: cookie
|
||||||
|
schemas:
|
||||||
|
Order:
|
||||||
|
title: Pet Order
|
||||||
|
description: An order for a pets from the pet store
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
petId:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
quantity:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
shipDate:
|
||||||
|
type: string
|
||||||
|
format: date-time
|
||||||
|
status:
|
||||||
|
type: string
|
||||||
|
description: Order Status
|
||||||
|
enum:
|
||||||
|
- placed
|
||||||
|
- approved
|
||||||
|
- delivered
|
||||||
|
complete:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
xml:
|
||||||
|
name: Order
|
||||||
|
Category:
|
||||||
|
title: Pet category
|
||||||
|
description: A category for a pet
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
pattern: '^[a-zA-Z0-9]+[a-zA-Z0-9\.\-_]*[a-zA-Z0-9]+$'
|
||||||
|
xml:
|
||||||
|
name: Category
|
||||||
|
User:
|
||||||
|
title: a User
|
||||||
|
description: A User who is purchasing from the pet store
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
firstName:
|
||||||
|
type: string
|
||||||
|
lastName:
|
||||||
|
type: string
|
||||||
|
email:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
phone:
|
||||||
|
type: string
|
||||||
|
userStatus:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
description: User Status
|
||||||
|
xml:
|
||||||
|
name: User
|
||||||
|
Tag:
|
||||||
|
title: Pet Tag
|
||||||
|
description: A tag for a pet
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
xml:
|
||||||
|
name: Tag
|
||||||
|
Pet:
|
||||||
|
title: a Pet
|
||||||
|
description: A pet for sale in the pet store
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- photoUrls
|
||||||
|
properties:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
format: int64
|
||||||
|
category:
|
||||||
|
$ref: '#/components/schemas/Category'
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
example: doggie
|
||||||
|
photoUrls:
|
||||||
|
type: array
|
||||||
|
xml:
|
||||||
|
name: photoUrl
|
||||||
|
wrapped: true
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
tags:
|
||||||
|
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
|
||||||
|
xml:
|
||||||
|
name: Pet
|
||||||
|
PetForm:
|
||||||
|
title: A pet form
|
||||||
|
description: A form for updating a pet
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- status
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: Updated name of the pet
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Updated status of the pet
|
||||||
|
type: string
|
||||||
|
UploadForm:
|
||||||
|
title: An upload form
|
||||||
|
description: A form for attaching files to a pet
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- file
|
||||||
|
properties:
|
||||||
|
additionalMetadata:
|
||||||
|
description: Additional data to pass to server
|
||||||
|
type: string
|
||||||
|
file:
|
||||||
|
description: file to upload
|
||||||
|
type: string
|
||||||
|
format: binary
|
||||||
|
ApiResponse:
|
||||||
|
title: An uploaded response
|
||||||
|
description: Describes the result of uploading an image resource
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
code:
|
||||||
|
type: integer
|
||||||
|
format: int32
|
||||||
|
type:
|
||||||
|
type: string
|
||||||
|
message:
|
||||||
|
type: string
|
||||||
|
statusEnum:
|
||||||
|
type: string
|
||||||
|
description: pet status in the store
|
||||||
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
parameters:
|
||||||
|
statusEnum:
|
||||||
|
description: The required status
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/statusEnum'
|
||||||
|
example:
|
||||||
|
pending
|
||||||
|
style: form
|
@ -3,6 +3,9 @@ import six
|
|||||||
|
|
||||||
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from openapi_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
|
from openapi_server.models.pet_form import PetForm # noqa: E501
|
||||||
|
from openapi_server.models.status_enum import StatusEnum # noqa: E501
|
||||||
|
from openapi_server.models.upload_form import UploadForm # noqa: E501
|
||||||
from openapi_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
@ -90,35 +93,52 @@ def update_pet(pet): # noqa: E501
|
|||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def update_pet_with_form(pet_id, name=None, status=None): # noqa: E501
|
def update_pet_status_with_enum(pet_id, status): # noqa: E501
|
||||||
|
"""Set the status of a pet in the store using an enum
|
||||||
|
|
||||||
|
# noqa: E501
|
||||||
|
|
||||||
|
:param pet_id: ID of pet to return
|
||||||
|
:type pet_id: int
|
||||||
|
:param status: The required status
|
||||||
|
:type status: dict | bytes
|
||||||
|
|
||||||
|
:rtype: Pet
|
||||||
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
status = StatusEnum.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
|
def update_pet_with_form(pet_id, pet_form=None): # noqa: E501
|
||||||
"""Updates a pet in the store with form data
|
"""Updates a pet in the store with form data
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param pet_id: ID of pet that needs to be updated
|
:param pet_id: ID of pet that needs to be updated
|
||||||
:type pet_id: int
|
:type pet_id: int
|
||||||
:param name: Updated name of the pet
|
:param pet_form:
|
||||||
:type name: str
|
:type pet_form: dict | bytes
|
||||||
:param status: Updated status of the pet
|
|
||||||
:type status: str
|
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
pet_form = PetForm.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def upload_file(pet_id, additional_metadata=None, file=None): # noqa: E501
|
def upload_file(pet_id, upload_form=None): # noqa: E501
|
||||||
"""uploads an image
|
"""uploads an image
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param pet_id: ID of pet to update
|
:param pet_id: ID of pet to update
|
||||||
:type pet_id: int
|
:type pet_id: int
|
||||||
:param additional_metadata: Additional data to pass to server
|
:param upload_form:
|
||||||
:type additional_metadata: str
|
:type upload_form: dict | bytes
|
||||||
:param file: file to upload
|
|
||||||
:type file: str
|
|
||||||
|
|
||||||
:rtype: ApiResponse
|
:rtype: ApiResponse
|
||||||
"""
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
upload_form = UploadForm.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
@ -25,7 +25,7 @@ def create_users_with_array_input(user): # noqa: E501
|
|||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param user: List of user object
|
:param user: List of user objects
|
||||||
:type user: list | bytes
|
:type user: list | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
@ -40,7 +40,7 @@ def create_users_with_list_input(user): # noqa: E501
|
|||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param user: List of user object
|
:param user: List of user objects
|
||||||
:type user: list | bytes
|
:type user: list | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
@ -5,9 +5,10 @@ from __future__ import absolute_import
|
|||||||
# import models into model package
|
# import models into model package
|
||||||
from openapi_server.models.api_response import ApiResponse
|
from openapi_server.models.api_response import ApiResponse
|
||||||
from openapi_server.models.category import Category
|
from openapi_server.models.category import Category
|
||||||
from openapi_server.models.inline_object import InlineObject
|
|
||||||
from openapi_server.models.inline_object1 import InlineObject1
|
|
||||||
from openapi_server.models.order import Order
|
from openapi_server.models.order import Order
|
||||||
from openapi_server.models.pet import Pet
|
from openapi_server.models.pet import Pet
|
||||||
|
from openapi_server.models.pet_form import PetForm
|
||||||
|
from openapi_server.models.status_enum import StatusEnum
|
||||||
from openapi_server.models.tag import Tag
|
from openapi_server.models.tag import Tag
|
||||||
|
from openapi_server.models.upload_form import UploadForm
|
||||||
from openapi_server.models.user import User
|
from openapi_server.models.user import User
|
||||||
|
@ -9,18 +9,18 @@ from openapi_server.models.base_model_ import Model
|
|||||||
from openapi_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class InlineObject(Model):
|
class PetForm(Model):
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name=None, status=None): # noqa: E501
|
def __init__(self, name=None, status=None): # noqa: E501
|
||||||
"""InlineObject - a model defined in OpenAPI
|
"""PetForm - a model defined in OpenAPI
|
||||||
|
|
||||||
:param name: The name of this InlineObject. # noqa: E501
|
:param name: The name of this PetForm. # noqa: E501
|
||||||
:type name: str
|
:type name: str
|
||||||
:param status: The status of this InlineObject. # noqa: E501
|
:param status: The status of this PetForm. # noqa: E501
|
||||||
:type status: str
|
:type status: str
|
||||||
"""
|
"""
|
||||||
self.openapi_types = {
|
self.openapi_types = {
|
||||||
@ -42,53 +42,57 @@ class InlineObject(Model):
|
|||||||
|
|
||||||
:param dikt: A dict.
|
:param dikt: A dict.
|
||||||
:type: dict
|
:type: dict
|
||||||
:return: The inline_object of this InlineObject. # noqa: E501
|
:return: The PetForm of this PetForm. # noqa: E501
|
||||||
:rtype: InlineObject
|
:rtype: PetForm
|
||||||
"""
|
"""
|
||||||
return util.deserialize_model(dikt, cls)
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Gets the name of this InlineObject.
|
"""Gets the name of this PetForm.
|
||||||
|
|
||||||
Updated name of the pet # noqa: E501
|
Updated name of the pet # noqa: E501
|
||||||
|
|
||||||
:return: The name of this InlineObject.
|
:return: The name of this PetForm.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
"""Sets the name of this InlineObject.
|
"""Sets the name of this PetForm.
|
||||||
|
|
||||||
Updated name of the pet # noqa: E501
|
Updated name of the pet # noqa: E501
|
||||||
|
|
||||||
:param name: The name of this InlineObject.
|
:param name: The name of this PetForm.
|
||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
|
if name is None:
|
||||||
|
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def status(self):
|
def status(self):
|
||||||
"""Gets the status of this InlineObject.
|
"""Gets the status of this PetForm.
|
||||||
|
|
||||||
Updated status of the pet # noqa: E501
|
Updated status of the pet # noqa: E501
|
||||||
|
|
||||||
:return: The status of this InlineObject.
|
:return: The status of this PetForm.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._status
|
return self._status
|
||||||
|
|
||||||
@status.setter
|
@status.setter
|
||||||
def status(self, status):
|
def status(self, status):
|
||||||
"""Sets the status of this InlineObject.
|
"""Sets the status of this PetForm.
|
||||||
|
|
||||||
Updated status of the pet # noqa: E501
|
Updated status of the pet # noqa: E501
|
||||||
|
|
||||||
:param status: The status of this InlineObject.
|
:param status: The status of this PetForm.
|
||||||
:type status: str
|
:type status: str
|
||||||
"""
|
"""
|
||||||
|
if status is None:
|
||||||
|
raise ValueError("Invalid value for `status`, must not be `None`") # noqa: E501
|
||||||
|
|
||||||
self._status = status
|
self._status = status
|
@ -0,0 +1,43 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from datetime import date, datetime # noqa: F401
|
||||||
|
|
||||||
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
|
from openapi_server.models.base_model_ import Model
|
||||||
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
|
class StatusEnum(Model):
|
||||||
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
allowed enum values
|
||||||
|
"""
|
||||||
|
AVAILABLE = "available"
|
||||||
|
PENDING = "pending"
|
||||||
|
SOLD = "sold"
|
||||||
|
def __init__(self): # noqa: E501
|
||||||
|
"""StatusEnum - a model defined in OpenAPI
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.openapi_types = {
|
||||||
|
}
|
||||||
|
|
||||||
|
self.attribute_map = {
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, dikt):
|
||||||
|
"""Returns the dict as a model
|
||||||
|
|
||||||
|
:param dikt: A dict.
|
||||||
|
:type: dict
|
||||||
|
:return: The statusEnum of this StatusEnum. # noqa: E501
|
||||||
|
:rtype: StatusEnum
|
||||||
|
"""
|
||||||
|
return util.deserialize_model(dikt, cls)
|
@ -9,18 +9,18 @@ from openapi_server.models.base_model_ import Model
|
|||||||
from openapi_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class InlineObject1(Model):
|
class UploadForm(Model):
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, additional_metadata=None, file=None): # noqa: E501
|
def __init__(self, additional_metadata=None, file=None): # noqa: E501
|
||||||
"""InlineObject1 - a model defined in OpenAPI
|
"""UploadForm - a model defined in OpenAPI
|
||||||
|
|
||||||
:param additional_metadata: The additional_metadata of this InlineObject1. # noqa: E501
|
:param additional_metadata: The additional_metadata of this UploadForm. # noqa: E501
|
||||||
:type additional_metadata: str
|
:type additional_metadata: str
|
||||||
:param file: The file of this InlineObject1. # noqa: E501
|
:param file: The file of this UploadForm. # noqa: E501
|
||||||
:type file: file
|
:type file: file
|
||||||
"""
|
"""
|
||||||
self.openapi_types = {
|
self.openapi_types = {
|
||||||
@ -42,29 +42,29 @@ class InlineObject1(Model):
|
|||||||
|
|
||||||
:param dikt: A dict.
|
:param dikt: A dict.
|
||||||
:type: dict
|
:type: dict
|
||||||
:return: The inline_object_1 of this InlineObject1. # noqa: E501
|
:return: The UploadForm of this UploadForm. # noqa: E501
|
||||||
:rtype: InlineObject1
|
:rtype: UploadForm
|
||||||
"""
|
"""
|
||||||
return util.deserialize_model(dikt, cls)
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def additional_metadata(self):
|
def additional_metadata(self):
|
||||||
"""Gets the additional_metadata of this InlineObject1.
|
"""Gets the additional_metadata of this UploadForm.
|
||||||
|
|
||||||
Additional data to pass to server # noqa: E501
|
Additional data to pass to server # noqa: E501
|
||||||
|
|
||||||
:return: The additional_metadata of this InlineObject1.
|
:return: The additional_metadata of this UploadForm.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._additional_metadata
|
return self._additional_metadata
|
||||||
|
|
||||||
@additional_metadata.setter
|
@additional_metadata.setter
|
||||||
def additional_metadata(self, additional_metadata):
|
def additional_metadata(self, additional_metadata):
|
||||||
"""Sets the additional_metadata of this InlineObject1.
|
"""Sets the additional_metadata of this UploadForm.
|
||||||
|
|
||||||
Additional data to pass to server # noqa: E501
|
Additional data to pass to server # noqa: E501
|
||||||
|
|
||||||
:param additional_metadata: The additional_metadata of this InlineObject1.
|
:param additional_metadata: The additional_metadata of this UploadForm.
|
||||||
:type additional_metadata: str
|
:type additional_metadata: str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -72,23 +72,25 @@ class InlineObject1(Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def file(self):
|
def file(self):
|
||||||
"""Gets the file of this InlineObject1.
|
"""Gets the file of this UploadForm.
|
||||||
|
|
||||||
file to upload # noqa: E501
|
file to upload # noqa: E501
|
||||||
|
|
||||||
:return: The file of this InlineObject1.
|
:return: The file of this UploadForm.
|
||||||
:rtype: file
|
:rtype: file
|
||||||
"""
|
"""
|
||||||
return self._file
|
return self._file
|
||||||
|
|
||||||
@file.setter
|
@file.setter
|
||||||
def file(self, file):
|
def file(self, file):
|
||||||
"""Sets the file of this InlineObject1.
|
"""Sets the file of this UploadForm.
|
||||||
|
|
||||||
file to upload # noqa: E501
|
file to upload # noqa: E501
|
||||||
|
|
||||||
:param file: The file of this InlineObject1.
|
:param file: The file of this UploadForm.
|
||||||
:type file: file
|
:type file: file
|
||||||
"""
|
"""
|
||||||
|
if file is None:
|
||||||
|
raise ValueError("Invalid value for `file`, must not be `None`") # noqa: E501
|
||||||
|
|
||||||
self._file = file
|
self._file = file
|
@ -1,4 +1,4 @@
|
|||||||
openapi: 3.0.0
|
openapi: 3.0.1
|
||||||
info:
|
info:
|
||||||
description: This is a sample server Petstore server. For this sample, you can use
|
description: This is a sample server Petstore server. For this sample, you can use
|
||||||
the api key `special-key` to test the authorization filters.
|
the api key `special-key` to test the authorization filters.
|
||||||
@ -220,6 +220,45 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
patch:
|
||||||
|
operationId: update_pet_status_with_enum
|
||||||
|
parameters:
|
||||||
|
- description: ID of pet to return
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: petId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
- description: The required status
|
||||||
|
example: pending
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/statusEnum'
|
||||||
|
style: form
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid ID supplied
|
||||||
|
"404":
|
||||||
|
description: Pet not found
|
||||||
|
summary: Set the status of a pet in the store using an enum
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
post:
|
post:
|
||||||
operationId: update_pet_with_form
|
operationId: update_pet_with_form
|
||||||
parameters:
|
parameters:
|
||||||
@ -233,18 +272,7 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
style: simple
|
style: simple
|
||||||
requestBody:
|
requestBody:
|
||||||
$ref: '#/components/requestBodies/inline_object'
|
$ref: '#/components/requestBodies/PetForm'
|
||||||
content:
|
|
||||||
application/x-www-form-urlencoded:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: Updated name of the pet
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
responses:
|
||||||
"405":
|
"405":
|
||||||
description: Invalid input
|
description: Invalid input
|
||||||
@ -270,19 +298,7 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
style: simple
|
style: simple
|
||||||
requestBody:
|
requestBody:
|
||||||
$ref: '#/components/requestBodies/inline_object_1'
|
$ref: '#/components/requestBodies/UploadForm'
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
content:
|
content:
|
||||||
@ -605,6 +621,17 @@ paths:
|
|||||||
- user
|
- user
|
||||||
x-openapi-router-controller: openapi_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
components:
|
components:
|
||||||
|
parameters:
|
||||||
|
statusEnum:
|
||||||
|
description: The required status
|
||||||
|
example: pending
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/statusEnum'
|
||||||
|
style: form
|
||||||
requestBodies:
|
requestBodies:
|
||||||
UserArray:
|
UserArray:
|
||||||
content:
|
content:
|
||||||
@ -613,7 +640,7 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/User'
|
$ref: '#/components/schemas/User'
|
||||||
type: array
|
type: array
|
||||||
description: List of user object
|
description: List of user objects
|
||||||
required: true
|
required: true
|
||||||
Pet:
|
Pet:
|
||||||
content:
|
content:
|
||||||
@ -625,16 +652,22 @@ components:
|
|||||||
$ref: '#/components/schemas/Pet'
|
$ref: '#/components/schemas/Pet'
|
||||||
description: Pet object that needs to be added to the store
|
description: Pet object that needs to be added to the store
|
||||||
required: true
|
required: true
|
||||||
inline_object:
|
PetForm:
|
||||||
content:
|
content:
|
||||||
application/x-www-form-urlencoded:
|
application/x-www-form-urlencoded:
|
||||||
|
example:
|
||||||
|
name: fluffy
|
||||||
|
status: available
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/inline_object'
|
$ref: '#/components/schemas/PetForm'
|
||||||
inline_object_1:
|
UploadForm:
|
||||||
content:
|
content:
|
||||||
multipart/form-data:
|
multipart/form-data:
|
||||||
|
example:
|
||||||
|
additionalMetadata: additional metadata example
|
||||||
|
file: c29tZSB0ZXN0IGRhdGEK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/inline_object_1'
|
$ref: '#/components/schemas/UploadForm'
|
||||||
schemas:
|
schemas:
|
||||||
Order:
|
Order:
|
||||||
description: An order for a pets from the pet store
|
description: An order for a pets from the pet store
|
||||||
@ -792,6 +825,34 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
xml:
|
xml:
|
||||||
name: Pet
|
name: Pet
|
||||||
|
PetForm:
|
||||||
|
description: A form for updating a pet
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: Updated name of the pet
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Updated status of the pet
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- status
|
||||||
|
title: A pet form
|
||||||
|
type: object
|
||||||
|
UploadForm:
|
||||||
|
description: A form for attaching files to a pet
|
||||||
|
properties:
|
||||||
|
additionalMetadata:
|
||||||
|
description: Additional data to pass to server
|
||||||
|
type: string
|
||||||
|
file:
|
||||||
|
description: file to upload
|
||||||
|
format: binary
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- file
|
||||||
|
title: An upload form
|
||||||
|
type: object
|
||||||
ApiResponse:
|
ApiResponse:
|
||||||
description: Describes the result of uploading an image resource
|
description: Describes the result of uploading an image resource
|
||||||
example:
|
example:
|
||||||
@ -808,25 +869,13 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
title: An uploaded response
|
title: An uploaded response
|
||||||
type: object
|
type: object
|
||||||
inline_object:
|
statusEnum:
|
||||||
properties:
|
description: pet status in the store
|
||||||
name:
|
enum:
|
||||||
description: Updated name of the pet
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
type: string
|
type: string
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
inline_object_1:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
petstore_auth:
|
petstore_auth:
|
||||||
flows:
|
flows:
|
||||||
|
@ -8,6 +8,9 @@ from six import BytesIO
|
|||||||
|
|
||||||
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from openapi_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
|
from openapi_server.models.pet_form import PetForm # noqa: E501
|
||||||
|
from openapi_server.models.status_enum import StatusEnum # noqa: E501
|
||||||
|
from openapi_server.models.upload_form import UploadForm # noqa: E501
|
||||||
from openapi_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
@ -156,23 +159,39 @@ class TestPetController(BaseTestCase):
|
|||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
|
def test_update_pet_status_with_enum(self):
|
||||||
|
"""Test case for update_pet_status_with_enum
|
||||||
|
|
||||||
|
Set the status of a pet in the store using an enum
|
||||||
|
"""
|
||||||
|
query_string = [('status', pending)]
|
||||||
|
headers = {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
}
|
||||||
|
response = self.client.open(
|
||||||
|
'/v2/pet/{pet_id}'.format(pet_id=789),
|
||||||
|
method='PATCH',
|
||||||
|
headers=headers,
|
||||||
|
query_string=query_string)
|
||||||
|
self.assert200(response,
|
||||||
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@unittest.skip("application/x-www-form-urlencoded not supported by Connexion")
|
@unittest.skip("application/x-www-form-urlencoded not supported by Connexion")
|
||||||
def test_update_pet_with_form(self):
|
def test_update_pet_with_form(self):
|
||||||
"""Test case for update_pet_with_form
|
"""Test case for update_pet_with_form
|
||||||
|
|
||||||
Updates a pet in the store with form data
|
Updates a pet in the store with form data
|
||||||
"""
|
"""
|
||||||
|
pet_form = {"name":"fluffy","status":"available"}
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
}
|
}
|
||||||
data = dict(name='name_example',
|
|
||||||
status='status_example')
|
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{pet_id}'.format(pet_id=789),
|
'/v2/pet/{pet_id}'.format(pet_id=789),
|
||||||
method='POST',
|
method='POST',
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=data,
|
data=json.dumps(pet_form),
|
||||||
content_type='application/x-www-form-urlencoded')
|
content_type='application/x-www-form-urlencoded')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@ -183,18 +202,17 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
uploads an image
|
uploads an image
|
||||||
"""
|
"""
|
||||||
|
upload_form = {"additionalMetadata":"additional metadata example","file":"c29tZSB0ZXN0IGRhdGEK"}
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
}
|
}
|
||||||
data = dict(additional_metadata='additional_metadata_example',
|
|
||||||
file=(BytesIO(b'some file data'), 'file.txt'))
|
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=789),
|
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=789),
|
||||||
method='POST',
|
method='POST',
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=data,
|
data=json.dumps(upload_form),
|
||||||
content_type='multipart/form-data')
|
content_type='multipart/form-data')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
connexion >= 2.5.0; python_version>="3.6"
|
connexion >= 2.6.0; python_version>="3.6"
|
||||||
connexion >= 2.3.0; python_version=="3.5"
|
connexion >= 2.3.0; python_version=="3.5"
|
||||||
connexion >= 2.3.0; python_version=="3.4"
|
connexion >= 2.3.0; python_version=="3.4"
|
||||||
connexion == 2.4.0; python_version<="2.7"
|
connexion == 2.4.0; python_version<="2.7"
|
||||||
|
@ -3,6 +3,9 @@ import six
|
|||||||
|
|
||||||
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from openapi_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
|
from openapi_server.models.pet_form import PetForm # noqa: E501
|
||||||
|
from openapi_server.models.status_enum import StatusEnum # noqa: E501
|
||||||
|
from openapi_server.models.upload_form import UploadForm # noqa: E501
|
||||||
from openapi_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
@ -90,35 +93,52 @@ def update_pet(pet): # noqa: E501
|
|||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def update_pet_with_form(pet_id, name=None, status=None): # noqa: E501
|
def update_pet_status_with_enum(pet_id, status): # noqa: E501
|
||||||
|
"""Set the status of a pet in the store using an enum
|
||||||
|
|
||||||
|
# noqa: E501
|
||||||
|
|
||||||
|
:param pet_id: ID of pet to return
|
||||||
|
:type pet_id: int
|
||||||
|
:param status: The required status
|
||||||
|
:type status: dict | bytes
|
||||||
|
|
||||||
|
:rtype: Pet
|
||||||
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
status = StatusEnum.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
|
def update_pet_with_form(pet_id, pet_form=None): # noqa: E501
|
||||||
"""Updates a pet in the store with form data
|
"""Updates a pet in the store with form data
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param pet_id: ID of pet that needs to be updated
|
:param pet_id: ID of pet that needs to be updated
|
||||||
:type pet_id: int
|
:type pet_id: int
|
||||||
:param name: Updated name of the pet
|
:param pet_form:
|
||||||
:type name: str
|
:type pet_form: dict | bytes
|
||||||
:param status: Updated status of the pet
|
|
||||||
:type status: str
|
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
"""
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
pet_form = PetForm.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
|
||||||
|
|
||||||
def upload_file(pet_id, additional_metadata=None, file=None): # noqa: E501
|
def upload_file(pet_id, upload_form=None): # noqa: E501
|
||||||
"""uploads an image
|
"""uploads an image
|
||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param pet_id: ID of pet to update
|
:param pet_id: ID of pet to update
|
||||||
:type pet_id: int
|
:type pet_id: int
|
||||||
:param additional_metadata: Additional data to pass to server
|
:param upload_form:
|
||||||
:type additional_metadata: str
|
:type upload_form: dict | bytes
|
||||||
:param file: file to upload
|
|
||||||
:type file: str
|
|
||||||
|
|
||||||
:rtype: ApiResponse
|
:rtype: ApiResponse
|
||||||
"""
|
"""
|
||||||
|
if connexion.request.is_json:
|
||||||
|
upload_form = UploadForm.from_dict(connexion.request.get_json()) # noqa: E501
|
||||||
return 'do some magic!'
|
return 'do some magic!'
|
||||||
|
@ -25,7 +25,7 @@ def create_users_with_array_input(user): # noqa: E501
|
|||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param user: List of user object
|
:param user: List of user objects
|
||||||
:type user: list | bytes
|
:type user: list | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
@ -40,7 +40,7 @@ def create_users_with_list_input(user): # noqa: E501
|
|||||||
|
|
||||||
# noqa: E501
|
# noqa: E501
|
||||||
|
|
||||||
:param user: List of user object
|
:param user: List of user objects
|
||||||
:type user: list | bytes
|
:type user: list | bytes
|
||||||
|
|
||||||
:rtype: None
|
:rtype: None
|
||||||
|
@ -5,9 +5,10 @@ from __future__ import absolute_import
|
|||||||
# import models into model package
|
# import models into model package
|
||||||
from openapi_server.models.api_response import ApiResponse
|
from openapi_server.models.api_response import ApiResponse
|
||||||
from openapi_server.models.category import Category
|
from openapi_server.models.category import Category
|
||||||
from openapi_server.models.inline_object import InlineObject
|
|
||||||
from openapi_server.models.inline_object1 import InlineObject1
|
|
||||||
from openapi_server.models.order import Order
|
from openapi_server.models.order import Order
|
||||||
from openapi_server.models.pet import Pet
|
from openapi_server.models.pet import Pet
|
||||||
|
from openapi_server.models.pet_form import PetForm
|
||||||
|
from openapi_server.models.status_enum import StatusEnum
|
||||||
from openapi_server.models.tag import Tag
|
from openapi_server.models.tag import Tag
|
||||||
|
from openapi_server.models.upload_form import UploadForm
|
||||||
from openapi_server.models.user import User
|
from openapi_server.models.user import User
|
||||||
|
@ -9,18 +9,18 @@ from openapi_server.models.base_model_ import Model
|
|||||||
from openapi_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class InlineObject(Model):
|
class PetForm(Model):
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, name=None, status=None): # noqa: E501
|
def __init__(self, name=None, status=None): # noqa: E501
|
||||||
"""InlineObject - a model defined in OpenAPI
|
"""PetForm - a model defined in OpenAPI
|
||||||
|
|
||||||
:param name: The name of this InlineObject. # noqa: E501
|
:param name: The name of this PetForm. # noqa: E501
|
||||||
:type name: str
|
:type name: str
|
||||||
:param status: The status of this InlineObject. # noqa: E501
|
:param status: The status of this PetForm. # noqa: E501
|
||||||
:type status: str
|
:type status: str
|
||||||
"""
|
"""
|
||||||
self.openapi_types = {
|
self.openapi_types = {
|
||||||
@ -37,58 +37,62 @@ class InlineObject(Model):
|
|||||||
self._status = status
|
self._status = status
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dikt) -> 'InlineObject':
|
def from_dict(cls, dikt) -> 'PetForm':
|
||||||
"""Returns the dict as a model
|
"""Returns the dict as a model
|
||||||
|
|
||||||
:param dikt: A dict.
|
:param dikt: A dict.
|
||||||
:type: dict
|
:type: dict
|
||||||
:return: The inline_object of this InlineObject. # noqa: E501
|
:return: The PetForm of this PetForm. # noqa: E501
|
||||||
:rtype: InlineObject
|
:rtype: PetForm
|
||||||
"""
|
"""
|
||||||
return util.deserialize_model(dikt, cls)
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Gets the name of this InlineObject.
|
"""Gets the name of this PetForm.
|
||||||
|
|
||||||
Updated name of the pet # noqa: E501
|
Updated name of the pet # noqa: E501
|
||||||
|
|
||||||
:return: The name of this InlineObject.
|
:return: The name of this PetForm.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
@name.setter
|
@name.setter
|
||||||
def name(self, name):
|
def name(self, name):
|
||||||
"""Sets the name of this InlineObject.
|
"""Sets the name of this PetForm.
|
||||||
|
|
||||||
Updated name of the pet # noqa: E501
|
Updated name of the pet # noqa: E501
|
||||||
|
|
||||||
:param name: The name of this InlineObject.
|
:param name: The name of this PetForm.
|
||||||
:type name: str
|
:type name: str
|
||||||
"""
|
"""
|
||||||
|
if name is None:
|
||||||
|
raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501
|
||||||
|
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def status(self):
|
def status(self):
|
||||||
"""Gets the status of this InlineObject.
|
"""Gets the status of this PetForm.
|
||||||
|
|
||||||
Updated status of the pet # noqa: E501
|
Updated status of the pet # noqa: E501
|
||||||
|
|
||||||
:return: The status of this InlineObject.
|
:return: The status of this PetForm.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._status
|
return self._status
|
||||||
|
|
||||||
@status.setter
|
@status.setter
|
||||||
def status(self, status):
|
def status(self, status):
|
||||||
"""Sets the status of this InlineObject.
|
"""Sets the status of this PetForm.
|
||||||
|
|
||||||
Updated status of the pet # noqa: E501
|
Updated status of the pet # noqa: E501
|
||||||
|
|
||||||
:param status: The status of this InlineObject.
|
:param status: The status of this PetForm.
|
||||||
:type status: str
|
:type status: str
|
||||||
"""
|
"""
|
||||||
|
if status is None:
|
||||||
|
raise ValueError("Invalid value for `status`, must not be `None`") # noqa: E501
|
||||||
|
|
||||||
self._status = status
|
self._status = status
|
@ -0,0 +1,43 @@
|
|||||||
|
# coding: utf-8
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from datetime import date, datetime # noqa: F401
|
||||||
|
|
||||||
|
from typing import List, Dict # noqa: F401
|
||||||
|
|
||||||
|
from openapi_server.models.base_model_ import Model
|
||||||
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
|
class StatusEnum(Model):
|
||||||
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
|
Do not edit the class manually.
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
allowed enum values
|
||||||
|
"""
|
||||||
|
AVAILABLE = "available"
|
||||||
|
PENDING = "pending"
|
||||||
|
SOLD = "sold"
|
||||||
|
def __init__(self): # noqa: E501
|
||||||
|
"""StatusEnum - a model defined in OpenAPI
|
||||||
|
|
||||||
|
"""
|
||||||
|
self.openapi_types = {
|
||||||
|
}
|
||||||
|
|
||||||
|
self.attribute_map = {
|
||||||
|
}
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls, dikt) -> 'StatusEnum':
|
||||||
|
"""Returns the dict as a model
|
||||||
|
|
||||||
|
:param dikt: A dict.
|
||||||
|
:type: dict
|
||||||
|
:return: The statusEnum of this StatusEnum. # noqa: E501
|
||||||
|
:rtype: StatusEnum
|
||||||
|
"""
|
||||||
|
return util.deserialize_model(dikt, cls)
|
@ -9,18 +9,18 @@ from openapi_server.models.base_model_ import Model
|
|||||||
from openapi_server import util
|
from openapi_server import util
|
||||||
|
|
||||||
|
|
||||||
class InlineObject1(Model):
|
class UploadForm(Model):
|
||||||
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
"""NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||||
|
|
||||||
Do not edit the class manually.
|
Do not edit the class manually.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, additional_metadata=None, file=None): # noqa: E501
|
def __init__(self, additional_metadata=None, file=None): # noqa: E501
|
||||||
"""InlineObject1 - a model defined in OpenAPI
|
"""UploadForm - a model defined in OpenAPI
|
||||||
|
|
||||||
:param additional_metadata: The additional_metadata of this InlineObject1. # noqa: E501
|
:param additional_metadata: The additional_metadata of this UploadForm. # noqa: E501
|
||||||
:type additional_metadata: str
|
:type additional_metadata: str
|
||||||
:param file: The file of this InlineObject1. # noqa: E501
|
:param file: The file of this UploadForm. # noqa: E501
|
||||||
:type file: file
|
:type file: file
|
||||||
"""
|
"""
|
||||||
self.openapi_types = {
|
self.openapi_types = {
|
||||||
@ -37,34 +37,34 @@ class InlineObject1(Model):
|
|||||||
self._file = file
|
self._file = file
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dikt) -> 'InlineObject1':
|
def from_dict(cls, dikt) -> 'UploadForm':
|
||||||
"""Returns the dict as a model
|
"""Returns the dict as a model
|
||||||
|
|
||||||
:param dikt: A dict.
|
:param dikt: A dict.
|
||||||
:type: dict
|
:type: dict
|
||||||
:return: The inline_object_1 of this InlineObject1. # noqa: E501
|
:return: The UploadForm of this UploadForm. # noqa: E501
|
||||||
:rtype: InlineObject1
|
:rtype: UploadForm
|
||||||
"""
|
"""
|
||||||
return util.deserialize_model(dikt, cls)
|
return util.deserialize_model(dikt, cls)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def additional_metadata(self):
|
def additional_metadata(self):
|
||||||
"""Gets the additional_metadata of this InlineObject1.
|
"""Gets the additional_metadata of this UploadForm.
|
||||||
|
|
||||||
Additional data to pass to server # noqa: E501
|
Additional data to pass to server # noqa: E501
|
||||||
|
|
||||||
:return: The additional_metadata of this InlineObject1.
|
:return: The additional_metadata of this UploadForm.
|
||||||
:rtype: str
|
:rtype: str
|
||||||
"""
|
"""
|
||||||
return self._additional_metadata
|
return self._additional_metadata
|
||||||
|
|
||||||
@additional_metadata.setter
|
@additional_metadata.setter
|
||||||
def additional_metadata(self, additional_metadata):
|
def additional_metadata(self, additional_metadata):
|
||||||
"""Sets the additional_metadata of this InlineObject1.
|
"""Sets the additional_metadata of this UploadForm.
|
||||||
|
|
||||||
Additional data to pass to server # noqa: E501
|
Additional data to pass to server # noqa: E501
|
||||||
|
|
||||||
:param additional_metadata: The additional_metadata of this InlineObject1.
|
:param additional_metadata: The additional_metadata of this UploadForm.
|
||||||
:type additional_metadata: str
|
:type additional_metadata: str
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -72,23 +72,25 @@ class InlineObject1(Model):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def file(self):
|
def file(self):
|
||||||
"""Gets the file of this InlineObject1.
|
"""Gets the file of this UploadForm.
|
||||||
|
|
||||||
file to upload # noqa: E501
|
file to upload # noqa: E501
|
||||||
|
|
||||||
:return: The file of this InlineObject1.
|
:return: The file of this UploadForm.
|
||||||
:rtype: file
|
:rtype: file
|
||||||
"""
|
"""
|
||||||
return self._file
|
return self._file
|
||||||
|
|
||||||
@file.setter
|
@file.setter
|
||||||
def file(self, file):
|
def file(self, file):
|
||||||
"""Sets the file of this InlineObject1.
|
"""Sets the file of this UploadForm.
|
||||||
|
|
||||||
file to upload # noqa: E501
|
file to upload # noqa: E501
|
||||||
|
|
||||||
:param file: The file of this InlineObject1.
|
:param file: The file of this UploadForm.
|
||||||
:type file: file
|
:type file: file
|
||||||
"""
|
"""
|
||||||
|
if file is None:
|
||||||
|
raise ValueError("Invalid value for `file`, must not be `None`") # noqa: E501
|
||||||
|
|
||||||
self._file = file
|
self._file = file
|
@ -1,4 +1,4 @@
|
|||||||
openapi: 3.0.0
|
openapi: 3.0.1
|
||||||
info:
|
info:
|
||||||
description: This is a sample server Petstore server. For this sample, you can use
|
description: This is a sample server Petstore server. For this sample, you can use
|
||||||
the api key `special-key` to test the authorization filters.
|
the api key `special-key` to test the authorization filters.
|
||||||
@ -220,6 +220,45 @@ paths:
|
|||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
|
patch:
|
||||||
|
operationId: update_pet_status_with_enum
|
||||||
|
parameters:
|
||||||
|
- description: ID of pet to return
|
||||||
|
explode: false
|
||||||
|
in: path
|
||||||
|
name: petId
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
format: int64
|
||||||
|
type: integer
|
||||||
|
style: simple
|
||||||
|
- description: The required status
|
||||||
|
example: pending
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/statusEnum'
|
||||||
|
style: form
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
content:
|
||||||
|
application/xml:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/Pet'
|
||||||
|
description: successful operation
|
||||||
|
"400":
|
||||||
|
description: Invalid ID supplied
|
||||||
|
"404":
|
||||||
|
description: Pet not found
|
||||||
|
summary: Set the status of a pet in the store using an enum
|
||||||
|
tags:
|
||||||
|
- pet
|
||||||
|
x-openapi-router-controller: openapi_server.controllers.pet_controller
|
||||||
post:
|
post:
|
||||||
operationId: update_pet_with_form
|
operationId: update_pet_with_form
|
||||||
parameters:
|
parameters:
|
||||||
@ -233,18 +272,7 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
style: simple
|
style: simple
|
||||||
requestBody:
|
requestBody:
|
||||||
$ref: '#/components/requestBodies/inline_object'
|
$ref: '#/components/requestBodies/PetForm'
|
||||||
content:
|
|
||||||
application/x-www-form-urlencoded:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
description: Updated name of the pet
|
|
||||||
type: string
|
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
responses:
|
||||||
"405":
|
"405":
|
||||||
description: Invalid input
|
description: Invalid input
|
||||||
@ -270,19 +298,7 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
style: simple
|
style: simple
|
||||||
requestBody:
|
requestBody:
|
||||||
$ref: '#/components/requestBodies/inline_object_1'
|
$ref: '#/components/requestBodies/UploadForm'
|
||||||
content:
|
|
||||||
multipart/form-data:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
content:
|
content:
|
||||||
@ -605,6 +621,17 @@ paths:
|
|||||||
- user
|
- user
|
||||||
x-openapi-router-controller: openapi_server.controllers.user_controller
|
x-openapi-router-controller: openapi_server.controllers.user_controller
|
||||||
components:
|
components:
|
||||||
|
parameters:
|
||||||
|
statusEnum:
|
||||||
|
description: The required status
|
||||||
|
example: pending
|
||||||
|
explode: true
|
||||||
|
in: query
|
||||||
|
name: status
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/statusEnum'
|
||||||
|
style: form
|
||||||
requestBodies:
|
requestBodies:
|
||||||
UserArray:
|
UserArray:
|
||||||
content:
|
content:
|
||||||
@ -613,7 +640,7 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/User'
|
$ref: '#/components/schemas/User'
|
||||||
type: array
|
type: array
|
||||||
description: List of user object
|
description: List of user objects
|
||||||
required: true
|
required: true
|
||||||
Pet:
|
Pet:
|
||||||
content:
|
content:
|
||||||
@ -625,16 +652,22 @@ components:
|
|||||||
$ref: '#/components/schemas/Pet'
|
$ref: '#/components/schemas/Pet'
|
||||||
description: Pet object that needs to be added to the store
|
description: Pet object that needs to be added to the store
|
||||||
required: true
|
required: true
|
||||||
inline_object:
|
PetForm:
|
||||||
content:
|
content:
|
||||||
application/x-www-form-urlencoded:
|
application/x-www-form-urlencoded:
|
||||||
|
example:
|
||||||
|
name: fluffy
|
||||||
|
status: available
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/inline_object'
|
$ref: '#/components/schemas/PetForm'
|
||||||
inline_object_1:
|
UploadForm:
|
||||||
content:
|
content:
|
||||||
multipart/form-data:
|
multipart/form-data:
|
||||||
|
example:
|
||||||
|
additionalMetadata: additional metadata example
|
||||||
|
file: c29tZSB0ZXN0IGRhdGEK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/inline_object_1'
|
$ref: '#/components/schemas/UploadForm'
|
||||||
schemas:
|
schemas:
|
||||||
Order:
|
Order:
|
||||||
description: An order for a pets from the pet store
|
description: An order for a pets from the pet store
|
||||||
@ -792,6 +825,34 @@ components:
|
|||||||
type: object
|
type: object
|
||||||
xml:
|
xml:
|
||||||
name: Pet
|
name: Pet
|
||||||
|
PetForm:
|
||||||
|
description: A form for updating a pet
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: Updated name of the pet
|
||||||
|
type: string
|
||||||
|
status:
|
||||||
|
description: Updated status of the pet
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- name
|
||||||
|
- status
|
||||||
|
title: A pet form
|
||||||
|
type: object
|
||||||
|
UploadForm:
|
||||||
|
description: A form for attaching files to a pet
|
||||||
|
properties:
|
||||||
|
additionalMetadata:
|
||||||
|
description: Additional data to pass to server
|
||||||
|
type: string
|
||||||
|
file:
|
||||||
|
description: file to upload
|
||||||
|
format: binary
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- file
|
||||||
|
title: An upload form
|
||||||
|
type: object
|
||||||
ApiResponse:
|
ApiResponse:
|
||||||
description: Describes the result of uploading an image resource
|
description: Describes the result of uploading an image resource
|
||||||
example:
|
example:
|
||||||
@ -808,25 +869,13 @@ components:
|
|||||||
type: string
|
type: string
|
||||||
title: An uploaded response
|
title: An uploaded response
|
||||||
type: object
|
type: object
|
||||||
inline_object:
|
statusEnum:
|
||||||
properties:
|
description: pet status in the store
|
||||||
name:
|
enum:
|
||||||
description: Updated name of the pet
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
type: string
|
type: string
|
||||||
status:
|
|
||||||
description: Updated status of the pet
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
inline_object_1:
|
|
||||||
properties:
|
|
||||||
additionalMetadata:
|
|
||||||
description: Additional data to pass to server
|
|
||||||
type: string
|
|
||||||
file:
|
|
||||||
description: file to upload
|
|
||||||
format: binary
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
securitySchemes:
|
securitySchemes:
|
||||||
petstore_auth:
|
petstore_auth:
|
||||||
flows:
|
flows:
|
||||||
|
@ -8,6 +8,9 @@ from six import BytesIO
|
|||||||
|
|
||||||
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
from openapi_server.models.api_response import ApiResponse # noqa: E501
|
||||||
from openapi_server.models.pet import Pet # noqa: E501
|
from openapi_server.models.pet import Pet # noqa: E501
|
||||||
|
from openapi_server.models.pet_form import PetForm # noqa: E501
|
||||||
|
from openapi_server.models.status_enum import StatusEnum # noqa: E501
|
||||||
|
from openapi_server.models.upload_form import UploadForm # noqa: E501
|
||||||
from openapi_server.test import BaseTestCase
|
from openapi_server.test import BaseTestCase
|
||||||
|
|
||||||
|
|
||||||
@ -156,23 +159,39 @@ class TestPetController(BaseTestCase):
|
|||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
|
def test_update_pet_status_with_enum(self):
|
||||||
|
"""Test case for update_pet_status_with_enum
|
||||||
|
|
||||||
|
Set the status of a pet in the store using an enum
|
||||||
|
"""
|
||||||
|
query_string = [('status', pending)]
|
||||||
|
headers = {
|
||||||
|
'Accept': 'application/json',
|
||||||
|
}
|
||||||
|
response = self.client.open(
|
||||||
|
'/v2/pet/{pet_id}'.format(pet_id=56),
|
||||||
|
method='PATCH',
|
||||||
|
headers=headers,
|
||||||
|
query_string=query_string)
|
||||||
|
self.assert200(response,
|
||||||
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
|
||||||
@unittest.skip("application/x-www-form-urlencoded not supported by Connexion")
|
@unittest.skip("application/x-www-form-urlencoded not supported by Connexion")
|
||||||
def test_update_pet_with_form(self):
|
def test_update_pet_with_form(self):
|
||||||
"""Test case for update_pet_with_form
|
"""Test case for update_pet_with_form
|
||||||
|
|
||||||
Updates a pet in the store with form data
|
Updates a pet in the store with form data
|
||||||
"""
|
"""
|
||||||
|
pet_form = {"name":"fluffy","status":"available"}
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
}
|
}
|
||||||
data = dict(name='name_example',
|
|
||||||
status='status_example')
|
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{pet_id}'.format(pet_id=56),
|
'/v2/pet/{pet_id}'.format(pet_id=56),
|
||||||
method='POST',
|
method='POST',
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=data,
|
data=json.dumps(pet_form),
|
||||||
content_type='application/x-www-form-urlencoded')
|
content_type='application/x-www-form-urlencoded')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
@ -183,18 +202,17 @@ class TestPetController(BaseTestCase):
|
|||||||
|
|
||||||
uploads an image
|
uploads an image
|
||||||
"""
|
"""
|
||||||
|
upload_form = {"additionalMetadata":"additional metadata example","file":"c29tZSB0ZXN0IGRhdGEK"}
|
||||||
headers = {
|
headers = {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
'Authorization': 'Bearer special-key',
|
'Authorization': 'Bearer special-key',
|
||||||
}
|
}
|
||||||
data = dict(additional_metadata='additional_metadata_example',
|
|
||||||
file=(BytesIO(b'some file data'), 'file.txt'))
|
|
||||||
response = self.client.open(
|
response = self.client.open(
|
||||||
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
'/v2/pet/{pet_id}/uploadImage'.format(pet_id=56),
|
||||||
method='POST',
|
method='POST',
|
||||||
headers=headers,
|
headers=headers,
|
||||||
data=data,
|
data=json.dumps(upload_form),
|
||||||
content_type='multipart/form-data')
|
content_type='multipart/form-data')
|
||||||
self.assert200(response,
|
self.assert200(response,
|
||||||
'Response body is : ' + response.data.decode('utf-8'))
|
'Response body is : ' + response.data.decode('utf-8'))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
connexion >= 2.5.0; python_version>="3.6"
|
connexion >= 2.6.0; python_version>="3.6"
|
||||||
connexion >= 2.3.0; python_version=="3.5"
|
connexion >= 2.3.0; python_version=="3.5"
|
||||||
connexion >= 2.3.0; python_version=="3.4"
|
connexion >= 2.3.0; python_version=="3.4"
|
||||||
connexion == 2.4.0; python_version<="2.7"
|
connexion == 2.4.0; python_version<="2.7"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
connexion >= 2.5.0; python_version>="3.6"
|
connexion >= 2.6.0; python_version>="3.6"
|
||||||
connexion >= 2.3.0; python_version=="3.5"
|
connexion >= 2.3.0; python_version=="3.5"
|
||||||
connexion >= 2.3.0; python_version=="3.4"
|
connexion >= 2.3.0; python_version=="3.4"
|
||||||
connexion == 2.4.0; python_version<="2.7"
|
connexion == 2.4.0; python_version<="2.7"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
connexion >= 2.5.0; python_version>="3.6"
|
connexion >= 2.6.0; python_version>="3.6"
|
||||||
connexion >= 2.3.0; python_version=="3.5"
|
connexion >= 2.3.0; python_version=="3.5"
|
||||||
connexion >= 2.3.0; python_version=="3.4"
|
connexion >= 2.3.0; python_version=="3.4"
|
||||||
connexion == 2.4.0; python_version<="2.7"
|
connexion == 2.4.0; python_version<="2.7"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user