Skip to content

Instantly share code, notes, and snippets.

@kakwa
Last active December 20, 2018 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kakwa/0d192ee6f354b305cbfa931a20133fac to your computer and use it in GitHub Desktop.
Save kakwa/0d192ee6f354b305cbfa931a20133fac to your computer and use it in GitHub Desktop.
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 = # Pet |
try:
api_instance.pets_post(body)
except ApiException as e:
print("Exception when calling DefaultApi->petsPost: %s\n" % e)
---
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'
definitions:
Pet:
type: "object"
required:
- "id"
- "name"
properties:
id:
type: "integer"
format: "int64"
example: 42
name:
type: "string"
example: 'Georges'
tag:
type: "string"
example: "dog"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment