Last active
October 12, 2017 14:22
-
-
Save nazarhussain/ba59ab1e84821ce011bdaf52ff5a1449 to your computer and use it in GitHub Desktop.
Swagger 2.0 vs OAS3.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: '2.0' | |
info: | |
description: This is a sample server Petstore server. | |
version: 1.0.0 | |
title: Swagger Petstore | |
host: virtserver.swaggerhub.com | |
basePath: /nazarhussain/Swagger2/1.0.0 | |
schemes: | |
- https | |
- http | |
paths: | |
/pet: | |
post: | |
summary: Add a new pet to the store | |
operationId: addPet | |
consumes: | |
- application/json | |
- application/xml | |
produces: | |
- application/json | |
- application/xml | |
parameters: | |
- in: body | |
name: body | |
description: Pet object that needs to be added to the store | |
required: true | |
schema: | |
$ref: '#/definitions/Pet' | |
responses: | |
405: | |
description: Invalid input | |
security: | |
- petstore_auth: | |
- write:pets | |
- read:pets | |
/pet/{petId}: | |
get: | |
tags: | |
- pet | |
summary: Find pet by ID | |
description: Returns a single pet | |
operationId: getPetById | |
produces: | |
- application/json | |
- application/xml | |
parameters: | |
- name: petId | |
in: path | |
description: ID of pet to return | |
required: true | |
type: integer | |
format: int64 | |
responses: | |
200: | |
description: successful operation | |
schema: | |
$ref: '#/definitions/Pet' | |
400: | |
description: Invalid ID supplied | |
404: | |
description: Pet not found | |
security: | |
- api_key: [] | |
securityDefinitions: | |
petstore_auth: | |
type: oauth2 | |
authorizationUrl: http://petstore.swagger.io/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 | |
definitions: | |
Category: | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int64 | |
name: | |
type: string | |
xml: | |
name: Category | |
User: | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int64 | |
username: | |
type: string | |
firstName: | |
type: string | |
lastName: | |
type: string | |
email: | |
type: string | |
password: | |
type: string | |
phone: | |
type: string | |
userStatus: | |
type: integer | |
format: int32 | |
description: User Status | |
xml: | |
name: User | |
Tag: | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int64 | |
name: | |
type: string | |
xml: | |
name: Tag | |
Pet: | |
type: object | |
required: | |
- name | |
- photoUrls | |
properties: | |
id: | |
type: integer | |
format: int64 | |
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' | |
status: | |
type: string | |
description: pet status in the store | |
enum: | |
- available | |
- pending | |
- sold | |
xml: | |
name: Pet | |
ApiResponse: | |
type: object | |
properties: | |
code: | |
type: integer | |
format: int32 | |
type: | |
type: string | |
message: | |
type: string | |
externalDocs: | |
description: Find out more about Swagger | |
url: http://swagger.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: 3.0.0 | |
info: | |
description: This is a sample server Petstore server. | |
version: "1.0.0" | |
title: Swagger Petstore | |
servers: | |
- url: virtserver.swaggerhub.com/nazarhussain/Swagger2/1.0.0 | |
description: Sweagger Hub Server | |
paths: | |
/pet: | |
post: | |
summary: Add a new pet to the store | |
operationId: addPet | |
responses: | |
'405': | |
description: Invalid input | |
security: | |
- petstore_auth: | |
- 'write:pets' | |
- 'read:pets' | |
requestBody: | |
$ref: '#/components/requestBodies/Pet' | |
'/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 | |
required: true | |
schema: | |
type: integer | |
format: int64 | |
responses: | |
'200': | |
description: successful operation | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Pet' | |
application/xml: | |
schema: | |
$ref: '#/components/schemas/Pet' | |
'400': | |
description: Invalid ID supplied | |
'404': | |
description: Pet not found | |
security: | |
- api_key: [] | |
components: | |
schemas: | |
Category: | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int64 | |
name: | |
type: string | |
xml: | |
name: Category | |
User: | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int64 | |
username: | |
type: string | |
firstName: | |
type: string | |
lastName: | |
type: string | |
email: | |
type: string | |
password: | |
type: string | |
phone: | |
type: string | |
userStatus: | |
type: integer | |
format: int32 | |
description: User Status | |
xml: | |
name: User | |
Tag: | |
type: object | |
properties: | |
id: | |
type: integer | |
format: int64 | |
name: | |
type: string | |
xml: | |
name: Tag | |
Pet: | |
type: object | |
required: | |
- name | |
- photoUrls | |
properties: | |
id: | |
type: integer | |
format: int64 | |
category: | |
$ref: '#/components/schemas/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: '#/components/schemas/Tag' | |
status: | |
type: string | |
description: pet status in the store | |
enum: | |
- available | |
- pending | |
- sold | |
xml: | |
name: Pet | |
ApiResponse: | |
type: object | |
properties: | |
code: | |
type: integer | |
format: int32 | |
type: | |
type: string | |
message: | |
type: string | |
requestBodies: | |
Pet: | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Pet' | |
application/xml: | |
schema: | |
$ref: '#/components/schemas/Pet' | |
description: Pet object that needs to be added to the store | |
required: true | |
UserArray: | |
content: | |
application/json: | |
schema: | |
type: array | |
items: | |
$ref: '#/components/schemas/User' | |
description: List of user object | |
required: true | |
securitySchemes: | |
petstore_auth: | |
type: oauth2 | |
flows: | |
implicit: | |
authorizationUrl: 'http://petstore.swagger.io/oauth/dialog' | |
scopes: | |
'write:pets': modify pets in your account | |
'read:pets': read your pets | |
api_key: | |
type: apiKey | |
name: api_key | |
in: header | |
externalDocs: | |
description: Find out more about Swagger | |
url: 'http://swagger.io' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment