Skip to content

Instantly share code, notes, and snippets.

@dojeda
Created February 17, 2019 15:29
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 dojeda/14151390478b19a1fda94a156c1fccaf to your computer and use it in GitHub Desktop.
Save dojeda/14151390478b19a1fda94a156c1fccaf to your computer and use it in GitHub Desktop.
Example OpenAPI specification for inline model bug reproduction
openapi: "3.0.0"
info:
version: 1.0.0
title: Swagger Petstore
license:
name: MIT
servers:
- url: http://petstore.swagger.io/v1
paths:
/pets:
get:
summary: List all pets
operationId: listPets
tags:
- pets
parameters:
- $ref: '#/components/parameters/pageOffset'
- $ref: '#/components/parameters/pageSize'
responses:
'200':
description: A paged array of pets
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: '#/components/schemas/Pet'
page:
$ref: '#/components/schemas/PaginationEnvelope/properties/page'
pages:
$ref: '#/components/schemas/PaginationEnvelope/properties/pages'
total:
$ref: '#/components/schemas/PaginationEnvelope/properties/total'
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
parameters:
pageOffset:
name: page
in: query
description: The page of a collection.
required: false
schema:
type: integer
pageSize:
name: per_page
in: query
description: Number of items to return per page.
required: false
schema:
type: integer
schemas:
PaginationEnvelope:
type: object
title: Paginated response template type
required:
- pages
- page
- total
- data
properties:
pages:
type: integer
description: Number of pages available in the collection
readOnly: true
page:
type: integer
description: Current page number
readOnly: true
total:
type: integer
description: Total number of items in the collection
readOnly: true
data:
type: array
description: Array of objects with the results of the current page
readOnly: true
items:
type: object
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment