Created
March 7, 2023 15:49
-
-
Save greycatsec/4bdb1c8b5ddd4b06da2390184870b8c1 to your computer and use it in GitHub Desktop.
An EXAMPLE OpenAPI 2.0 specification for TTRPG character handling. For use in a blog post
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
{ | |
"swagger": "2.0", | |
"basePath": "/api/v1", | |
"info": { | |
"title": "Table Top Role Playing Game (TTRPG) API", | |
"version": "1.0", | |
"description": "Welcome to the OpenAPI documentation site!", | |
"license": { | |
"name": "MIT" | |
}, | |
"contact": { | |
"name": "Elliott Grey at InterSystems" | |
} | |
}, | |
"produces": [ | |
"application/json" | |
], | |
"consumes": [ | |
"application/json" | |
], | |
"securityDefinitions": { | |
"Bearer": { | |
"type": "apiKey", | |
"in": "header", | |
"name": "Authorization" | |
} | |
}, | |
"paths": { | |
"/characters": { | |
"get": { | |
"responses": { | |
"500": { | |
"description": "Internal server error." | |
}, | |
"401": { | |
"description": "Unauthorized." | |
}, | |
"400": { | |
"description": "Validation error." | |
}, | |
"200": { | |
"description": "Retrieved character list." | |
} | |
}, | |
"summary": "Retrieve a list of TTRPG characters", | |
"operationId": "GetCharacterList", | |
"parameters": [ | |
], | |
"security": [{ | |
"Bearer": [] | |
}], | |
"tags": [ | |
"characters" | |
] | |
}, | |
"post": { | |
"responses": { | |
"500": { | |
"description": "Internal server error." | |
}, | |
"401": { | |
"description": "Unauthorized." | |
}, | |
"400": { | |
"description": "Validation error." | |
}, | |
"409": { | |
"description": "character name already exists." | |
}, | |
"403": { | |
"description": "Administrator token required." | |
}, | |
"201": { | |
"description": "Added new character." | |
} | |
}, | |
"summary": "Create a character", | |
"operationId": "PostCharacter", | |
"parameters": [{ | |
"name": "name", | |
"in": "formData", | |
"type": "string", | |
"required": true | |
}, | |
{ | |
"name": "class", | |
"in": "formData", | |
"type": "string", | |
"format": "url", | |
"required": true | |
}, | |
{ | |
"name": "race", | |
"in": "formData", | |
"type": "string", | |
"required": true | |
}, | |
{ | |
"name": "level", | |
"in": "formData", | |
"type": "string", | |
"required": true | |
} | |
], | |
"security": [{ | |
"Bearer": [] | |
}], | |
"consumes": [ | |
"application/x-www-form-urlencoded", | |
"multipart/form-data" | |
], | |
"tags": [ | |
"characters" | |
] | |
} | |
}, | |
"/characters/{charName}": { | |
"get": { | |
"responses": { | |
"500": { | |
"description": "Internal server error." | |
}, | |
"401": { | |
"description": "Unauthorized." | |
}, | |
"404": { | |
"description": "character not found." | |
}, | |
"400": { | |
"description": "Validation error." | |
}, | |
"200": { | |
"description": "Retrieved character.", | |
"schema": { | |
"$ref": "#/definitions/Character" | |
} | |
} | |
}, | |
"summary": "Retrieve a character", | |
"operationId": "GetCharacterByName", | |
"parameters": [{ | |
"in": "path", | |
"description": "character name", | |
"name": "charName", | |
"required": true, | |
"type": "string" | |
}], | |
"security": [{ | |
"Bearer": [] | |
}], | |
"tags": [ | |
"characters" | |
] | |
} | |
} | |
}, | |
"tags": [ | |
{ | |
"name": "characters" | |
} | |
], | |
"definitions": { | |
"Character": { | |
"properties": { | |
"name": { | |
"type": "string" | |
}, | |
"class": { | |
"type": "string" | |
}, | |
"race": { | |
"type": "string" | |
}, | |
"level": { | |
"type": "string" | |
} | |
}, | |
"type": "object" | |
} | |
}, | |
"responses": { | |
"ParseError": { | |
"description": "When a mask can't be parsed" | |
}, | |
"MaskError": { | |
"description": "When any error occurs on mask" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment