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:
|
info:
|
||||||
description: |
|
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.'
|
||||||
This is a sample server Petstore server.
|
version: 1.0.0
|
||||||
|
|
||||||
[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"
|
|
||||||
title: Swagger Petstore
|
title: Swagger Petstore
|
||||||
termsOfService: http://swagger.io/terms/
|
termsOfService: 'http://swagger.io/terms/'
|
||||||
contact:
|
contact:
|
||||||
name: apiteam@swagger.io
|
email: apiteam@swagger.io
|
||||||
license:
|
license:
|
||||||
name: Apache 2.0
|
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
|
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:
|
||||||
/pets:
|
/pet:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
summary: Add a new pet to the store
|
summary: Add a new pet to the store
|
||||||
description: ""
|
description: ''
|
||||||
operationId: addPet
|
operationId: addPet
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
- application/xml
|
- application/xml
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
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: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Pet"
|
$ref: '#/definitions/Pet'
|
||||||
responses:
|
responses:
|
||||||
"405":
|
'405':
|
||||||
description: Invalid input
|
description: Invalid input
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write_pets
|
- 'write:pets'
|
||||||
- read_pets
|
- 'read:pets'
|
||||||
put:
|
put:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
summary: Update an existing pet
|
summary: Update an existing pet
|
||||||
description: ""
|
description: ''
|
||||||
operationId: updatePet
|
operationId: updatePet
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
- application/xml
|
- application/xml
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
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: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Pet"
|
$ref: '#/definitions/Pet'
|
||||||
responses:
|
responses:
|
||||||
"405":
|
'400':
|
||||||
description: Validation exception
|
|
||||||
"404":
|
|
||||||
description: Pet not found
|
|
||||||
"400":
|
|
||||||
description: Invalid ID supplied
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
|
'405':
|
||||||
|
description: Validation exception
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write_pets
|
- 'write:pets'
|
||||||
- read_pets
|
- 'read:pets'
|
||||||
/pets/findByStatus:
|
/pet/findByStatus:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
@ -84,204 +92,266 @@ paths:
|
|||||||
description: Multiple status values can be provided with comma seperated strings
|
description: Multiple status values can be provided with comma seperated strings
|
||||||
operationId: findPetsByStatus
|
operationId: findPetsByStatus
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: query
|
- name: status
|
||||||
name: status
|
in: query
|
||||||
description: Status values that need to be considered for filter
|
description: Status values that need to be considered for filter
|
||||||
required: false
|
required: true
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
collectionFormat: multi
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
default: available
|
||||||
|
collectionFormat: csv
|
||||||
responses:
|
responses:
|
||||||
"200":
|
'200':
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Pet"
|
$ref: '#/definitions/Pet'
|
||||||
"400":
|
'400':
|
||||||
description: Invalid status value
|
description: Invalid status value
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write_pets
|
- 'write:pets'
|
||||||
- read_pets
|
- 'read:pets'
|
||||||
/pets/findByTags:
|
/pet/findByTags:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
summary: Finds Pets by tags
|
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
|
operationId: findPetsByTags
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: query
|
- name: tags
|
||||||
name: tags
|
in: query
|
||||||
description: Tags to filter by
|
description: Tags to filter by
|
||||||
required: false
|
required: true
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
collectionFormat: multi
|
collectionFormat: csv
|
||||||
responses:
|
responses:
|
||||||
"200":
|
'200':
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Pet"
|
$ref: '#/definitions/Pet'
|
||||||
"400":
|
'400':
|
||||||
description: Invalid tag value
|
description: Invalid tag value
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write_pets
|
- 'write:pets'
|
||||||
- read_pets
|
- 'read:pets'
|
||||||
/pets/{petId}:
|
'/pet/{petId}':
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
summary: Find pet by ID
|
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
|
operationId: getPetById
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: petId
|
||||||
name: petId
|
in: path
|
||||||
description: ID of pet that needs to be fetched
|
description: ID of pet to return
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
responses:
|
responses:
|
||||||
"404":
|
'200':
|
||||||
description: Pet not found
|
|
||||||
"200":
|
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Pet"
|
$ref: '#/definitions/Pet'
|
||||||
"400":
|
'400':
|
||||||
description: Invalid ID supplied
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Pet not found
|
||||||
security:
|
security:
|
||||||
- api_key: []
|
- api_key: []
|
||||||
- petstore_auth:
|
|
||||||
- write_pets
|
|
||||||
- read_pets
|
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
summary: Updates a pet in the store with form data
|
summary: Updates a pet in the store with form data
|
||||||
description: ""
|
description: ''
|
||||||
operationId: updatePetWithForm
|
operationId: updatePetWithForm
|
||||||
consumes:
|
consumes:
|
||||||
- application/x-www-form-urlencoded
|
- application/x-www-form-urlencoded
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: petId
|
||||||
name: petId
|
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: string
|
type: integer
|
||||||
- in: formData
|
format: int64
|
||||||
name: name
|
- name: name
|
||||||
|
in: formData
|
||||||
description: Updated name of the pet
|
description: Updated name of the pet
|
||||||
required: true
|
required: false
|
||||||
type: string
|
type: string
|
||||||
- in: formData
|
- name: status
|
||||||
name: status
|
in: formData
|
||||||
description: Updated status of the pet
|
description: Updated status of the pet
|
||||||
required: true
|
required: false
|
||||||
type: string
|
type: string
|
||||||
responses:
|
responses:
|
||||||
"405":
|
'405':
|
||||||
description: Invalid input
|
description: Invalid input
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write_pets
|
- 'write:pets'
|
||||||
- read_pets
|
- 'read:pets'
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- pet
|
- pet
|
||||||
summary: Deletes a pet
|
summary: Deletes a pet
|
||||||
description: ""
|
description: ''
|
||||||
operationId: deletePet
|
operationId: deletePet
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: header
|
- name: api_key
|
||||||
name: api_key
|
in: header
|
||||||
description: ""
|
required: false
|
||||||
required: true
|
|
||||||
type: string
|
type: string
|
||||||
- in: path
|
- name: petId
|
||||||
name: petId
|
in: path
|
||||||
description: Pet id to delete
|
description: Pet id to delete
|
||||||
required: true
|
required: true
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
responses:
|
responses:
|
||||||
"400":
|
'400':
|
||||||
description: Invalid pet value
|
description: Invalid pet value
|
||||||
security:
|
security:
|
||||||
- petstore_auth:
|
- petstore_auth:
|
||||||
- write_pets
|
- 'write:pets'
|
||||||
- read_pets
|
- 'read:pets'
|
||||||
/stores/order:
|
'/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:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- store
|
- store
|
||||||
summary: Place an order for a pet
|
summary: Place an order for a pet
|
||||||
description: ""
|
description: ''
|
||||||
operationId: placeOrder
|
operationId: placeOrder
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
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: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Order"
|
$ref: '#/definitions/Order'
|
||||||
responses:
|
responses:
|
||||||
"200":
|
'200':
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Order"
|
$ref: '#/definitions/Order'
|
||||||
"400":
|
'400':
|
||||||
description: Invalid Order
|
description: Invalid Order
|
||||||
/stores/order/{orderId}:
|
'/store/order/{orderId}':
|
||||||
get:
|
get:
|
||||||
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 <= 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
|
operationId: getOrderById
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: orderId
|
||||||
name: orderId
|
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: string
|
type: integer
|
||||||
|
maximum: 5
|
||||||
|
minimum: 1
|
||||||
|
format: int64
|
||||||
responses:
|
responses:
|
||||||
"404":
|
'200':
|
||||||
description: Order not found
|
|
||||||
"200":
|
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Order"
|
$ref: '#/definitions/Order'
|
||||||
"400":
|
'400':
|
||||||
description: Invalid ID supplied
|
description: Invalid ID supplied
|
||||||
|
'404':
|
||||||
|
description: Order not found
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- store
|
- 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
|
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||||
operationId: deleteOrder
|
operationId: deleteOrder
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: orderId
|
||||||
name: orderId
|
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: string
|
type: string
|
||||||
|
minimum: 1
|
||||||
responses:
|
responses:
|
||||||
"404":
|
'400':
|
||||||
description: Order not found
|
|
||||||
"400":
|
|
||||||
description: Invalid ID supplied
|
description: Invalid ID supplied
|
||||||
/users:
|
'404':
|
||||||
|
description: Order not found
|
||||||
|
/user:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
@ -310,128 +381,138 @@ paths:
|
|||||||
description: This can only be done by the logged in user.
|
description: This can only be done by the logged in user.
|
||||||
operationId: createUser
|
operationId: createUser
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: body
|
- in: body
|
||||||
name: body
|
name: body
|
||||||
description: Created user object
|
description: Created user object
|
||||||
required: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/User"
|
$ref: '#/definitions/User'
|
||||||
responses:
|
responses:
|
||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
/users/createWithArray:
|
/user/createWithArray:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
summary: Creates list of users with given input array
|
summary: Creates list of users with given input array
|
||||||
description: ""
|
description: ''
|
||||||
operationId: createUsersWithArrayInput
|
operationId: createUsersWithArrayInput
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: body
|
- in: body
|
||||||
name: body
|
name: body
|
||||||
description: List of user object
|
description: List of user object
|
||||||
required: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/User"
|
$ref: '#/definitions/User'
|
||||||
responses:
|
responses:
|
||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
/users/createWithList:
|
/user/createWithList:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
summary: Creates list of users with given input array
|
summary: Creates list of users with given input array
|
||||||
description: ""
|
description: ''
|
||||||
operationId: createUsersWithListInput
|
operationId: createUsersWithListInput
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: body
|
- in: body
|
||||||
name: body
|
name: body
|
||||||
description: List of user object
|
description: List of user object
|
||||||
required: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/User"
|
$ref: '#/definitions/User'
|
||||||
responses:
|
responses:
|
||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
/users/login:
|
/user/login:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
summary: Logs user into the system
|
summary: Logs user into the system
|
||||||
description: ""
|
description: ''
|
||||||
operationId: loginUser
|
operationId: loginUser
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: query
|
- name: username
|
||||||
name: username
|
in: query
|
||||||
description: The user name for login
|
description: The user name for login
|
||||||
required: false
|
required: true
|
||||||
type: string
|
type: string
|
||||||
- in: query
|
- name: password
|
||||||
name: password
|
in: query
|
||||||
description: The password for login in clear text
|
description: The password for login in clear text
|
||||||
required: false
|
required: true
|
||||||
type: string
|
type: string
|
||||||
responses:
|
responses:
|
||||||
"200":
|
'200':
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
type: string
|
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
|
description: Invalid username/password supplied
|
||||||
/users/logout:
|
/user/logout:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
summary: Logs out current logged in user session
|
summary: Logs out current logged in user session
|
||||||
description: ""
|
description: ''
|
||||||
operationId: logoutUser
|
operationId: logoutUser
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
|
parameters: []
|
||||||
responses:
|
responses:
|
||||||
default:
|
default:
|
||||||
description: successful operation
|
description: successful operation
|
||||||
/users/{username}:
|
'/user/{username}':
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
summary: Get user by user name
|
summary: Get user by user name
|
||||||
description: ""
|
description: ''
|
||||||
operationId: getUserByName
|
operationId: getUserByName
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: username
|
||||||
name: username
|
in: path
|
||||||
description: The name that needs to be fetched. Use user1 for testing.
|
description: 'The name that needs to be fetched. Use user1 for testing. '
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
responses:
|
responses:
|
||||||
"404":
|
'200':
|
||||||
description: User not found
|
|
||||||
"200":
|
|
||||||
description: successful operation
|
description: successful operation
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/User"
|
$ref: '#/definitions/User'
|
||||||
"400":
|
'400':
|
||||||
description: Invalid username supplied
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
put:
|
put:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
@ -439,25 +520,25 @@ paths:
|
|||||||
description: This can only be done by the logged in user.
|
description: This can only be done by the logged in user.
|
||||||
operationId: updateUser
|
operationId: updateUser
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: username
|
||||||
name: username
|
in: path
|
||||||
description: name that need to be deleted
|
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: false
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/User"
|
$ref: '#/definitions/User'
|
||||||
responses:
|
responses:
|
||||||
"404":
|
'400':
|
||||||
description: User not found
|
|
||||||
"400":
|
|
||||||
description: Invalid user supplied
|
description: Invalid user supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
delete:
|
delete:
|
||||||
tags:
|
tags:
|
||||||
- user
|
- user
|
||||||
@ -465,32 +546,69 @@ paths:
|
|||||||
description: This can only be done by the logged in user.
|
description: This can only be done by the logged in user.
|
||||||
operationId: deleteUser
|
operationId: deleteUser
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
|
||||||
- application/xml
|
- application/xml
|
||||||
|
- application/json
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- name: username
|
||||||
name: username
|
in: path
|
||||||
description: The name that needs to be deleted
|
description: The name that needs to be deleted
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
responses:
|
responses:
|
||||||
"404":
|
'400':
|
||||||
description: User not found
|
|
||||||
"400":
|
|
||||||
description: Invalid username supplied
|
description: Invalid username supplied
|
||||||
|
'404':
|
||||||
|
description: User not found
|
||||||
securityDefinitions:
|
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:
|
api_key:
|
||||||
type: apiKey
|
type: apiKey
|
||||||
name: api_key
|
name: api_key
|
||||||
in: header
|
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:
|
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:
|
User:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -513,7 +631,9 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
description: User Status
|
description: User Status
|
||||||
Category:
|
xml:
|
||||||
|
name: User
|
||||||
|
Tag:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
@ -521,6 +641,8 @@ definitions:
|
|||||||
format: int64
|
format: int64
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
xml:
|
||||||
|
name: Tag
|
||||||
Pet:
|
Pet:
|
||||||
type: object
|
type: object
|
||||||
required:
|
required:
|
||||||
@ -531,46 +653,43 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
category:
|
category:
|
||||||
$ref: "#/definitions/Category"
|
$ref: '#/definitions/Category'
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
example: doggie
|
example: doggie
|
||||||
photoUrls:
|
photoUrls:
|
||||||
type: array
|
type: array
|
||||||
|
xml:
|
||||||
|
name: photoUrl
|
||||||
|
wrapped: true
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
tags:
|
tags:
|
||||||
type: array
|
type: array
|
||||||
|
xml:
|
||||||
|
name: tag
|
||||||
|
wrapped: true
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Tag"
|
$ref: '#/definitions/Tag'
|
||||||
status:
|
status:
|
||||||
type: string
|
type: string
|
||||||
description: pet status in the store
|
description: pet status in the store
|
||||||
Tag:
|
enum:
|
||||||
|
- available
|
||||||
|
- pending
|
||||||
|
- sold
|
||||||
|
xml:
|
||||||
|
name: Pet
|
||||||
|
ApiResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
id:
|
code:
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
name:
|
|
||||||
type: string
|
|
||||||
Order:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
id:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
petId:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
quantity:
|
|
||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
shipDate:
|
type:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
message:
|
||||||
status:
|
|
||||||
type: string
|
type: string
|
||||||
description: Order Status
|
externalDocs:
|
||||||
complete:
|
description: Find out more about Swagger
|
||||||
type: boolean
|
url: 'http://swagger.io'
|
||||||
|
@ -5,6 +5,5 @@ import (
|
|||||||
|
|
||||||
type Category struct {
|
type Category struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,9 @@ import (
|
|||||||
|
|
||||||
type Order struct {
|
type Order struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
PetId int64 `json:"petId,omitempty"`
|
PetId int64 `json:"petId,omitempty"`
|
||||||
Quantity int32 `json:"quantity,omitempty"`
|
Quantity int32 `json:"quantity,omitempty"`
|
||||||
ShipDate time.Time `json:"shipDate,omitempty"`
|
ShipDate time.Time `json:"shipDate,omitempty"`
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
Complete bool `json:"complete,omitempty"`
|
Complete bool `json:"complete,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,9 @@ import (
|
|||||||
|
|
||||||
type Pet struct {
|
type Pet struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
Category Category `json:"category,omitempty"`
|
Category Category `json:"category,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
PhotoUrls []string `json:"photoUrls,omitempty"`
|
PhotoUrls []string `json:"photoUrls,omitempty"`
|
||||||
Tags []Tag `json:"tags,omitempty"`
|
Tags []Tag `json:"tags,omitempty"`
|
||||||
Status string `json:"status,omitempty"`
|
Status string `json:"status,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package swagger
|
package swagger
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/dghubble/sling"
|
"github.com/dghubble/sling"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PetApi struct {
|
type PetApi struct {
|
||||||
@ -30,7 +29,6 @@ func NewPetApiWithBasePath(basePath string) *PetApi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new pet to the store
|
* 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)
|
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets"
|
path := "/v2/pet"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -94,29 +89,26 @@ func (a PetApi) AddPet (body Pet) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
*
|
*
|
||||||
* @param apiKey
|
|
||||||
* @param petId Pet id to delete
|
* @param petId Pet id to delete
|
||||||
|
* @param apiKey
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) DeletePet (apiKey string, petId int64) (error) {
|
//func (a PetApi) DeletePet (petId int64, apiKey string) (error) {
|
||||||
func (a PetApi) DeletePet (apiKey string, petId int64) (error) {
|
func (a PetApi) DeletePet (petId int64, apiKey string) (error) {
|
||||||
|
|
||||||
_sling := sling.New().Delete(a.Configuration.BasePath)
|
_sling := sling.New().Delete(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets/{petId}"
|
path := "/v2/pet/{petId}"
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
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.
|
// 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
|
// 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.
|
// 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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
* Multiple status values can be provided with comma seperated strings
|
* 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)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets/findByStatus"
|
path := "/v2/pet/findByStatus"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
type QueryParams struct {
|
type QueryParams struct {
|
||||||
status []string `url:"status,omitempty"`
|
status []string `url:"status,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ status: status })
|
_sling = _sling.QueryStruct(&QueryParams{ status: status })
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var successPayload = new([]Pet)
|
var successPayload = new([]Pet)
|
||||||
|
|
||||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
// 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
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
* 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)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets/findByTags"
|
path := "/v2/pet/findByTags"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
type QueryParams struct {
|
type QueryParams struct {
|
||||||
tags []string `url:"tags,omitempty"`
|
tags []string `url:"tags,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ tags: tags })
|
_sling = _sling.QueryStruct(&QueryParams{ tags: tags })
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var successPayload = new([]Pet)
|
var successPayload = new([]Pet)
|
||||||
|
|
||||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
// 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
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
* Returns a single pet
|
||||||
* @param petId ID of pet that needs to be fetched
|
* @param petId ID of pet to return
|
||||||
* @return Pet
|
* @return Pet
|
||||||
*/
|
*/
|
||||||
//func (a PetApi) GetPetById (petId int64) (Pet, error) {
|
//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)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets/{petId}"
|
path := "/v2/pet/{petId}"
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var successPayload = new(Pet)
|
var successPayload = new(Pet)
|
||||||
|
|
||||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
// 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
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update an existing pet
|
* Update an existing pet
|
||||||
*
|
*
|
||||||
@ -370,20 +346,17 @@ func (a PetApi) UpdatePet (body Pet) (error) {
|
|||||||
_sling := sling.New().Put(a.Configuration.BasePath)
|
_sling := sling.New().Put(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets"
|
path := "/v2/pet"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -421,7 +394,6 @@ func (a PetApi) UpdatePet (body Pet) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* 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
|
* @param status Updated status of the pet
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
//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 string, name string, status string) (error) {
|
func (a PetApi) UpdatePetWithForm (petId int64, name string, status string) (error) {
|
||||||
|
|
||||||
_sling := sling.New().Post(a.Configuration.BasePath)
|
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/pets/{petId}"
|
path := "/v2/pet/{petId}"
|
||||||
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
path = strings.Replace(path, "{" + "petId" + "}", fmt.Sprintf("%v", petId), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
@ -453,13 +423,11 @@ func (a PetApi) UpdatePetWithForm (petId string, name string, status string) (er
|
|||||||
type FormParams struct {
|
type FormParams struct {
|
||||||
name string `url:"name,omitempty"`
|
name string `url:"name,omitempty"`
|
||||||
status string `url:"status,omitempty"`
|
status string `url:"status,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
_sling = _sling.BodyForm(&FormParams{ name: name,status: status })
|
_sling = _sling.BodyForm(&FormParams{ name: name,status: status })
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
// 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
|
// 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.
|
// 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
|
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
|
package swagger
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/dghubble/sling"
|
"github.com/dghubble/sling"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type StoreApi struct {
|
type StoreApi struct {
|
||||||
@ -30,7 +28,6 @@ func NewStoreApiWithBasePath(basePath string) *StoreApi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
* 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)
|
_sling := sling.New().Delete(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// 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)
|
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
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.
|
// 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
|
// 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.
|
// response (error) models, which needs to be implemented at some point.
|
||||||
@ -93,34 +87,87 @@ func (a StoreApi) DeleteOrder (orderId string) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find purchase order by ID
|
* Returns pet inventories by status
|
||||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
* Returns a map of status codes to quantities
|
||||||
* @param orderId ID of pet that needs to be fetched
|
* @return map[string]int32
|
||||||
* @return Order
|
|
||||||
*/
|
*/
|
||||||
//func (a StoreApi) GetOrderById (orderId string) (Order, error) {
|
//func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||||
func (a StoreApi) GetOrderById (orderId string) (Order, error) {
|
func (a StoreApi) GetInventory () (map[string]int32, error) {
|
||||||
|
|
||||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/stores/order/{orderId}"
|
path := "/v2/store/inventory"
|
||||||
path = strings.Replace(path, "{" + "orderId" + "}", fmt.Sprintf("%v", orderId), -1)
|
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
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)
|
var successPayload = new(Order)
|
||||||
|
|
||||||
@ -156,7 +203,6 @@ func (a StoreApi) GetOrderById (orderId string) (Order, error) {
|
|||||||
|
|
||||||
return *successPayload, err
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* 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)
|
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/stores/order"
|
path := "/v2/store/order"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -220,5 +263,3 @@ func (a StoreApi) PlaceOrder (body Order) (Order, error) {
|
|||||||
|
|
||||||
return *successPayload, err
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,5 @@ import (
|
|||||||
|
|
||||||
type Tag struct {
|
type Tag struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,12 +5,11 @@ import (
|
|||||||
|
|
||||||
type User struct {
|
type User struct {
|
||||||
Id int64 `json:"id,omitempty"`
|
Id int64 `json:"id,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
FirstName string `json:"firstName,omitempty"`
|
FirstName string `json:"firstName,omitempty"`
|
||||||
LastName string `json:"lastName,omitempty"`
|
LastName string `json:"lastName,omitempty"`
|
||||||
Email string `json:"email,omitempty"`
|
Email string `json:"email,omitempty"`
|
||||||
Password string `json:"password,omitempty"`
|
Password string `json:"password,omitempty"`
|
||||||
Phone string `json:"phone,omitempty"`
|
Phone string `json:"phone,omitempty"`
|
||||||
UserStatus int32 `json:"userStatus,omitempty"`
|
UserStatus int32 `json:"userStatus,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package swagger
|
package swagger
|
||||||
|
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"fmt"
|
"fmt"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/dghubble/sling"
|
"github.com/dghubble/sling"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UserApi struct {
|
type UserApi struct {
|
||||||
@ -30,7 +28,6 @@ func NewUserApiWithBasePath(basePath string) *UserApi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create user
|
* Create user
|
||||||
* This can only be done by the logged in 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)
|
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users"
|
path := "/v2/user"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -94,7 +88,6 @@ func (a UserApi) CreateUser (body User) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* 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)
|
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/createWithArray"
|
path := "/v2/user/createWithArray"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -158,7 +148,6 @@ func (a UserApi) CreateUsersWithArrayInput (body []User) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* 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)
|
_sling := sling.New().Post(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/createWithList"
|
path := "/v2/user/createWithList"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -222,7 +208,6 @@ func (a UserApi) CreateUsersWithListInput (body []User) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete user
|
* Delete user
|
||||||
* This can only be done by the logged in 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)
|
_sling := sling.New().Delete(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/{username}"
|
path := "/v2/user/{username}"
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
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.
|
// 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
|
// 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.
|
// response (error) models, which needs to be implemented at some point.
|
||||||
@ -285,11 +267,10 @@ func (a UserApi) DeleteUser (username string) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user by user name
|
* Get user by user name
|
||||||
*
|
*
|
||||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||||
* @return User
|
* @return User
|
||||||
*/
|
*/
|
||||||
//func (a UserApi) GetUserByName (username string) (User, error) {
|
//func (a UserApi) GetUserByName (username string) (User, error) {
|
||||||
@ -298,22 +279,19 @@ func (a UserApi) GetUserByName (username string) (User, error) {
|
|||||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/{username}"
|
path := "/v2/user/{username}"
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var successPayload = new(User)
|
var successPayload = new(User)
|
||||||
|
|
||||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
// 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
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs user into the system
|
* 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)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/login"
|
path := "/v2/user/login"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
type QueryParams struct {
|
type QueryParams struct {
|
||||||
username string `url:"username,omitempty"`
|
username string `url:"username,omitempty"`
|
||||||
password string `url:"password,omitempty"`
|
password string `url:"password,omitempty"`
|
||||||
|
|
||||||
}
|
}
|
||||||
_sling = _sling.QueryStruct(&QueryParams{ username: username,password: password })
|
_sling = _sling.QueryStruct(&QueryParams{ username: username,password: password })
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var successPayload = new(string)
|
var successPayload = new(string)
|
||||||
|
|
||||||
// We use this map (below) so that any arbitrary error JSON can be handled.
|
// 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
|
return *successPayload, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
*
|
*
|
||||||
@ -429,14 +401,12 @@ func (a UserApi) LogoutUser () (error) {
|
|||||||
_sling := sling.New().Get(a.Configuration.BasePath)
|
_sling := sling.New().Get(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/logout"
|
path := "/v2/user/logout"
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
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.
|
// 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
|
// 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.
|
// response (error) models, which needs to be implemented at some point.
|
||||||
@ -478,7 +447,6 @@ func (a UserApi) LogoutUser () (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated user
|
* Updated user
|
||||||
* This can only be done by the logged in 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)
|
_sling := sling.New().Put(a.Configuration.BasePath)
|
||||||
|
|
||||||
// create path and map variables
|
// create path and map variables
|
||||||
path := "/v2/users/{username}"
|
path := "/v2/user/{username}"
|
||||||
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
path = strings.Replace(path, "{" + "username" + "}", fmt.Sprintf("%v", username), -1)
|
||||||
|
|
||||||
|
|
||||||
_sling = _sling.Path(path)
|
_sling = _sling.Path(path)
|
||||||
|
|
||||||
|
|
||||||
// accept header
|
// accept header
|
||||||
accepts := []string { "application/json", "application/xml" }
|
accepts := []string { "application/xml", "application/json" }
|
||||||
for key := range accepts {
|
for key := range accepts {
|
||||||
_sling = _sling.Set("Accept", accepts[key])
|
_sling = _sling.Set("Accept", accepts[key])
|
||||||
break // only use the first Accept
|
break // only use the first Accept
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// body params
|
// body params
|
||||||
_sling = _sling.BodyJSON(body)
|
_sling = _sling.BodyJSON(body)
|
||||||
|
|
||||||
@ -544,5 +509,3 @@ func (a UserApi) UpdateUser (username string, body User) (error) {
|
|||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ func main() {
|
|||||||
s.AddPet(newPet)
|
s.AddPet(newPet)
|
||||||
|
|
||||||
// test POST(form)
|
// test POST(form)
|
||||||
s.UpdatePetWithForm("12830", "golang", "available")
|
s.UpdatePetWithForm(12830, "golang", "available")
|
||||||
|
|
||||||
// test GET
|
// test GET
|
||||||
resp, err := s.GetPetById(12830)
|
resp, err := s.GetPetById(12830)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user