Skip to content

Instantly share code, notes, and snippets.

@MaryamAdnan3
Created September 1, 2023 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryamAdnan3/14186c9c1b0ac5d84b4f48368c7289f1 to your computer and use it in GitHub Desktop.
Save MaryamAdnan3/14186c9c1b0ac5d84b4f48368c7289f1 to your computer and use it in GitHub Desktop.
This is a sample Pet Store Server based on the OpenAPI 3.0 specification.
openapi: 3.0.3
info:
title: Swagger Petstore - OpenAPI 3.0
description: |-
This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
You can now help us improve the API whether it's by making changes to the definition itself or to the code.
That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
_If you're looking for the Swagger 2.0/OAS 2.0 version of Petstore, then click [here](https://editor.swagger.io/?url=https://petstore.swagger.io/v2/swagger.yaml). Alternatively, you can load via the `Edit > Load Petstore OAS 2.0` menu option!_
Some useful links:
- [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
- [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
termsOfService: http://swagger.io/terms/
contact:
email: apiteam@swagger.io
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.11
externalDocs:
description: Find out more about Swagger.
url: http://swagger.io
servers:
- url: https://petstore3.swagger.io/api/v3
description: Production server
tags:
- name: pet
description: Everything about your Pets.
externalDocs:
description: Find out more
url: http://swagger.io
- name: store
description: Access to Petstore orders.
externalDocs:
description: Find out more about our store.
url: http://swagger.io
- name: user
description: Operations about user.
paths:
/pet:
put:
tags:
- pet
summary: Update an existing pet
description: Update an existing pet by Id.
operationId: updatePet
requestBody:
description: Update an existent pet in the store.
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
required: true
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
"400":
description: Invalid ID supplied.
"404":
description: Pet not found.
"405":
description: Validation exception.
post:
tags:
- pet
summary: Add a new pet to the store
description: This endpoint adds a new pet to the store.
operationId: addPet
requestBody:
description: Create a new pet in the store.
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
required: true
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
"405":
description: Invalid input.
/pet/findByStatus:
get:
tags:
- pet
summary: Finds Pets by status
description: Multiple status values can be provided with comma separated strings
operationId: findPetsByStatus
parameters:
- name: status
in: query
description: Status values that need to be considered for filter
example: available
required: false
schema:
$ref: '#/components/schemas/Status'
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
type: array
description: List of pets matching the status criteria.
example:
- id: 10
category:
id: 1
name: Hola
name: Perrito
photoUrls:
- "/tmp/inflector2671908192094406561.tmp"
tags: []
petStatus: available
items:
$ref: "#/components/schemas/Pet"
"400":
description: Invalid status value.
/pet/findByTags:
get:
tags:
- pet
summary: Finds Pets by tags
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- name: tags
in: query
description: Tags to filter by.
example:
- tag1
- tag2
required: false
explode: true
schema:
type: array
items:
type: string
description: Tags to filter Pet.
example: tag1
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
type: array
description: Tags to filter Pet.
example:
- id: 10
category:
id: 1
name: Hola
name: Perrito
photoUrls:
- "/tmp/inflector2671908192094406561.tmp"
tags: []
petStatus: available
items:
$ref: "#/components/schemas/Pet"
"400":
description: Invalid tag value.
/pet/{petId}:
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet.
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return.
example: 10
required: true
schema:
type: integer
format: int64
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
"400":
description: Invalid ID supplied.
"404":
description: Pet not found.
security:
- api_key: []
post:
tags:
- pet
summary: Updates a pet in the store with form data
description: "This endpoint updates a pet in the store with form data."
operationId: updatePetWithForm
parameters:
- name: petId
in: path
description: ID of pet that needs to be updated.
example : 10
required: true
schema:
type: integer
format: int64
- name: name
in: query
description: Name of pet that needs to be updated.
example: Dogs
schema:
type: string
- name: status
in: query
description: Status of pet that needs to be updated.
example: availble
schema:
type: string
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: '#/components/schemas/Pet'
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : [ ]
petStatus : available
"405":
description: Invalid input.
delete:
tags:
- pet
summary: Deletes a pet
description: Delete a pet.
operationId: deletePet
parameters:
- name: petId
in: path
description: Pet id to delete.
example : 10
required: true
schema:
type: integer
format: int64
- name: api_key
in: header
description: Api key to be passed as a header.
example : api_key
required: false
schema:
type: string
responses:
"204":
description: The pet was deleted successfully.
"400":
description: Invalid pet value.
/pet/{petId}/uploadImage:
post:
tags:
- pet
summary: Uploads an image
description: This endpoint uploads an image of a pet.
operationId: uploadFile
parameters:
- name: petId
in: path
description: ID of pet to update
example : 10
required: true
schema:
type: integer
format: int64
- name: additionalMetadata
in: query
description: Additional data to pass to server.
example: Additional metadata here
required: false
schema:
type: string
requestBody:
description : Upload image of a pet.
content:
application/octet-stream:
schema:
type: string
format: binary
description: Upload image of a pet.
example: ""
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/PetImage"
example:
code: 415
type: ""
message: "HTTP 415 Unsupported Media Type"
/store/inventory:
get:
tags:
- store
summary: Returns pet inventories by status
description: Returns a map of status codes to quantities.
operationId: getInventory
responses:
"200":
description: Successful operation
content:
application/json:
schema:
description: A map of status codes to quantities.
example:
available: 15
pending: 5
sold: 10
type: object
additionalProperties:
type: integer
format: int32
security:
- api_key: []
/store/order:
post:
tags:
- store
summary: Place an order for a pet
description: Place a new order in the store.
operationId: placeOrder
requestBody:
description: Place a new order for a pet.
content:
application/json:
schema:
$ref: "#/components/schemas/Order"
example:
id : 10
petId : 198772
quantity: 7
shipDate : 2023-02-08T18:04:28Z
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/Order"
example:
id : 10
petId : 198772
quantity: 7
shipDate : 2023-02-08T18:04:28Z
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/Order"
example:
id : 10
petId : 198772
quantity: 7
shipDate : 2023-02-08T18:04:28Z
"405":
description: Invalid input.
/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 generate exceptions.
operationId: getOrderById
parameters:
- name: orderId
in: path
description: ID of order that needs to be fetched.
example : 10
required: true
schema:
type: integer
format: int64
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/Order"
example:
id : 10
petId : 198772
quantity: 7
shipDate : 2023-02-08T18:04:28Z
"400":
description: Invalid ID supplied.
"404":
description: Order not found.
delete:
tags:
- store
summary: Delete purchase order by ID
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
operationId: deleteOrder
parameters:
- name: orderId
in: path
description: ID of the order that needs to be deleted.
example : 9
required: true
schema:
type: integer
format: int64
responses:
"204":
description: Successful operation.
"400":
description: Invalid ID supplied.
"404":
description: Order not found.
/user:
post:
tags:
- user
summary: Create user
description: This can only be done by the logged in user.
operationId: createUser
requestBody:
description: Created user object.
content:
application/json:
schema:
$ref: "#/components/schemas/User"
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/User"
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/User"
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
/user/createWithList:
post:
tags:
- user
summary: Creates list of users with given input array
description: Creates list of users with given input array.
operationId: createUsersWithListInput
requestBody:
description : Create a list of users.
content:
application/json:
schema:
type: array
description: List of Users.
items:
$ref: "#/components/schemas/User"
example:
- id: 1
username: theUser
firstName: John
lastName: James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/User"
example :
id : 1
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
default:
description: Successful operation.
/user/login:
get:
tags:
- user
summary: Logs user into the system
description: This endpoint logs user into the system.
operationId: loginUser
parameters:
- name: username
in: query
description: The user name for login.
example : theUser
required: false
schema:
type: string
- name: password
in: query
description: The password for login in clear text.
example : "12345"
required: false
schema:
type: string
responses:
"200":
description: Successful operation.
headers:
X-Rate-Limit:
description: Calls per hour allowed by the user.
example: 5000
schema:
type: integer
format: int32
X-Expires-After:
description: Date in UTC when token expires.
example: 2023-02-08T18:04:28Z
schema:
type: string
format: date-time
content:
application/json:
schema:
type: string
description: Logged in user session.
example: "450961056275307520"
"400":
description: Invalid username/password supplied.
/user/logout:
get:
tags:
- user
summary: Logs out current logged in user session.
description: This endpoint logs out current logged in user session.
operationId: logoutUser
parameters: []
responses:
"200":
description: Successful operation.
/user/{name}:
get:
tags:
- user
summary: Get user by username
description: This endpoint helps retrieve user by username.
operationId: getUserByName
parameters:
- name: name
in: path
description: "The name that needs to be fetched. Use user1 for testing."
example : theUser
required: true
schema:
type: string
responses:
"200":
description: Successful operation.
content:
application/json:
schema:
$ref: "#/components/schemas/User"
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
"400":
description: Invalid username supplied
"404":
description: User not found
put:
tags:
- user
summary: Update user
description: This can only be done by the logged in user.
operationId: updateUser
parameters:
- name: name
in: path
description: Username that need to be deleted.
example : theUser
required: true
schema:
type: string
requestBody:
description: Update an existent user in the store.
content:
application/json:
schema:
$ref: "#/components/schemas/User"
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/User"
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
responses:
"200":
description: Successful operation.
delete:
tags:
- user
summary: Delete user
description: This can only be done by the logged in user.
operationId: deleteUser
parameters:
- name: name
in: path
description: The name that needs to be deleted.
example : John
required: true
schema:
type: string
responses:
"204":
description: The User was deleted successfully.
"400":
description: Invalid username supplied.
"404":
description: User not found.
components:
schemas:
Order:
type: object
description : Order details.
example:
id : 10
petId : 198772
quantity: 7
shipDate : 2023-02-08T18:04:28Z
properties:
id:
type: integer
format: int64
description: Order id.
example: 10
petId:
type: integer
format: int64
description: Id of pet.
example: 198772
quantity:
type: integer
format: int32
description : Quantity of pets.
example: 7
shipDate:
type: string
format: date-time
description: Date of shipment.
example : 2023-02-08T18:04:28Z
orderStatus:
$ref: '#/components/schemas/OrderStatus'
complete:
type: boolean
description: Shipment status.
example: true
Category:
type: object
description : Categories of pet.
example :
id : 1
name : Dogs
properties:
id:
type: integer
format: int64
description: Id of pet.
example: 1
name:
type: string
description : Name of pet
example: Dogs
User:
type: object
description: Information of user.
example :
id : 10
username : theUser
firstName : John
lastName : James
email: john@email.com
password: "12345"
phone: "12345"
userStatus: 1
properties:
id:
type: integer
format: int64
description: Id of user.
example: 10
username:
type: string
description : Unique username.
example: theUser
firstName:
type: string
description: First name of user.
example: John
lastName:
type: string
example: James
description: Last name of user.
email:
type: string
description: Email of user.
example: john@email.com
password:
type: string
description: Password of user.
example: "12345"
phone:
type: string
description: Phone number of user.
example: "12345"
userStatus:
type: integer
description: User Status.
format: int32
example: 1
Tag:
type: object
description: Tags that need to be considered for filter.
example:
id: 1
name : Perrito
properties:
id:
type: integer
format: int64
description: Id of pet.
example: 1
name:
type: string
description: Name of pet.
example: Perrito
Pet:
required:
- name
- photoUrls
type: object
description: Returns a single pet.
example:
id : 10
category :
id: 1
name : Hola
name : Perrito
photoUrls: [/tmp/inflector2671908192094406561.tmp]
tags : []
petStatus : available
properties:
name:
type: string
description: Name of pet.
example: doggie
photoUrls:
type: array
description: Pet image urls.
example : [ url1, url2]
items:
type: string
description: Pet image url.
example : url1
id:
type: integer
format: int64
description: Id of pet
example: 10
category:
$ref: "#/components/schemas/Category"
tags:
type: array
description: Tags to filter pets.
example:
- id: 1
name: tag1
- id: 2
name: tag2
- id: 3
name: tag3
items:
$ref: "#/components/schemas/Tag"
petStatus:
$ref: '#/components/schemas/Status'
PetImage:
type: object
description: Upload a pet image.
example:
code: 415
type: ""
message: "HTTP 415 Unsupported Media Type"
properties:
code:
type: integer
description: Code.
format: int32
example: 415
type:
type: string
description: Media type.
example: ""
message:
type: string
description: Message about the uploading of image.
example: "HTTP 415 Unsupported Media Type"
Status:
type: string
description: Pet Status.
default: available
enum:
- available
- pending
- sold
OrderStatus:
type: string
description: Order Status.
example: approved
enum:
- placed
- approved
- delivered
securitySchemes:
api_key:
type: apiKey
name: api_key
in: header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment