forked from loafle/openapi-generator-original
restore petstore.yaml
This commit is contained in:
parent
c159239d1b
commit
070d87a97c
@ -1,82 +1,90 @@
|
||||
swagger: "2.0"
|
||||
swagger: '2.0'
|
||||
info:
|
||||
description: |
|
||||
This is a sample server Petstore server.
|
||||
|
||||
[Learn about Swagger](http://swagger.io) or join the IRC channel `#swagger` on irc.freenode.net.
|
||||
|
||||
For this sample, you can use the api key `special-key` to test the authorization filters
|
||||
version: "1.0.0"
|
||||
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/). 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/
|
||||
termsOfService: 'http://swagger.io/terms/'
|
||||
contact:
|
||||
name: apiteam@swagger.io
|
||||
email: apiteam@swagger.io
|
||||
license:
|
||||
name: Apache 2.0
|
||||
url: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
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:
|
||||
/pets:
|
||||
/pet:
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: Add a new pet to the store
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: addPet
|
||||
consumes:
|
||||
- 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"
|
||||
$ref: '#/definitions/Pet'
|
||||
responses:
|
||||
"405":
|
||||
'405':
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
put:
|
||||
tags:
|
||||
- pet
|
||||
summary: Update an existing pet
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: updatePet
|
||||
consumes:
|
||||
- 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"
|
||||
$ref: '#/definitions/Pet'
|
||||
responses:
|
||||
"405":
|
||||
description: Validation exception
|
||||
"404":
|
||||
description: Pet not found
|
||||
"400":
|
||||
'400':
|
||||
description: Invalid ID supplied
|
||||
'404':
|
||||
description: Pet not found
|
||||
'405':
|
||||
description: Validation exception
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
/pets/findByStatus:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
tags:
|
||||
- pet
|
||||
@ -84,204 +92,266 @@ paths:
|
||||
description: Multiple status values can be provided with comma seperated strings
|
||||
operationId: findPetsByStatus
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: query
|
||||
name: status
|
||||
- name: status
|
||||
in: query
|
||||
description: Status values that need to be considered for filter
|
||||
required: false
|
||||
required: true
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
collectionFormat: multi
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
default: available
|
||||
collectionFormat: csv
|
||||
responses:
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/Pet"
|
||||
"400":
|
||||
$ref: '#/definitions/Pet'
|
||||
'400':
|
||||
description: Invalid status value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
/pets/findByTags:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
/pet/findByTags:
|
||||
get:
|
||||
tags:
|
||||
- pet
|
||||
summary: Finds Pets by tags
|
||||
description: Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.'
|
||||
operationId: findPetsByTags
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: query
|
||||
name: tags
|
||||
- name: tags
|
||||
in: query
|
||||
description: Tags to filter by
|
||||
required: false
|
||||
required: true
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
collectionFormat: multi
|
||||
collectionFormat: csv
|
||||
responses:
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/definitions/Pet"
|
||||
"400":
|
||||
$ref: '#/definitions/Pet'
|
||||
'400':
|
||||
description: Invalid tag value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
/pets/{petId}:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
'/pet/{petId}':
|
||||
get:
|
||||
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: getPetById
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: petId
|
||||
description: ID of pet that needs to be fetched
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet to return
|
||||
required: true
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
"404":
|
||||
description: Pet not found
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
$ref: "#/definitions/Pet"
|
||||
"400":
|
||||
$ref: '#/definitions/Pet'
|
||||
'400':
|
||||
description: Invalid ID supplied
|
||||
'404':
|
||||
description: Pet not found
|
||||
security:
|
||||
- api_key: []
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: Updates a pet in the store with form data
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: updatePetWithForm
|
||||
consumes:
|
||||
- application/x-www-form-urlencoded
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: petId
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet that needs to be updated
|
||||
required: true
|
||||
type: string
|
||||
- in: formData
|
||||
name: name
|
||||
type: integer
|
||||
format: int64
|
||||
- name: name
|
||||
in: formData
|
||||
description: Updated name of the pet
|
||||
required: true
|
||||
required: false
|
||||
type: string
|
||||
- in: formData
|
||||
name: status
|
||||
- name: status
|
||||
in: formData
|
||||
description: Updated status of the pet
|
||||
required: true
|
||||
required: false
|
||||
type: string
|
||||
responses:
|
||||
"405":
|
||||
'405':
|
||||
description: Invalid input
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
delete:
|
||||
tags:
|
||||
- pet
|
||||
summary: Deletes a pet
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: deletePet
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: header
|
||||
name: api_key
|
||||
description: ""
|
||||
required: true
|
||||
- name: api_key
|
||||
in: header
|
||||
required: false
|
||||
type: string
|
||||
- in: path
|
||||
name: petId
|
||||
- name: petId
|
||||
in: path
|
||||
description: Pet id to delete
|
||||
required: true
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
"400":
|
||||
'400':
|
||||
description: Invalid pet value
|
||||
security:
|
||||
- petstore_auth:
|
||||
- write_pets
|
||||
- read_pets
|
||||
/stores/order:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
'/pet/{petId}/uploadImage':
|
||||
post:
|
||||
tags:
|
||||
- pet
|
||||
summary: uploads an image
|
||||
description: ''
|
||||
operationId: uploadFile
|
||||
consumes:
|
||||
- multipart/form-data
|
||||
produces:
|
||||
- application/json
|
||||
parameters:
|
||||
- name: petId
|
||||
in: path
|
||||
description: ID of pet to update
|
||||
required: true
|
||||
type: integer
|
||||
format: int64
|
||||
- name: additionalMetadata
|
||||
in: formData
|
||||
description: Additional data to pass to server
|
||||
required: false
|
||||
type: string
|
||||
- name: file
|
||||
in: formData
|
||||
description: file to upload
|
||||
required: false
|
||||
type: file
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
$ref: '#/definitions/ApiResponse'
|
||||
security:
|
||||
- petstore_auth:
|
||||
- 'write:pets'
|
||||
- 'read:pets'
|
||||
/store/inventory:
|
||||
get:
|
||||
tags:
|
||||
- store
|
||||
summary: Returns pet inventories by status
|
||||
description: Returns a map of status codes to quantities
|
||||
operationId: getInventory
|
||||
produces:
|
||||
- application/json
|
||||
parameters: []
|
||||
responses:
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: integer
|
||||
format: int32
|
||||
security:
|
||||
- api_key: []
|
||||
/store/order:
|
||||
post:
|
||||
tags:
|
||||
- store
|
||||
summary: Place an order for a pet
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: placeOrder
|
||||
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"
|
||||
$ref: '#/definitions/Order'
|
||||
responses:
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
$ref: "#/definitions/Order"
|
||||
"400":
|
||||
$ref: '#/definitions/Order'
|
||||
'400':
|
||||
description: Invalid Order
|
||||
/stores/order/{orderId}:
|
||||
'/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
|
||||
description: 'For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions'
|
||||
operationId: getOrderById
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: orderId
|
||||
- name: orderId
|
||||
in: path
|
||||
description: ID of pet that needs to be fetched
|
||||
required: true
|
||||
type: string
|
||||
type: integer
|
||||
maximum: 5
|
||||
minimum: 1
|
||||
format: int64
|
||||
responses:
|
||||
"404":
|
||||
description: Order not found
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
$ref: "#/definitions/Order"
|
||||
"400":
|
||||
$ref: '#/definitions/Order'
|
||||
'400':
|
||||
description: Invalid ID supplied
|
||||
'404':
|
||||
description: Order not found
|
||||
delete:
|
||||
tags:
|
||||
- store
|
||||
@ -289,20 +359,21 @@ paths:
|
||||
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
operationId: deleteOrder
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: orderId
|
||||
- name: orderId
|
||||
in: path
|
||||
description: ID of the order that needs to be deleted
|
||||
required: true
|
||||
type: string
|
||||
minimum: 1
|
||||
responses:
|
||||
"404":
|
||||
description: Order not found
|
||||
"400":
|
||||
'400':
|
||||
description: Invalid ID supplied
|
||||
/users:
|
||||
'404':
|
||||
description: Order not found
|
||||
/user:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
@ -310,128 +381,138 @@ paths:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: createUser
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: body
|
||||
name: body
|
||||
description: Created user object
|
||||
required: false
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/User"
|
||||
$ref: '#/definitions/User'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
/users/createWithArray:
|
||||
/user/createWithArray:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Creates list of users with given input array
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: createUsersWithArrayInput
|
||||
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:
|
||||
$ref: "#/definitions/User"
|
||||
$ref: '#/definitions/User'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
/users/createWithList:
|
||||
/user/createWithList:
|
||||
post:
|
||||
tags:
|
||||
- user
|
||||
summary: Creates list of users with given input array
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: createUsersWithListInput
|
||||
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:
|
||||
$ref: "#/definitions/User"
|
||||
$ref: '#/definitions/User'
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
/users/login:
|
||||
/user/login:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Logs user into the system
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: loginUser
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: query
|
||||
name: username
|
||||
- name: username
|
||||
in: query
|
||||
description: The user name for login
|
||||
required: false
|
||||
required: true
|
||||
type: string
|
||||
- in: query
|
||||
name: password
|
||||
- name: password
|
||||
in: query
|
||||
description: The password for login in clear text
|
||||
required: false
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
type: string
|
||||
"400":
|
||||
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 toekn expires
|
||||
'400':
|
||||
description: Invalid username/password supplied
|
||||
/users/logout:
|
||||
/user/logout:
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Logs out current logged in user session
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: logoutUser
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters: []
|
||||
responses:
|
||||
default:
|
||||
description: successful operation
|
||||
/users/{username}:
|
||||
'/user/{username}':
|
||||
get:
|
||||
tags:
|
||||
- user
|
||||
summary: Get user by user name
|
||||
description: ""
|
||||
description: ''
|
||||
operationId: getUserByName
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: username
|
||||
description: The name that needs to be fetched. Use user1 for testing.
|
||||
- name: username
|
||||
in: path
|
||||
description: 'The name that needs to be fetched. Use user1 for testing. '
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"404":
|
||||
description: User not found
|
||||
"200":
|
||||
'200':
|
||||
description: successful operation
|
||||
schema:
|
||||
$ref: "#/definitions/User"
|
||||
"400":
|
||||
$ref: '#/definitions/User'
|
||||
'400':
|
||||
description: Invalid username supplied
|
||||
'404':
|
||||
description: User not found
|
||||
put:
|
||||
tags:
|
||||
- user
|
||||
@ -439,25 +520,25 @@ paths:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: updateUser
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: username
|
||||
- name: username
|
||||
in: path
|
||||
description: name that need to be deleted
|
||||
required: true
|
||||
type: string
|
||||
- in: body
|
||||
name: body
|
||||
description: Updated user object
|
||||
required: false
|
||||
required: true
|
||||
schema:
|
||||
$ref: "#/definitions/User"
|
||||
$ref: '#/definitions/User'
|
||||
responses:
|
||||
"404":
|
||||
description: User not found
|
||||
"400":
|
||||
'400':
|
||||
description: Invalid user supplied
|
||||
'404':
|
||||
description: User not found
|
||||
delete:
|
||||
tags:
|
||||
- user
|
||||
@ -465,32 +546,69 @@ paths:
|
||||
description: This can only be done by the logged in user.
|
||||
operationId: deleteUser
|
||||
produces:
|
||||
- application/json
|
||||
- application/xml
|
||||
- application/json
|
||||
parameters:
|
||||
- in: path
|
||||
name: username
|
||||
- name: username
|
||||
in: path
|
||||
description: The name that needs to be deleted
|
||||
required: true
|
||||
type: string
|
||||
responses:
|
||||
"404":
|
||||
description: User not found
|
||||
"400":
|
||||
'400':
|
||||
description: Invalid username supplied
|
||||
'404':
|
||||
description: User not found
|
||||
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
|
||||
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:
|
||||
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
|
||||
Category:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
xml:
|
||||
name: Category
|
||||
User:
|
||||
type: object
|
||||
properties:
|
||||
@ -513,7 +631,9 @@ definitions:
|
||||
type: integer
|
||||
format: int32
|
||||
description: User Status
|
||||
Category:
|
||||
xml:
|
||||
name: User
|
||||
Tag:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
@ -521,6 +641,8 @@ definitions:
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
xml:
|
||||
name: Tag
|
||||
Pet:
|
||||
type: object
|
||||
required:
|
||||
@ -531,46 +653,43 @@ definitions:
|
||||
type: integer
|
||||
format: int64
|
||||
category:
|
||||
$ref: "#/definitions/Category"
|
||||
$ref: '#/definitions/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: "#/definitions/Tag"
|
||||
$ref: '#/definitions/Tag'
|
||||
status:
|
||||
type: string
|
||||
description: pet status in the store
|
||||
Tag:
|
||||
enum:
|
||||
- available
|
||||
- pending
|
||||
- sold
|
||||
xml:
|
||||
name: Pet
|
||||
ApiResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
Order:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
petId:
|
||||
type: integer
|
||||
format: int64
|
||||
quantity:
|
||||
code:
|
||||
type: integer
|
||||
format: int32
|
||||
shipDate:
|
||||
type:
|
||||
type: string
|
||||
format: date-time
|
||||
status:
|
||||
message:
|
||||
type: string
|
||||
description: Order Status
|
||||
complete:
|
||||
type: boolean
|
||||
externalDocs:
|
||||
description: Find out more about Swagger
|
||||
url: 'http://swagger.io'
|
||||
|
@ -5,6 +5,5 @@ import (
|
||||
|
||||
type Category struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
@ -6,10 +6,9 @@ import (
|
||||
|
||||
type Order struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
PetId int64 `json:"petId,omitempty"`
|
||||
Quantity int32 `json:"quantity,omitempty"`
|
||||
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
|
||||
PetId int64 `json:"petId,omitempty"`
|
||||
Quantity int32 `json:"quantity,omitempty"`
|
||||
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Complete bool `json:"complete,omitempty"`
|
||||
}
|
||||
|
@ -5,10 +5,9 @@ import (
|
||||
|
||||
type Pet struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Category Category `json:"category,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
|
||||
Category Category `json:"category,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||
Tags []Tag `json:"tags,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
package swagger
|
||||
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/dghubble/sling"
|
||||
|
||||
"os"
|
||||
)
|
||||
|
||||
type PetApi struct {
|
||||
@ -30,7 +29,6 @@ func NewPetApiWithBasePath(basePath string) *PetApi{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
@ -43,20 +41,17 @@ func (a PetApi) AddPet (body Pet) (error) {
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets"
|
||||
|
||||
path := "/v2/pet"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -94,29 +89,26 @@ func (a PetApi) AddPet (body Pet) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
* @param apiKey
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
* @return void
|
||||
*/
|
||||
//func (a PetApi) DeletePet (apiKey string, petId int64) (error) {
|
||||
func (a PetApi) DeletePet (apiKey string, petId int64) (error) {
|
||||
//func (a PetApi) DeletePet (petId int64, apiKey string) (error) {
|
||||
func (a PetApi) DeletePet (petId int64, apiKey string) (error) {
|
||||
|
||||
_sling := sling.New().Delete(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets/{petId}"
|
||||
path := "/v2/pet/{petId}"
|
||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
@ -127,7 +119,6 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) {
|
||||
|
||||
|
||||
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
@ -160,7 +151,6 @@ func (a PetApi) DeletePet (apiKey string, petId int64) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma seperated strings
|
||||
@ -173,26 +163,22 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) {
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets/findByStatus"
|
||||
|
||||
path := "/v2/pet/findByStatus"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
type QueryParams struct {
|
||||
status []string `url:"status,omitempty"`
|
||||
|
||||
}
|
||||
_sling = _sling.QueryStruct(&QueryParams{ status: status })
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
|
||||
var successPayload = new([]Pet)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
@ -227,7 +213,6 @@ func (a PetApi) FindPetsByStatus (status []string) ([]Pet, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
@ -240,26 +225,22 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) {
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets/findByTags"
|
||||
|
||||
path := "/v2/pet/findByTags"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
type QueryParams struct {
|
||||
tags []string `url:"tags,omitempty"`
|
||||
|
||||
}
|
||||
_sling = _sling.QueryStruct(&QueryParams{ tags: tags })
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
|
||||
var successPayload = new([]Pet)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
@ -294,11 +275,10 @@ func (a PetApi) FindPetsByTags (tags []string) ([]Pet, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
* Returns a single pet
|
||||
* @param petId ID of pet to return
|
||||
* @return Pet
|
||||
*/
|
||||
//func (a PetApi) GetPetById (petId int64) (Pet, error) {
|
||||
@ -307,22 +287,19 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) {
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets/{petId}"
|
||||
path := "/v2/pet/{petId}"
|
||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
|
||||
var successPayload = new(Pet)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
@ -357,7 +334,6 @@ func (a PetApi) GetPetById (petId int64) (Pet, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
@ -370,20 +346,17 @@ func (a PetApi) UpdatePet (body Pet) (error) {
|
||||
_sling := sling.New().Put(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets"
|
||||
|
||||
path := "/v2/pet"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -421,7 +394,6 @@ func (a PetApi) UpdatePet (body Pet) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
@ -430,21 +402,19 @@ func (a PetApi) UpdatePet (body Pet) (error) {
|
||||
* @param status Updated status of the pet
|
||||
* @return void
|
||||
*/
|
||||
//func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) {
|
||||
func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (error) {
|
||||
//func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) {
|
||||
func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) {
|
||||
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pets/{petId}"
|
||||
path := "/v2/pet/{petId}"
|
||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
@ -453,13 +423,11 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er
|
||||
type FormParams struct {
|
||||
name string `url:"name,omitempty"`
|
||||
status string `url:"status,omitempty"`
|
||||
|
||||
}
|
||||
_sling = _sling.BodyForm(&FormParams{ name: name,status: status })
|
||||
|
||||
|
||||
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
@ -492,5 +460,69 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er
|
||||
|
||||
return err
|
||||
}
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
* @param petId ID of pet to update
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
* @return ApiResponse
|
||||
*/
|
||||
//func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error) {
|
||||
func (a PetApi) UploadFile (petId int64, additionalMetadata string, file *os.File) (ApiResponse, error) {
|
||||
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/pet/{petId}/uploadImage"
|
||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
type FormParams struct {
|
||||
additionalMetadata string `url:"additionalMetadata,omitempty"`
|
||||
file *os.File `url:"file,omitempty"`
|
||||
}
|
||||
_sling = _sling.BodyForm(&FormParams{ additionalMetadata: additionalMetadata,file: file })
|
||||
|
||||
var successPayload = new(ApiResponse)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
var failurePayload map[string]interface{}
|
||||
|
||||
httpResponse, err := _sling.Receive(successPayload, &failurePayload)
|
||||
|
||||
if err == nil {
|
||||
// err == nil only means that there wasn't a sub-application-layer error (e.g. no network error)
|
||||
if failurePayload != nil {
|
||||
// If the failurePayload is present, there likely was some kind of non-2xx status
|
||||
// returned (and a JSON payload error present)
|
||||
var str []byte
|
||||
str, err = json.Marshal(failurePayload)
|
||||
if err == nil { // For safety, check for an error marshalling... probably superfluous
|
||||
// This will return the JSON error body as a string
|
||||
err = errors.New(string(str))
|
||||
}
|
||||
} else {
|
||||
// So, there was no network-type error, and nothing in the failure payload,
|
||||
// but we should still check the status code
|
||||
if httpResponse == nil {
|
||||
// This should never happen...
|
||||
err = errors.New("No HTTP Response received.")
|
||||
} else if code := httpResponse.StatusCode; 200 > code || code > 299 {
|
||||
err = errors.New("HTTP Error: " + string(httpResponse.StatusCode))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package swagger
|
||||
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/dghubble/sling"
|
||||
|
||||
)
|
||||
|
||||
type StoreApi struct {
|
||||
@ -30,7 +28,6 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
@ -43,15 +40,13 @@ func (a StoreApi) DeleteOrder (orderId string) (error) {
|
||||
_sling := sling.New().Delete(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/stores/order/{orderId}"
|
||||
path := "/v2/store/order/{orderId}"
|
||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
@ -60,7 +55,6 @@ func (a StoreApi) DeleteOrder (orderId string) (error) {
|
||||
|
||||
|
||||
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
@ -93,34 +87,87 @@ func (a StoreApi) DeleteOrder (orderId string) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @return Order
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
* @return map[string]int32
|
||||
*/
|
||||
//func (a StoreApi) GetOrderById (orderId string) (Order, error) {
|
||||
func (a StoreApi) GetOrderById (orderId string) (Order, error) {
|
||||
//func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||
func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/stores/order/{orderId}"
|
||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
path := "/v2/store/inventory"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
var successPayload = new(map[string]int32)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
var failurePayload map[string]interface{}
|
||||
|
||||
httpResponse, err := _sling.Receive(successPayload, &failurePayload)
|
||||
|
||||
if err == nil {
|
||||
// err == nil only means that there wasn't a sub-application-layer error (e.g. no network error)
|
||||
if failurePayload != nil {
|
||||
// If the failurePayload is present, there likely was some kind of non-2xx status
|
||||
// returned (and a JSON payload error present)
|
||||
var str []byte
|
||||
str, err = json.Marshal(failurePayload)
|
||||
if err == nil { // For safety, check for an error marshalling... probably superfluous
|
||||
// This will return the JSON error body as a string
|
||||
err = errors.New(string(str))
|
||||
}
|
||||
} else {
|
||||
// So, there was no network-type error, and nothing in the failure payload,
|
||||
// but we should still check the status code
|
||||
if httpResponse == nil {
|
||||
// This should never happen...
|
||||
err = errors.New("No HTTP Response received.")
|
||||
} else if code := httpResponse.StatusCode; 200 > code || code > 299 {
|
||||
err = errors.New("HTTP Error: " + string(httpResponse.StatusCode))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @return Order
|
||||
*/
|
||||
//func (a StoreApi) GetOrderById (orderId int64) (Order, error) {
|
||||
func (a StoreApi) GetOrderById (orderId int64) (Order, error) {
|
||||
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/store/order/{orderId}"
|
||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
var successPayload = new(Order)
|
||||
|
||||
@ -156,7 +203,6 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
@ -169,20 +215,17 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) {
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/stores/order"
|
||||
|
||||
path := "/v2/store/order"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -220,5 +263,3 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,6 +5,5 @@ import (
|
||||
|
||||
type Tag struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
@ -5,12 +5,11 @@ import (
|
||||
|
||||
type User struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
UserStatus int32 `json:"userStatus,omitempty"`
|
||||
|
||||
Username string `json:"username,omitempty"`
|
||||
FirstName string `json:"firstName,omitempty"`
|
||||
LastName string `json:"lastName,omitempty"`
|
||||
Email string `json:"email,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
Phone string `json:"phone,omitempty"`
|
||||
UserStatus int32 `json:"userStatus,omitempty"`
|
||||
}
|
||||
|
@ -1,13 +1,11 @@
|
||||
package swagger
|
||||
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"fmt"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/dghubble/sling"
|
||||
|
||||
)
|
||||
|
||||
type UserApi struct {
|
||||
@ -30,7 +28,6 @@ func NewUserApiWithBasePath(basePath string) *UserApi{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
@ -43,20 +40,17 @@ func (a UserApi) CreateUser (body User) (error) {
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users"
|
||||
|
||||
path := "/v2/user"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -94,7 +88,6 @@ func (a UserApi) CreateUser (body User) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
@ -107,20 +100,17 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) {
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/createWithArray"
|
||||
|
||||
path := "/v2/user/createWithArray"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -158,7 +148,6 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
@ -171,20 +160,17 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) {
|
||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/createWithList"
|
||||
|
||||
path := "/v2/user/createWithList"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -222,7 +208,6 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* This can only be done by the logged in user.
|
||||
@ -235,15 +220,13 @@ func (a UserApi) DeleteUser (username string) (error) {
|
||||
_sling := sling.New().Delete(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/{username}"
|
||||
path := "/v2/user/{username}"
|
||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
@ -252,7 +235,6 @@ func (a UserApi) DeleteUser (username string) (error) {
|
||||
|
||||
|
||||
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
@ -285,7 +267,6 @@ func (a UserApi) DeleteUser (username string) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
@ -298,22 +279,19 @@ func (a UserApi) GetUserByName (username string) (User, error) {
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/{username}"
|
||||
path := "/v2/user/{username}"
|
||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
|
||||
var successPayload = new(User)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
@ -348,7 +326,6 @@ func (a UserApi) GetUserByName (username string) (User, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
@ -362,27 +339,23 @@ func (a UserApi) LoginUser (username string, password string) (string, error) {
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/login"
|
||||
|
||||
path := "/v2/user/login"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
type QueryParams struct {
|
||||
username string `url:"username,omitempty"`
|
||||
password string `url:"password,omitempty"`
|
||||
|
||||
password string `url:"password,omitempty"`
|
||||
}
|
||||
_sling = _sling.QueryStruct(&QueryParams{ username: username,password: password })
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
|
||||
var successPayload = new(string)
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
@ -417,7 +390,6 @@ func (a UserApi) LoginUser (username string, password string) (string, error) {
|
||||
|
||||
return *successPayload, err
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
@ -429,14 +401,12 @@ func (a UserApi) LogoutUser () (error) {
|
||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/logout"
|
||||
|
||||
path := "/v2/user/logout"
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
@ -445,7 +415,6 @@ func (a UserApi) LogoutUser () (error) {
|
||||
|
||||
|
||||
|
||||
|
||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
||||
// FIXME: This is in the absence of this Go generator honoring the non-2xx
|
||||
// response (error) models, which needs to be implemented at some point.
|
||||
@ -478,7 +447,6 @@ func (a UserApi) LogoutUser () (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
@ -492,21 +460,18 @@ func (a UserApi) UpdateUser (username string, body User) (error) {
|
||||
_sling := sling.New().Put(a.Configuration.BasePath)
|
||||
|
||||
// create path and map variables
|
||||
path := "/v2/users/{username}"
|
||||
path := "/v2/user/{username}"
|
||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||
|
||||
|
||||
_sling = _sling.Path(path)
|
||||
|
||||
|
||||
// accept header
|
||||
accepts := []string { "application/json", "application/xml" }
|
||||
accepts := []string { "application/xml", "application/json" }
|
||||
for key := range accepts {
|
||||
_sling = _sling.Set("Accept", accepts[key])
|
||||
break // only use the first Accept
|
||||
}
|
||||
|
||||
|
||||
// body params
|
||||
_sling = _sling.BodyJSON(body)
|
||||
|
||||
@ -544,5 +509,3 @@ func (a UserApi) UpdateUser (username string, body User) (error) {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ func main() {
|
||||
s.AddPet(newPet)
|
||||
|
||||
// test POST(form)
|
||||
s.UpdatePetWithForm("12830", "golang", "available")
|
||||
s.UpdatePetWithForm(12830, "golang", "available")
|
||||
|
||||
// test GET
|
||||
resp, err := s.GetPetById(12830)
|
||||
|
Loading…
x
Reference in New Issue
Block a user