Skip to content

Instantly share code, notes, and snippets.

@khia
Created September 20, 2016 19:13
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 khia/9441b0be8f8ccd8328517230c81347b3 to your computer and use it in GitHub Desktop.
Save khia/9441b0be8f8ccd8328517230c81347b3 to your computer and use it in GitHub Desktop.
cat priv/spec/db.yml
swagger: '2.0'
info:
title: CouchDB API
description: CouchDB API to define bindings
version: "2.0"
# the domain of the service
host: couchdb.org
# array of all schemes that your API supports
schemes:
- https
- http
produces:
- application/json
paths:
/{db}:
put:
summary: Create new database
description: |
To create a database, make a PUT request
The database name must start with a lowercase letter and contain only the following characters:
- Lowercase characters (a-z)
- Digits (0-9)
- Any of the characters _, $, (, ), +, -, and /
produces: [
"application/json"
]
operationId: create_db
parameters:
- name: db
in: path
description: Database name
type: string
required: true
responses:
201:
description: Success
schema:
"$ref": "#/definitions/ok"
202:
description: Success
schema:
"$ref": "#/definitions/ok"
default:
description: Unexpected Error
schema:
"$ref": "#/definitions/error"
post:
summary: Create new document in existent database
description: |
To create a document, make a POST request with the document’s JSON content
produces: [
"application/json"
]
operationId: update_doc
parameters:
- name: db
in: path
description: path
type: string
required: true
responses:
201:
description: Success
schema:
"$ref": "#/definitions/updatedDoc"
definitions:
ok:
properties:
ok:
type: boolean
description: Always true
examples:
application/json: |-
{
"ok": true
}
error:
properties:
error:
type: string
description: Error type
reason:
type: string
description: Reason for error
examples:
application/json: |-
{
"error": "file_exists",
"reason": "The database could not be created, the file already exists."
}
updatedDoc:
properties:
ok:
type: boolean
description: Always true
id:
type: string
description: Id of a document
rev:
type: string
description: New revision of document
examples:
application/json: |-
{
"ok": true,
"id": "apple",
"rev": "1-2902191555"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment