add support for python2

This commit is contained in:
wing328 2016-04-12 00:43:13 +08:00
parent 3e13f69b53
commit 38903aa7f3
6 changed files with 520 additions and 175 deletions

View File

@ -25,6 +25,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
public static final String CONTROLLER_PACKAGE = "controllerPackage"; public static final String CONTROLLER_PACKAGE = "controllerPackage";
public static final String DEFAULT_CONTROLLER = "defaultController"; public static final String DEFAULT_CONTROLLER = "defaultController";
public static final String SUPPORT_PYTHON2= "supportPython2";
protected String apiVersion = "1.0.0"; protected String apiVersion = "1.0.0";
protected int serverPort = 8080; protected int serverPort = 8080;
@ -105,11 +106,17 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
"", "",
"README.md") "README.md")
); );
supportingFiles.add(new SupportingFile("__init__.mustache",
"",
"__init__.py")
);
cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package"). cliOptions.add(new CliOption(CONTROLLER_PACKAGE, "controller package").
defaultValue("controllers")); defaultValue("controllers"));
cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller"). cliOptions.add(new CliOption(DEFAULT_CONTROLLER, "default controller").
defaultValue("default_controller")); defaultValue("default_controller"));
cliOptions.add(new CliOption(SUPPORT_PYTHON2, "support python2").
defaultValue("false"));
} }
@Override @Override
@ -124,6 +131,7 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
this.controllerPackage = "controllers"; this.controllerPackage = "controllers";
additionalProperties.put(CONTROLLER_PACKAGE, this.controllerPackage); additionalProperties.put(CONTROLLER_PACKAGE, this.controllerPackage);
} }
if (additionalProperties.containsKey(DEFAULT_CONTROLLER)) { if (additionalProperties.containsKey(DEFAULT_CONTROLLER)) {
this.defaultController = additionalProperties.get(DEFAULT_CONTROLLER).toString(); this.defaultController = additionalProperties.get(DEFAULT_CONTROLLER).toString();
} }
@ -132,11 +140,19 @@ public class FlaskConnexionCodegen extends DefaultCodegen implements CodegenConf
additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController); additionalProperties.put(DEFAULT_CONTROLLER, this.defaultController);
} }
if (Boolean.TRUE.equals(additionalProperties.get(SUPPORT_PYTHON2))) {
additionalProperties.put(SUPPORT_PYTHON2, Boolean.TRUE);
}
if(!new java.io.File(controllerPackage + File.separator + defaultController + ".py").exists()) { if(!new java.io.File(controllerPackage + File.separator + defaultController + ".py").exists()) {
supportingFiles.add(new SupportingFile("controller.mustache", supportingFiles.add(new SupportingFile("controller.mustache",
controllerPackage, controllerPackage,
defaultController + ".py") defaultController + ".py")
); );
supportingFiles.add(new SupportingFile("__init__.mustache",
controllerPackage,
"__init__.py")
);
} }
} }

View File

@ -3,9 +3,9 @@
{{#operations}} {{#operations}}
{{#operation}} {{#operation}}
def {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) -> str: def {{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{^supportPython2}} -> str{{/supportPython2}}:
return 'do some magic!' return 'do some magic!'
{{/operation}} {{/operation}}
{{/operations}} {{/operations}}
{{/apis}} {{/apis}}
{{/apiInfo}} {{/apiInfo}}

View File

@ -4,5 +4,5 @@ import connexion
if __name__ == '__main__': if __name__ == '__main__':
app = connexion.App(__name__, specification_dir='./swagger/') app = connexion.App(__name__, specification_dir='./swagger/')
app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.'}) app.add_api('swagger.yaml', arguments={'title': 'This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters'})
app.run(port=8080) app.run(port=8080)

View File

@ -1,46 +1,13 @@
def create_user(body) -> str:
return 'do some magic!'
def create_users_with_array_input(body) -> str:
return 'do some magic!'
def create_users_with_list_input(body) -> str:
return 'do some magic!'
def login_user(username, password) -> str:
return 'do some magic!'
def logout_user() -> str:
return 'do some magic!'
def get_user_by_name(username) -> str:
return 'do some magic!'
def update_user(username, body) -> str:
return 'do some magic!'
def delete_user(username) -> str:
return 'do some magic!'
def get_inventory() -> str:
return 'do some magic!'
def place_order(body) -> str:
return 'do some magic!'
def get_order_by_id(orderId) -> str:
return 'do some magic!'
def delete_order(orderId) -> str:
return 'do some magic!'
def update_pet(body) -> str:
return 'do some magic!'
def add_pet(body) -> str: def add_pet(body) -> str:
return 'do some magic!' return 'do some magic!'
def add_pet_using_byte_array(body) -> str:
return 'do some magic!'
def delete_pet(petId, apiKey) -> str:
return 'do some magic!'
def find_pets_by_status(status) -> str: def find_pets_by_status(status) -> str:
return 'do some magic!' return 'do some magic!'
@ -50,11 +17,59 @@ def find_pets_by_tags(tags) -> str:
def get_pet_by_id(petId) -> str: def get_pet_by_id(petId) -> str:
return 'do some magic!' return 'do some magic!'
def update_pet_with_form(petId, name, status) -> str: def get_pet_by_id_in_object(petId) -> str:
return 'do some magic!' return 'do some magic!'
def delete_pet(petId, apiKey) -> str: def pet_pet_idtesting_byte_arraytrue_get(petId) -> str:
return 'do some magic!'
def update_pet(body) -> str:
return 'do some magic!'
def update_pet_with_form(petId, name, status) -> str:
return 'do some magic!' return 'do some magic!'
def upload_file(petId, additionalMetadata, file) -> str: def upload_file(petId, additionalMetadata, file) -> str:
return 'do some magic!' return 'do some magic!'
def delete_order(orderId) -> str:
return 'do some magic!'
def find_orders_by_status(status) -> str:
return 'do some magic!'
def get_inventory() -> str:
return 'do some magic!'
def get_inventory_in_object() -> str:
return 'do some magic!'
def get_order_by_id(orderId) -> str:
return 'do some magic!'
def place_order(body) -> str:
return 'do some magic!'
def create_user(body) -> str:
return 'do some magic!'
def create_users_with_array_input(body) -> str:
return 'do some magic!'
def create_users_with_list_input(body) -> str:
return 'do some magic!'
def delete_user(username) -> str:
return 'do some magic!'
def get_user_by_name(username) -> str:
return 'do some magic!'
def login_user(username, password) -> str:
return 'do some magic!'
def logout_user() -> str:
return 'do some magic!'
def update_user(username, body) -> str:
return 'do some magic!'

View File

@ -2,9 +2,9 @@
swagger: "2.0" swagger: "2.0"
info: info:
description: "This is a sample server Petstore server. You can find out more about\ description: "This is a sample server Petstore server. You can find out more about\
\ Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).\ \ Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net,\
\ For this sample, you can use the api key `special-key` to test the authorization\ \ #swagger. For this sample, you can use the api key \"special-key\" to test\
\ filters." \ the authorization filters"
version: "1.0.0" version: "1.0.0"
title: "Swagger Petstore" title: "Swagger Petstore"
termsOfService: "http://swagger.io/terms/" termsOfService: "http://swagger.io/terms/"
@ -15,19 +15,6 @@ info:
url: "http://www.apache.org/licenses/LICENSE-2.0.html" url: "http://www.apache.org/licenses/LICENSE-2.0.html"
host: "petstore.swagger.io" host: "petstore.swagger.io"
basePath: "/v2" basePath: "/v2"
tags:
- name: "pet"
description: "Everything about your Pets"
externalDocs:
description: "Find out more"
url: "http://swagger.io"
- name: "store"
description: "Access to Petstore orders"
- name: "user"
description: "Operations about user"
externalDocs:
description: "Find out more about our store"
url: "http://swagger.io"
schemes: schemes:
- "http" - "http"
paths: paths:
@ -42,18 +29,22 @@ paths:
- "application/json" - "application/json"
- "application/xml" - "application/xml"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
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: false
schema: schema:
$ref: "#/definitions/Pet" $ref: "#/definitions/Pet"
responses: responses:
405: 405:
description: "Invalid input" description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
put: put:
@ -66,13 +57,13 @@ paths:
- "application/json" - "application/json"
- "application/xml" - "application/xml"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
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: false
schema: schema:
$ref: "#/definitions/Pet" $ref: "#/definitions/Pet"
responses: responses:
@ -82,6 +73,10 @@ paths:
description: "Pet not found" description: "Pet not found"
405: 405:
description: "Validation exception" description: "Validation exception"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
/pet/findByStatus: /pet/findByStatus:
@ -92,13 +87,13 @@ paths:
description: "Multiple status values can be provided with comma separated strings" description: "Multiple status values can be provided with comma separated strings"
operationId: "controllers.default_controller.find_pets_by_status" operationId: "controllers.default_controller.find_pets_by_status"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "status" - name: "status"
in: "query" in: "query"
description: "Status values that need to be considered for filter" description: "Status values that need to be considered for query"
required: true required: false
type: "array" type: "array"
items: items:
type: "string" type: "string"
@ -106,8 +101,12 @@ paths:
- "available" - "available"
- "pending" - "pending"
- "sold" - "sold"
default: "available"
collectionFormat: "multi" collectionFormat: "multi"
default: "available"
enum:
- "available"
- "pending"
- "sold"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
@ -117,6 +116,10 @@ paths:
$ref: "#/definitions/Pet" $ref: "#/definitions/Pet"
400: 400:
description: "Invalid status value" description: "Invalid status value"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
/pet/findByTags: /pet/findByTags:
@ -124,17 +127,17 @@ paths:
tags: tags:
- "pet" - "pet"
summary: "Finds Pets by tags" summary: "Finds Pets by tags"
description: "Muliple tags can be provided with comma separated strings. Use\ description: "Muliple tags can be provided with comma seperated strings. Use\
\ tag1, tag2, tag3 for testing." \ tag1, tag2, tag3 for testing."
operationId: "controllers.default_controller.find_pets_by_tags" operationId: "controllers.default_controller.find_pets_by_tags"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "tags" - name: "tags"
in: "query" in: "query"
description: "Tags to filter by" description: "Tags to filter by"
required: true required: false
type: "array" type: "array"
items: items:
type: "string" type: "string"
@ -148,7 +151,10 @@ paths:
$ref: "#/definitions/Pet" $ref: "#/definitions/Pet"
400: 400:
description: "Invalid tag value" description: "Invalid tag value"
deprecated: true security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
/pet/{petId}: /pet/{petId}:
@ -156,15 +162,16 @@ paths:
tags: tags:
- "pet" - "pet"
summary: "Find pet by ID" summary: "Find pet by ID"
description: "Returns a single pet" description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
operationId: "controllers.default_controller.get_pet_by_id" operationId: "controllers.default_controller.get_pet_by_id"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "petId" - name: "petId"
in: "path" in: "path"
description: "ID of pet to return" description: "ID of pet that needs to be fetched"
required: true required: true
type: "integer" type: "integer"
format: "int64" format: "int64"
@ -179,6 +186,9 @@ paths:
description: "Pet not found" description: "Pet not found"
security: security:
- api_key: [] - api_key: []
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
post: post:
@ -190,15 +200,14 @@ paths:
consumes: consumes:
- "application/x-www-form-urlencoded" - "application/x-www-form-urlencoded"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "petId" - name: "petId"
in: "path" in: "path"
description: "ID of pet that needs to be updated" description: "ID of pet that needs to be updated"
required: true required: true
type: "integer" type: "string"
format: "int64"
- name: "name" - name: "name"
in: "formData" in: "formData"
description: "Updated name of the pet" description: "Updated name of the pet"
@ -212,6 +221,10 @@ paths:
responses: responses:
405: 405:
description: "Invalid input" description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
delete: delete:
@ -221,11 +234,12 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.delete_pet" operationId: "controllers.default_controller.delete_pet"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "api_key" - name: "api_key"
in: "header" in: "header"
description: ""
required: false required: false
type: "string" type: "string"
- name: "petId" - name: "petId"
@ -236,9 +250,11 @@ paths:
format: "int64" format: "int64"
responses: responses:
400: 400:
description: "Invalid ID supplied" description: "Invalid pet value"
404: security:
description: "Pet not found" - petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
/pet/{petId}/uploadImage: /pet/{petId}/uploadImage:
@ -252,6 +268,7 @@ paths:
- "multipart/form-data" - "multipart/form-data"
produces: produces:
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "petId" - name: "petId"
in: "path" in: "path"
@ -269,13 +286,151 @@ paths:
description: "file to upload" description: "file to upload"
required: false required: false
type: "file" type: "file"
responses:
default:
description: "successful operation"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/pet/{petId}?response=inline_arbitrary_object:
get:
tags:
- "pet"
summary: "Fake endpoint to test inline arbitrary object return by 'Find pet\
\ by ID'"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
operationId: "controllers.default_controller.get_pet_by_id_in_object"
produces:
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
format: "int64"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
schema: schema:
$ref: "#/definitions/ApiResponse" $ref: "#/definitions/inline_response_200"
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
security:
- api_key: []
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags: x-tags:
- tag: "pet" - tag: "pet"
/pet/{petId}?testing_byte_array=true:
get:
tags:
- "pet"
summary: "Fake endpoint to test byte array return by 'Find pet by ID'"
description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\
\ API error conditions"
operationId: "controllers.default_controller.pet_pet_idtesting_byte_arraytrue_get"
produces:
- "application/json"
- "application/xml"
parameters:
- name: "petId"
in: "path"
description: "ID of pet that needs to be fetched"
required: true
type: "integer"
format: "int64"
responses:
200:
description: "successful operation"
schema:
type: "string"
format: "binary"
400:
description: "Invalid ID supplied"
404:
description: "Pet not found"
security:
- api_key: []
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/pet?testing_byte_array=true:
post:
tags:
- "pet"
summary: "Fake endpoint to test byte array in body parameter for adding a new\
\ pet to the store"
description: ""
operationId: "controllers.default_controller.add_pet_using_byte_array"
consumes:
- "application/json"
- "application/xml"
produces:
- "application/json"
- "application/xml"
parameters:
- in: "body"
name: "body"
description: "Pet object in the form of byte array"
required: false
schema:
type: "string"
format: "binary"
responses:
405:
description: "Invalid input"
security:
- petstore_auth:
- "write:pets"
- "read:pets"
x-tags:
- tag: "pet"
/store/findByStatus:
get:
tags:
- "store"
summary: "Finds orders by status"
description: "A single status value can be provided as a string"
operationId: "controllers.default_controller.find_orders_by_status"
produces:
- "application/json"
- "application/xml"
parameters:
- name: "status"
in: "query"
description: "Status value that needs to be considered for query"
required: false
type: "string"
default: "placed"
enum:
- "placed"
- "approved"
- "delivered"
responses:
200:
description: "successful operation"
schema:
type: "array"
items:
$ref: "#/definitions/Order"
400:
description: "Invalid status value"
security:
- test_api_client_secret: []
test_api_client_id: []
x-tags:
- tag: "store"
/store/inventory: /store/inventory:
get: get:
tags: tags:
@ -285,6 +440,7 @@ paths:
operationId: "controllers.default_controller.get_inventory" operationId: "controllers.default_controller.get_inventory"
produces: produces:
- "application/json" - "application/json"
- "application/xml"
parameters: [] parameters: []
responses: responses:
200: 200:
@ -298,6 +454,28 @@ paths:
- api_key: [] - api_key: []
x-tags: x-tags:
- tag: "store" - tag: "store"
/store/inventory?response=arbitrary_object:
get:
tags:
- "store"
summary: "Fake endpoint to test arbitrary object return by 'Get inventory'"
description: "Returns an arbitrary object which is actually a map of status\
\ codes to quantities"
operationId: "controllers.default_controller.get_inventory_in_object"
produces:
- "application/json"
- "application/xml"
parameters: []
responses:
200:
description: "successful operation"
schema:
type: "object"
properties: {}
security:
- api_key: []
x-tags:
- tag: "store"
/store/order: /store/order:
post: post:
tags: tags:
@ -306,13 +484,13 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.place_order" operationId: "controllers.default_controller.place_order"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "order placed for purchasing the pet" description: "order placed for purchasing the pet"
required: true required: false
schema: schema:
$ref: "#/definitions/Order" $ref: "#/definitions/Order"
responses: responses:
@ -322,6 +500,9 @@ paths:
$ref: "#/definitions/Order" $ref: "#/definitions/Order"
400: 400:
description: "Invalid Order" description: "Invalid Order"
security:
- test_api_client_secret: []
test_api_client_id: []
x-tags: x-tags:
- tag: "store" - tag: "store"
/store/order/{orderId}: /store/order/{orderId}:
@ -329,21 +510,18 @@ paths:
tags: tags:
- "store" - "store"
summary: "Find purchase order by ID" summary: "Find purchase order by ID"
description: "For valid response try integer IDs with value >= 1 and <= 10.\ description: "For valid response try integer IDs with value <= 5 or > 10. Other\
\ Other values will generated exceptions" \ values will generated exceptions"
operationId: "controllers.default_controller.get_order_by_id" operationId: "controllers.default_controller.get_order_by_id"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "orderId" - name: "orderId"
in: "path" in: "path"
description: "ID of pet that needs to be fetched" description: "ID of pet that needs to be fetched"
required: true required: true
type: "integer" type: "string"
maximum: 10.0
minimum: 1.0
format: "int64"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
@ -353,26 +531,27 @@ paths:
description: "Invalid ID supplied" description: "Invalid ID supplied"
404: 404:
description: "Order not found" description: "Order not found"
security:
- test_api_key_header: []
- test_api_key_query: []
x-tags: x-tags:
- tag: "store" - tag: "store"
delete: delete:
tags: tags:
- "store" - "store"
summary: "Delete purchase order by ID" summary: "Delete purchase order by ID"
description: "For valid response try integer IDs with positive integer value.\ description: "For valid response try integer IDs with value < 1000. Anything\
\ Negative or non-integer values will generate API errors" \ above 1000 or nonintegers will generate API errors"
operationId: "controllers.default_controller.delete_order" operationId: "controllers.default_controller.delete_order"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "orderId" - name: "orderId"
in: "path" in: "path"
description: "ID of the order that needs to be deleted" description: "ID of the order that needs to be deleted"
required: true required: true
type: "integer" type: "string"
minimum: 1.0
format: "int64"
responses: responses:
400: 400:
description: "Invalid ID supplied" description: "Invalid ID supplied"
@ -388,13 +567,13 @@ paths:
description: "This can only be done by the logged in user." description: "This can only be done by the logged in user."
operationId: "controllers.default_controller.create_user" operationId: "controllers.default_controller.create_user"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "Created user object" description: "Created user object"
required: true required: false
schema: schema:
$ref: "#/definitions/User" $ref: "#/definitions/User"
responses: responses:
@ -410,13 +589,13 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.create_users_with_array_input" operationId: "controllers.default_controller.create_users_with_array_input"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "List of user object" description: "List of user object"
required: true required: false
schema: schema:
type: "array" type: "array"
items: items:
@ -434,13 +613,13 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.create_users_with_list_input" operationId: "controllers.default_controller.create_users_with_list_input"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- in: "body" - in: "body"
name: "body" name: "body"
description: "List of user object" description: "List of user object"
required: true required: false
schema: schema:
type: "array" type: "array"
items: items:
@ -458,33 +637,24 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.login_user" operationId: "controllers.default_controller.login_user"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "username" - name: "username"
in: "query" in: "query"
description: "The user name for login" description: "The user name for login"
required: true required: false
type: "string" type: "string"
- name: "password" - name: "password"
in: "query" in: "query"
description: "The password for login in clear text" description: "The password for login in clear text"
required: true required: false
type: "string" type: "string"
responses: responses:
200: 200:
description: "successful operation" description: "successful operation"
schema: schema:
type: "string" type: "string"
headers:
X-Rate-Limit:
type: "integer"
format: "int32"
description: "calls per hour allowed by the user"
X-Expires-After:
type: "string"
format: "date-time"
description: "date in UTC when token expires"
400: 400:
description: "Invalid username/password supplied" description: "Invalid username/password supplied"
x-tags: x-tags:
@ -497,8 +667,8 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.logout_user" operationId: "controllers.default_controller.logout_user"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: [] parameters: []
responses: responses:
default: default:
@ -513,8 +683,8 @@ paths:
description: "" description: ""
operationId: "controllers.default_controller.get_user_by_name" operationId: "controllers.default_controller.get_user_by_name"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
@ -526,6 +696,16 @@ paths:
description: "successful operation" description: "successful operation"
schema: schema:
$ref: "#/definitions/User" $ref: "#/definitions/User"
examples:
application/json:
id: 1
username: "johnp"
firstName: "John"
lastName: "Public"
email: "johnp@swagger.io"
password: "-secret-"
phone: "0123456789"
userStatus: 0
400: 400:
description: "Invalid username supplied" description: "Invalid username supplied"
404: 404:
@ -539,18 +719,18 @@ paths:
description: "This can only be done by the logged in user." description: "This can only be done by the logged in user."
operationId: "controllers.default_controller.update_user" operationId: "controllers.default_controller.update_user"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
description: "name that need to be updated" description: "name that need to be deleted"
required: true required: true
type: "string" type: "string"
- in: "body" - in: "body"
name: "body" name: "body"
description: "Updated user object" description: "Updated user object"
required: true required: false
schema: schema:
$ref: "#/definitions/User" $ref: "#/definitions/User"
responses: responses:
@ -567,8 +747,8 @@ paths:
description: "This can only be done by the logged in user." description: "This can only be done by the logged in user."
operationId: "controllers.default_controller.delete_user" operationId: "controllers.default_controller.delete_user"
produces: produces:
- "application/xml"
- "application/json" - "application/json"
- "application/xml"
parameters: parameters:
- name: "username" - name: "username"
in: "path" in: "path"
@ -580,43 +760,42 @@ paths:
description: "Invalid username supplied" description: "Invalid username supplied"
404: 404:
description: "User not found" description: "User not found"
security:
- test_http_basic: []
x-tags: x-tags:
- tag: "user" - tag: "user"
securityDefinitions: securityDefinitions:
test_api_key_header:
type: "apiKey"
name: "test_api_key_header"
in: "header"
api_key: api_key:
type: "apiKey" type: "apiKey"
name: "api_key" name: "api_key"
in: "header" in: "header"
test_http_basic:
type: "basic"
test_api_client_secret:
type: "apiKey"
name: "x-test_api_client_secret"
in: "header"
test_api_client_id:
type: "apiKey"
name: "x-test_api_client_id"
in: "header"
test_api_key_query:
type: "apiKey"
name: "test_api_key_query"
in: "query"
petstore_auth:
type: "oauth2"
authorizationUrl: "http://petstore.swagger.io/api/oauth/dialog"
flow: "implicit"
scopes:
write:pets: "modify pets in your account"
read:pets: "read your pets"
definitions: definitions:
Order:
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"
User: User:
type: "object"
properties: properties:
id: id:
type: "integer" type: "integer"
@ -640,7 +819,6 @@ definitions:
xml: xml:
name: "User" name: "User"
Category: Category:
type: "object"
properties: properties:
id: id:
type: "integer" type: "integer"
@ -649,28 +827,7 @@ definitions:
type: "string" type: "string"
xml: xml:
name: "Category" name: "Category"
Tag:
type: "object"
properties:
id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
ApiResponse:
type: "object"
properties:
code:
type: "integer"
format: "int32"
type:
type: "string"
message:
type: "string"
Pet: Pet:
type: "object"
required: required:
- "name" - "name"
- "photoUrls" - "photoUrls"
@ -706,6 +863,163 @@ definitions:
- "sold" - "sold"
xml: xml:
name: "Pet" name: "Pet"
externalDocs: Tag:
description: "Find out more about Swagger" properties:
url: "http://swagger.io" id:
type: "integer"
format: "int64"
name:
type: "string"
xml:
name: "Tag"
Order:
properties:
id:
type: "integer"
format: "int64"
readOnly: true
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"
xml:
name: "Order"
$special[model.name]:
properties:
$special[property.name]:
type: "integer"
format: "int64"
xml:
name: "$special[model.name]"
Return:
properties:
return:
type: "integer"
format: "int32"
description: "Model for testing reserved words"
xml:
name: "Return"
Name:
required:
- "name"
properties:
name:
type: "integer"
format: "int32"
snake_case:
type: "integer"
format: "int32"
readOnly: true
description: "Model for testing model name same as property name"
xml:
name: "Name"
200_response:
properties:
name:
type: "integer"
format: "int32"
description: "Model for testing model name starting with number"
xml:
name: "Name"
Dog:
allOf:
- $ref: "#/definitions/Animal"
- type: "object"
properties:
breed:
type: "string"
Cat:
allOf:
- $ref: "#/definitions/Animal"
- type: "object"
properties:
declawed:
type: "boolean"
Animal:
type: "object"
required:
- "className"
discriminator: "className"
properties:
className:
type: "string"
format_test:
type: "object"
required:
- "number"
properties:
integer:
type: "integer"
int32:
type: "integer"
format: "int32"
int64:
type: "integer"
format: "int64"
number:
type: "number"
float:
type: "number"
format: "float"
double:
type: "number"
format: "double"
string:
type: "string"
byte:
type: "string"
format: "byte"
binary:
type: "string"
format: "binary"
date:
type: "string"
format: "date"
dateTime:
type: "string"
format: "date-time"
password:
type: "string"
format: "password"
inline_response_200:
required:
- "id"
properties:
tags:
type: "array"
items:
$ref: "#/definitions/Tag"
id:
type: "integer"
format: "int64"
category:
type: "object"
properties: {}
status:
type: "string"
description: "pet status in the store"
enum:
- "available"
- "pending"
- "sold"
name:
type: "string"
example: "doggie"
photoUrls:
type: "array"
items:
type: "string"