Created
December 20, 2018 12:23
-
-
Save kakwa/42281517fc7fa5eb2b296256edb48d77 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_statement | |
import time | |
import swagger_client | |
from swagger_client.rest import ApiException | |
from pprint import pprint | |
# create an instance of the API class | |
api_instance = swagger_client.DefaultApi() | |
body = { | |
"id" : 42, | |
"name" : "Georges", | |
"tag" : "dog" | |
} # Pet | | |
try: | |
api_instance.pets_post(body) | |
except ApiException as e: | |
print("Exception when calling DefaultApi->petsPost: %s\n" % e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
swagger: "2.0" | |
info: | |
version: "1.0.0" | |
title: "Swagger Petstore" | |
description: "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification" | |
termsOfService: "http://swagger.io/terms/" | |
contact: | |
name: "Swagger API Team" | |
license: | |
name: "MIT" | |
host: "petstore.swagger.io" | |
basePath: "/api" | |
schemes: | |
- "http" | |
consumes: | |
- "application/json" | |
produces: | |
- "application/json" | |
paths: | |
/pets: | |
post: | |
description: "Create a pet" | |
responses: | |
"200": | |
description: "Pet created" | |
parameters: | |
- in: body | |
name: body | |
required: true | |
schema: | |
$ref: '#/definitions/Pet' | |
x-example: | |
id: 42 | |
name: Georges | |
tag: dog | |
definitions: | |
Pet: | |
type: "object" | |
required: | |
- "id" | |
- "name" | |
properties: | |
id: | |
type: "integer" | |
format: "int64" | |
name: | |
type: "string" | |
tag: | |
type: "string" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment