Skip to content

Instantly share code, notes, and snippets.

@lzhoucs
Created April 26, 2019 16:33
Show Gist options
  • Save lzhoucs/71099b94270c9e923b32f374c26b8d5a to your computer and use it in GitHub Desktop.
Save lzhoucs/71099b94270c9e923b32f374c26b8d5a to your computer and use it in GitHub Desktop.
open api spec samples
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- name: limit
in: query
description: How many items to return at one time (max 100)
required: false
schema:
type: integer
format: int32
responses:
'200':
description: A paged array of pets
content:
application/json:
schema:
$ref: "#/components/schemas/Pets"
post:
summary: Create a pet
operationId: createPets
tags:
- pets
responses:
'201':
description: Null response
components:
schemas:
Pet:
oneOf:
- $ref: '#/components/schemas/Cat'
- $ref: '#/components/schemas/Dog'
- $ref: '#/components/schemas/Lizard'
discriminator:
propertyName: petType
Cat:
required:
- name
properties:
name:
type: string
petType:
type: string
Dog:
required:
- name
properties:
name:
type: string
petType:
type: string
Lizard:
required:
- name
properties:
name:
type: string
petType:
type: string
Pets:
type: array
items:
$ref: "#/components/schemas/Pet"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment