Skip to content

Instantly share code, notes, and snippets.

@emjayoh
Created December 2, 2019 23:06
Show Gist options
  • Save emjayoh/91c6f88bea2d15e403da5d779cae0888 to your computer and use it in GitHub Desktop.
Save emjayoh/91c6f88bea2d15e403da5d779cae0888 to your computer and use it in GitHub Desktop.
Test
{
"swagger": "2.0",
"info": {
"description": "This is the documentation for the new notes micro-service (MVP).",
"version": "0.1.0",
"title": "Notes",
"contact": {
"email": "rafaellopez@reps2.com"
}
},
"host": "notes-api.reps2.com",
"basePath": "/v0",
"schemes": [
"https"
],
"paths": {
"/notes": {
"get": {
"tags": [
"notes"
],
"summary": "Scan",
"description": "Returns a list of notes.",
"operationId": "scan",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "user_id",
"in": "query",
"description": "user_id value of note to return",
"required": false,
"type": "string"
},
{
"name": "user_version",
"in": "query",
"description": "user_version value of note to return",
"required": false,
"type": "string"
},
{
"name": "created_at",
"in": "query",
"description": "created_at timestamp value of note to return",
"required": false,
"type": "string"
},
{
"name": "source_id",
"in": "query",
"description": "source_id value of note to return",
"required": false,
"type": "string"
},
{
"name": "note_type",
"in": "query",
"description": "note_type value of note to return",
"required": false,
"type": "string"
},
{
"name": "source_type",
"in": "query",
"description": "source_type value of note to return",
"required": false,
"type": "string"
},
{
"name": "Access-Token",
"in": "header",
"required": true,
"type": "string"
},
{
"name": "note_id",
"in": "query",
"description": "note_id value of note to return",
"required": false,
"type": "string"
},
{
"name": "entity",
"in": "query",
"description": "entity value of note to return",
"required": false,
"type": "string"
},
{
"name": "query_type",
"in": "query",
"description": "query_type for operation, must be either equals or starts_with",
"required": false,
"type": "string"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/MultipleNoteResponse"
},
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
}
},
"405": {
"description": "Invalid input",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"security": [
{
"cognitoAuthorizer": [
"aws.cognito.signin.user.admin"
]
}
]
},
"post": {
"tags": [
"notes"
],
"summary": "Create",
"description": "Creates a new note. It is optional to include a version.",
"operationId": "create",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "Access-Token",
"in": "header",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "NoteRequestBody",
"description": "Note object to be created.",
"required": true,
"schema": {
"$ref": "#/definitions/NoteRequestBody"
}
}
],
"responses": {
"200": {
"description": "200 response",
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
}
},
"201": {
"description": "Success",
"schema": {
"$ref": "#/definitions/SuccessResponse"
}
},
"405": {
"description": "Invalid input",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"security": [
{
"cognitoAuthorizer": [
"aws.cognito.signin.user.admin"
]
}
]
},
"options": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 response",
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
},
"Access-Control-Allow-Methods": {
"type": "string"
},
"Access-Control-Allow-Headers": {
"type": "string"
}
}
}
}
}
},
"/notes/{entity}": {
"get": {
"tags": [
"notes"
],
"summary": "Get note by entity and optionally user_version.",
"description": "Read (get single note)",
"operationId": "get_one",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "entity",
"in": "path",
"description": "entity value of note to return",
"required": true,
"type": "string"
},
{
"name": "user_version",
"in": "query",
"description": "user_version value of note to return (helps filter)",
"required": true,
"type": "string"
},
{
"name": "Access-Token",
"in": "header",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/MultipleNoteResponse"
},
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
}
},
"400": {
"description": "Invalid ID supplied.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"404": {
"description": "Not found.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"security": [
{
"cognitoAuthorizer": [
"aws.cognito.signin.user.admin"
]
}
]
},
"put": {
"tags": [
"notes"
],
"summary": "Update an existing note",
"operationId": "update",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "entity",
"in": "path",
"description": "entity value of note to update.",
"required": true,
"type": "string"
},
{
"name": "user_version",
"in": "query",
"description": "user_version value of note to update.",
"required": false,
"type": "string"
},
{
"name": "Access-Token",
"in": "header",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "NoteRequestBody",
"description": "Partial or complete object to update with.",
"required": true,
"schema": {
"$ref": "#/definitions/NoteRequestBody"
}
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/SuccessResponse"
},
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
}
},
"400": {
"description": "Invalid ID supplied.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"404": {
"description": "Not found.",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"405": {
"description": "Validation exception",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"security": [
{
"cognitoAuthorizer": [
"aws.cognito.signin.user.admin"
]
}
]
},
"delete": {
"tags": [
"notes"
],
"summary": "Deletes a note",
"operationId": "delete",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"name": "entity",
"in": "path",
"description": "entity value of note to delete",
"required": true,
"type": "string"
},
{
"name": "user_version",
"in": "query",
"description": "user_version value of note to delete",
"required": true,
"type": "string"
},
{
"name": "Access-Token",
"in": "header",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "Success",
"schema": {
"$ref": "#/definitions/SuccessResponse"
},
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
}
}
},
"400": {
"description": "Invalid ID supplied",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
},
"404": {
"description": "Note not found",
"schema": {
"$ref": "#/definitions/ErrorResponse"
}
}
},
"security": [
{
"cognitoAuthorizer": [
"aws.cognito.signin.user.admin"
]
}
]
},
"options": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "200 response",
"headers": {
"Access-Control-Allow-Origin": {
"type": "string"
},
"Access-Control-Allow-Methods": {
"type": "string"
},
"Access-Control-Allow-Headers": {
"type": "string"
}
}
}
}
}
}
},
"securityDefinitions": {
"cognitoAuthorizer": {
"type": "apiKey",
"name": "Access-Token",
"in": "header",
"x-amazon-apigateway-authtype": "cognito_user_pools"
}
},
"definitions": {
"SuccessResponse": {
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"message": {
"type": "string"
}
}
},
"MultipleNoteResponse": {
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"message": {
"type": "string"
},
"notes": {
"$ref": "#/definitions/NoteList"
}
}
},
"NoteList": {
"type": "array",
"items": {
"$ref": "#/definitions/OutNote"
}
},
"NoteRequestBody": {
"type": "object",
"properties": {
"user_id": {
"type": "string"
},
"source_type": {
"type": "string"
},
"source_id": {
"type": "string"
},
"entity_type": {
"type": "string"
},
"entity_id": {
"type": "string"
},
"note_type": {
"type": "string"
},
"note_id": {
"type": "string"
},
"version": {
"type": "integer"
},
"content": {
"type": "string"
}
}
},
"OutNote": {
"type": "object",
"properties": {
"entity": {
"type": "string"
},
"user_version": {
"type": "string"
},
"user_id": {
"type": "string"
},
"source_type": {
"type": "string"
},
"source_id": {
"type": "string"
},
"entity_type": {
"type": "string"
},
"entity_id": {
"type": "string"
},
"note_type": {
"type": "string"
},
"note_id": {
"type": "string"
},
"created_at": {
"type": "string"
},
"version": {
"type": "integer"
},
"content": {
"type": "string"
}
}
},
"ErrorResponse": {
"type": "object",
"properties": {
"ok": {
"type": "boolean"
},
"message": {
"type": "string"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment