From 4e9d1e8c793414f235531b7784fa0ba3cc221b2a Mon Sep 17 00:00:00 2001 From: hjacobs Date: Fri, 22 Jan 2016 22:35:37 +0100 Subject: [PATCH] re-generate flaskConnexion sample server with latest changes --- .../server/petstore/flaskConnexion/README.md | 13 +- samples/server/petstore/flaskConnexion/app.py | 7 +- .../flaskConnexion/swagger/swagger.yaml | 270 +++++++++--------- 3 files changed, 147 insertions(+), 143 deletions(-) diff --git a/samples/server/petstore/flaskConnexion/README.md b/samples/server/petstore/flaskConnexion/README.md index 2b8c96e6170..933d4ec2723 100644 --- a/samples/server/petstore/flaskConnexion/README.md +++ b/samples/server/petstore/flaskConnexion/README.md @@ -2,26 +2,27 @@ ## Overview This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the -[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This -is an example of building a swagger-enabled flask server. +[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This +is an example of building a swagger-enabled Flask server. -This example uses the [connexion](https://github.com/zalando/connexion) library on top of Flask. +This example uses the [Connexion](https://github.com/zalando/connexion) library on top of Flask. To run the server, please execute the following: ``` +sudo pip3 install -U connexion # install Connexion from PyPI python3 app.py ``` and open your browser to here: ``` -http://localhost:8080/ui +http://localhost:8080/v2/ui/ ``` -Your swagger definition lives here: +Your Swagger definition lives here: ``` -http://localhost:8080/swagger.json +http://localhost:8080/v2/swagger.json ``` diff --git a/samples/server/petstore/flaskConnexion/app.py b/samples/server/petstore/flaskConnexion/app.py index ae021b58df9..1e2fed4d9ea 100644 --- a/samples/server/petstore/flaskConnexion/app.py +++ b/samples/server/petstore/flaskConnexion/app.py @@ -3,7 +3,6 @@ import connexion if __name__ == '__main__': - app = connexion.App(__name__, 8080, - 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 <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() + 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.run(port=8080) diff --git a/samples/server/petstore/flaskConnexion/swagger/swagger.yaml b/samples/server/petstore/flaskConnexion/swagger/swagger.yaml index 1a4ff85e60a..d086d6ff49d 100644 --- a/samples/server/petstore/flaskConnexion/swagger/swagger.yaml +++ b/samples/server/petstore/flaskConnexion/swagger/swagger.yaml @@ -2,9 +2,9 @@ swagger: "2.0" info: description: "This is a sample server Petstore server. You can find out more about\ - \ Swagger at http://swagger.io or on irc.freenode.net,\ - \ #swagger. For this sample, you can use the api key \"special-key\" to test\ - \ the authorization filters" + \ 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." version: "1.0.0" title: "Swagger Petstore" termsOfService: "http://swagger.io/terms/" @@ -15,6 +15,19 @@ info: url: "http://www.apache.org/licenses/LICENSE-2.0.html" host: "petstore.swagger.io" 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: - "http" paths: @@ -29,22 +42,18 @@ paths: - "application/json" - "application/xml" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" - required: false + required: true schema: $ref: "#/definitions/Pet" responses: 405: description: "Invalid input" - security: - - petstore_auth: - - "write:pets" - - "read:pets" x-tags: - tag: "pet" put: @@ -57,13 +66,13 @@ paths: - "application/json" - "application/xml" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "Pet object that needs to be added to the store" - required: false + required: true schema: $ref: "#/definitions/Pet" responses: @@ -73,10 +82,6 @@ paths: description: "Pet not found" 405: description: "Validation exception" - security: - - petstore_auth: - - "write:pets" - - "read:pets" x-tags: - tag: "pet" /pet/findByStatus: @@ -84,21 +89,25 @@ paths: tags: - "pet" summary: "Finds Pets by status" - description: "Multiple status values can be provided with comma seperated strings" + description: "Multiple status values can be provided with comma separated strings" operationId: "controllers.default_controller.find_pets_by_status" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "status" in: "query" description: "Status values that need to be considered for filter" - required: false + required: true type: "array" items: type: "string" + enum: + - "available" + - "pending" + - "sold" + default: "available" collectionFormat: "multi" - default: "available" responses: 200: description: "successful operation" @@ -108,10 +117,6 @@ paths: $ref: "#/definitions/Pet" 400: description: "Invalid status value" - security: - - petstore_auth: - - "write:pets" - - "read:pets" x-tags: - tag: "pet" /pet/findByTags: @@ -119,17 +124,17 @@ paths: tags: - "pet" summary: "Finds Pets by tags" - description: "Muliple tags can be provided with comma seperated strings. Use\ + description: "Muliple tags can be provided with comma separated strings. Use\ \ tag1, tag2, tag3 for testing." operationId: "controllers.default_controller.find_pets_by_tags" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "tags" in: "query" description: "Tags to filter by" - required: false + required: true type: "array" items: type: "string" @@ -143,10 +148,7 @@ paths: $ref: "#/definitions/Pet" 400: description: "Invalid tag value" - security: - - petstore_auth: - - "write:pets" - - "read:pets" + deprecated: true x-tags: - tag: "pet" /pet/{petId}: @@ -154,16 +156,15 @@ paths: tags: - "pet" summary: "Find pet by ID" - description: "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate\ - \ API error conditions" + description: "Returns a single pet" operationId: "controllers.default_controller.get_pet_by_id" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "petId" in: "path" - description: "ID of pet that needs to be fetched" + description: "ID of pet to return" required: true type: "integer" format: "int64" @@ -178,9 +179,6 @@ paths: description: "Pet not found" security: - api_key: [] - - petstore_auth: - - "write:pets" - - "read:pets" x-tags: - tag: "pet" post: @@ -192,14 +190,15 @@ paths: consumes: - "application/x-www-form-urlencoded" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "petId" in: "path" description: "ID of pet that needs to be updated" required: true - type: "string" + type: "integer" + format: "int64" - name: "name" in: "formData" description: "Updated name of the pet" @@ -213,10 +212,6 @@ paths: responses: 405: description: "Invalid input" - security: - - petstore_auth: - - "write:pets" - - "read:pets" x-tags: - tag: "pet" delete: @@ -226,12 +221,11 @@ paths: description: "" operationId: "controllers.default_controller.delete_pet" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "api_key" in: "header" - description: "" required: false type: "string" - name: "petId" @@ -242,11 +236,9 @@ paths: format: "int64" responses: 400: - description: "Invalid pet value" - security: - - petstore_auth: - - "write:pets" - - "read:pets" + description: "Invalid ID supplied" + 404: + description: "Pet not found" x-tags: - tag: "pet" /pet/{petId}/uploadImage: @@ -260,7 +252,6 @@ paths: - "multipart/form-data" produces: - "application/json" - - "application/xml" parameters: - name: "petId" in: "path" @@ -279,12 +270,10 @@ paths: required: false type: "file" responses: - default: + 200: description: "successful operation" - security: - - petstore_auth: - - "write:pets" - - "read:pets" + schema: + $ref: "#/definitions/ApiResponse" x-tags: - tag: "pet" /store/inventory: @@ -296,7 +285,6 @@ paths: operationId: "controllers.default_controller.get_inventory" produces: - "application/json" - - "application/xml" parameters: [] responses: 200: @@ -318,13 +306,13 @@ paths: description: "" operationId: "controllers.default_controller.place_order" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "order placed for purchasing the pet" - required: false + required: true schema: $ref: "#/definitions/Order" responses: @@ -341,18 +329,21 @@ paths: 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" + description: "For valid response try integer IDs with value >= 1 and <= 10.\ + \ Other values will generated exceptions" operationId: "controllers.default_controller.get_order_by_id" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "orderId" in: "path" description: "ID of pet that needs to be fetched" required: true - type: "string" + type: "integer" + maximum: 10.0 + minimum: 1.0 + format: "int64" responses: 200: description: "successful operation" @@ -368,18 +359,20 @@ paths: 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" + description: "For valid response try integer IDs with positive integer value.\ + \ Negative or non-integer values will generate API errors" operationId: "controllers.default_controller.delete_order" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "orderId" in: "path" description: "ID of the order that needs to be deleted" required: true - type: "string" + type: "integer" + minimum: 1.0 + format: "int64" responses: 400: description: "Invalid ID supplied" @@ -395,13 +388,13 @@ paths: description: "This can only be done by the logged in user." operationId: "controllers.default_controller.create_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "Created user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -417,13 +410,13 @@ paths: description: "" operationId: "controllers.default_controller.create_users_with_array_input" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "List of user object" - required: false + required: true schema: type: "array" items: @@ -441,13 +434,13 @@ paths: description: "" operationId: "controllers.default_controller.create_users_with_list_input" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - in: "body" name: "body" description: "List of user object" - required: false + required: true schema: type: "array" items: @@ -465,24 +458,33 @@ paths: description: "" operationId: "controllers.default_controller.login_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "query" description: "The user name for login" - required: false + required: true type: "string" - name: "password" in: "query" description: "The password for login in clear text" - required: false + required: true type: "string" responses: 200: description: "successful operation" schema: 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: description: "Invalid username/password supplied" x-tags: @@ -495,8 +497,8 @@ paths: description: "" operationId: "controllers.default_controller.logout_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: [] responses: default: @@ -511,8 +513,8 @@ paths: description: "" operationId: "controllers.default_controller.get_user_by_name" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -524,16 +526,6 @@ paths: description: "successful operation" schema: $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: description: "Invalid username supplied" 404: @@ -547,18 +539,18 @@ paths: description: "This can only be done by the logged in user." operationId: "controllers.default_controller.update_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" - description: "name that need to be deleted" + description: "name that need to be updated" required: true type: "string" - in: "body" name: "body" description: "Updated user object" - required: false + required: true schema: $ref: "#/definitions/User" responses: @@ -575,8 +567,8 @@ paths: description: "This can only be done by the logged in user." operationId: "controllers.default_controller.delete_user" produces: - - "application/json" - "application/xml" + - "application/json" parameters: - name: "username" in: "path" @@ -591,19 +583,40 @@ paths: x-tags: - tag: "user" securityDefinitions: - 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" api_key: type: "apiKey" name: "api_key" in: "header" 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: + type: "object" properties: id: type: "integer" @@ -627,6 +640,7 @@ definitions: xml: name: "User" Category: + type: "object" properties: id: type: "integer" @@ -635,7 +649,28 @@ definitions: type: "string" xml: 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: + type: "object" required: - "name" - "photoUrls" @@ -671,37 +706,6 @@ definitions: - "sold" xml: name: "Pet" - Tag: - properties: - id: - type: "integer" - format: "int64" - name: - type: "string" - xml: - name: "Tag" - Order: - 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" - xml: - name: "Order" +externalDocs: + description: "Find out more about Swagger" + url: "http://swagger.io"