Last active
March 4, 2019 01:07
-
-
Save zachwalton/c8fea204edc3033d200e032eae11b9b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
openapi: "3.0.0" | |
info: | |
version: 0.1.0 | |
title: Johnny Cache | |
license: | |
name: MIT | |
paths: | |
/records: | |
post: | |
summary: Create a cache record | |
operationId: createRecord | |
requestBody: | |
description: Record to add to the cache | |
required: true | |
content: | |
application/json: | |
schema: | |
$ref: '#/components/schemas/Record' | |
tags: | |
- records | |
responses: | |
'201': | |
description: Null response | |
'409': | |
description: A record for the requested key already exists | |
default: | |
description: unexpected error | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Error" | |
/records/{key}: | |
get: | |
summary: Fetch a cache record | |
operationId: fetchRecordByKey | |
tags: | |
- records | |
parameters: | |
- name: key | |
in: path | |
required: true | |
description: The key of the cache record to retrieve | |
schema: | |
type: string | |
responses: | |
'200': | |
description: Expected response to a valid request | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Record" | |
'404': | |
description: The requested record doesn't exist for the provided key | |
default: | |
description: unexpected error | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Error" | |
put: | |
summary: Atomically update a cache record | |
operationId: updateRecordByKey | |
requestBody: | |
description: Changes to make to the cache record | |
required: true | |
content: | |
application/json: | |
schema: | |
oneOf: | |
- $ref: "#/components/schemas/Record" | |
- $ref: '#/components/schemas/OldValueCompareAndSwapRequest' | |
- $ref: '#/components/schemas/ValueExistsCompareAndSwapRequest' | |
tags: | |
- records | |
parameters: | |
- name: key | |
in: path | |
required: true | |
description: The key of the cache record to update | |
schema: | |
type: string | |
responses: | |
'200': | |
description: Null response | |
'404': | |
description: The requested record doesn't exist for the provided key | |
'409': | |
description: Compare and swap condition failed | |
default: | |
description: unexpected error | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Error" | |
delete: | |
summary: Delete a cache record | |
operationId: deleteRecordByKey | |
tags: | |
- records | |
parameters: | |
- name: key | |
in: path | |
required: true | |
description: The key of the cache record to delete | |
schema: | |
type: string | |
responses: | |
'200': | |
description: Null response | |
'404': | |
description: The requested record doesn't exist for the provided key | |
default: | |
description: unexpected error | |
content: | |
application/json: | |
schema: | |
$ref: "#/components/schemas/Error" | |
components: | |
schemas: | |
Record: | |
required: | |
- key | |
- value | |
- ttl | |
properties: | |
key: | |
type: string | |
value: | |
type: string | |
ttl: | |
type: integer | |
format: int64 | |
OldValueCompareAndSwapRequest: | |
required: | |
- key | |
- value | |
- ttl | |
- old_value | |
properties: | |
key: | |
type: string | |
value: | |
type: string | |
ttl: | |
type: integer | |
format: int64 | |
old_value: | |
type: string | |
ValueExistsCompareAndSwapRequest: | |
required: | |
- key | |
- value | |
- ttl | |
- value_exists | |
properties: | |
key: | |
type: string | |
value: | |
type: string | |
ttl: | |
type: integer | |
format: int64 | |
value_exists: | |
type: boolean | |
Error: | |
required: | |
- message | |
properties: | |
message: | |
type: string | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment