Skip to content

Instantly share code, notes, and snippets.

@hugohil
Created September 21, 2016 21:54
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 hugohil/5f7632961402f9bc9c7ceb2f23bc9090 to your computer and use it in GitHub Desktop.
Save hugohil/5f7632961402f9bc9c7ceb2f23bc9090 to your computer and use it in GitHub Desktop.
Base swagger API definition
swagger: '2.0'
info:
version: '1.0.0'
title: My API
description: A sample API to start hacking with swagger
contact:
name: John Doe
email: johndoe@example.com
url: http://example.com
license:
name: MIT
url: http://opensource.org/licenses/MIT
host: api.myservice.com
basePath: /v1
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/items:
get:
description: Returns all tiems
produces:
- application/json
- application/xml
responses:
'200':
description: item response
schema:
type: array
items:
$ref: '#/definitions/item'
default:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
post:
description: Creates a new item in the store.
operationId: addItem
produces:
- application/json
parameters:
- name: item
in: body
description: Pet to add to the store
required: true
schema:
$ref: '#/definitions/newItem'
responses:
'201':
description: item response
schema:
$ref: '#/definitions/item'
default:
description: unexpected error
schema:
$ref: '#/definitions/errorModel'
definitions:
item:
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
newItem:
type: object
required:
- name
properties:
id:
type: integer
format: int64
name:
type: string
errorModel:
type: object
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