Skip to content

Instantly share code, notes, and snippets.

@yosmoc
Created March 20, 2017 23:32
Show Gist options
  • Save yosmoc/e213c5cdb8399cac448a3424072a231a to your computer and use it in GitHub Desktop.
Save yosmoc/e213c5cdb8399cac448a3424072a231a to your computer and use it in GitHub Desktop.
swagger: "2.0"
info:
version: 1.0.0
title: Simple API
description: A simple API to learn how to write OpenAPI Specification
schemes:
- https
host: sample.api
# bashPath: /openapi101
paths:
/persons:
get:
summary: Gets some persons
description: Returns a list contaiing all persons. The list suppots paging.
parameters:
- name: pageSize
in: query
description: Number of persons returned
type: integer
- name: pageNumber
in: query
description: Page number
type: integer
responses:
200:
description: A list of Person
schema:
$ref: "#/definitions/Persons"
500:
$ref: "#/responses/Standard500ErrorResponse"
post:
summary: Create a person
description: Adds a new person to the persons list.
parameters:
- name: person
in: body
description: The person to create.
schema:
$ref: "#/definitions/Person"
responses:
204:
description: Persons succesfully created.
400:
description: Persons couldn't have been created.
500:
$ref: "#/responses/Standard500ErrorResponse"
/persons/{username}:
get:
summary: Gets a person
description: Returns a single person for its username
parameters:
- name: username
in: path
required: true
description: The person's username
type: string
responses:
200:
description: A Person
schema:
$ref: "#/definitions/Person"
404:
description: The Person does not exists.
500:
$ref: "#/responses/Standard500ErrorResponse"
definitions:
Person:
required:
- username
properties:
firstName:
type: string
lastName:
type: string
username:
type: string
Persons:
type: array
items:
$ref: "#/definitions/Person"
Error:
properties:
code:
type: string
message:
type: string
responses:
Standard500ErrorResponse:
description: An unexpected error occured.
schema:
$ref: "#/definitions/Error"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment