|
| 1 | +{ |
| 2 | + "openapi": "3.0.0", |
| 3 | + "info": { |
| 4 | + "title": "Node API boilerplate", |
| 5 | + "version": "v1" |
| 6 | + }, |
| 7 | + "servers": [ |
| 8 | + { |
| 9 | + "description": "Local server", |
| 10 | + "url": "/api" |
| 11 | + } |
| 12 | + ], |
| 13 | + "paths": { |
| 14 | + "/users": { |
| 15 | + "get": { |
| 16 | + "operationId": "listUsers", |
| 17 | + "tags": [ "Users" ], |
| 18 | + "responses": { |
| 19 | + "200": { |
| 20 | + "description": "List of all users", |
| 21 | + "content": { |
| 22 | + "application/json": { |
| 23 | + "schema": { |
| 24 | + "type": "array", |
| 25 | + "items": { |
| 26 | + "$ref": "#/components/schemas/User" |
| 27 | + } |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + }, |
| 34 | + "post": { |
| 35 | + "operationId": "createUser", |
| 36 | + "tags": [ "Users" ], |
| 37 | + "requestBody": { |
| 38 | + "description": "User data", |
| 39 | + "required": true, |
| 40 | + "content": { |
| 41 | + "application/json": { |
| 42 | + "schema": { |
| 43 | + "$ref": "#/components/schemas/NewUser" |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + }, |
| 48 | + "responses": { |
| 49 | + "201": { |
| 50 | + "description": "User created successfully", |
| 51 | + "content": { |
| 52 | + "application/json": { |
| 53 | + "schema": { |
| 54 | + "$ref": "#/components/schemas/User" |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + }, |
| 59 | + "400": { |
| 60 | + "description": "User not created because of validation error", |
| 61 | + "content": { |
| 62 | + "application/json": { |
| 63 | + "schema": { |
| 64 | + "$ref": "#/components/schemas/ValidationError" |
| 65 | + } |
| 66 | + } |
| 67 | + } |
| 68 | + } |
| 69 | + } |
| 70 | + } |
| 71 | + }, |
| 72 | + "/users/{id}": { |
| 73 | + "get": { |
| 74 | + "operationId": "showUser", |
| 75 | + "tags": [ "Users" ], |
| 76 | + "parameters": [ |
| 77 | + { |
| 78 | + "name": "id", |
| 79 | + "in": "path", |
| 80 | + "description": "Id of user to show", |
| 81 | + "required": true, |
| 82 | + "type": "integer", |
| 83 | + "format": "int64" |
| 84 | + } |
| 85 | + ], |
| 86 | + "responses": { |
| 87 | + "200": { |
| 88 | + "description": "Return user with given id", |
| 89 | + "content": { |
| 90 | + "application/json": { |
| 91 | + "schema": { |
| 92 | + "$ref": "#/components/schemas/User" |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | + }, |
| 97 | + "404": { |
| 98 | + "description": "User not found", |
| 99 | + "content": { |
| 100 | + "application/json": { |
| 101 | + "schema": { |
| 102 | + "$ref": "#/components/schemas/NotFoundError" |
| 103 | + } |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + }, |
| 109 | + "put": { |
| 110 | + "operationId": "updateUser", |
| 111 | + "tags": [ "Users" ], |
| 112 | + "parameters": [ |
| 113 | + { |
| 114 | + "name": "id", |
| 115 | + "in": "path", |
| 116 | + "description": "Id of user to update", |
| 117 | + "required": true, |
| 118 | + "type": "integer", |
| 119 | + "format": "int64" |
| 120 | + } |
| 121 | + ], |
| 122 | + "requestBody": { |
| 123 | + "description": "User new data", |
| 124 | + "required": true, |
| 125 | + "content": { |
| 126 | + "application/json": { |
| 127 | + "schema": { |
| 128 | + "$ref": "#/components/schemas/NewUser" |
| 129 | + } |
| 130 | + } |
| 131 | + } |
| 132 | + }, |
| 133 | + "responses": { |
| 134 | + "202": { |
| 135 | + "description": "User updated successfully", |
| 136 | + "content": { |
| 137 | + "application/json": { |
| 138 | + "schema": { |
| 139 | + "$ref": "#/components/schemas/User" |
| 140 | + } |
| 141 | + } |
| 142 | + } |
| 143 | + }, |
| 144 | + "404": { |
| 145 | + "description": "User not found", |
| 146 | + "content": { |
| 147 | + "application/json": { |
| 148 | + "schema": { |
| 149 | + "$ref": "#/components/schemas/NotFoundError" |
| 150 | + } |
| 151 | + } |
| 152 | + } |
| 153 | + } |
| 154 | + } |
| 155 | + }, |
| 156 | + "delete": { |
| 157 | + "operationId": "deleteUser", |
| 158 | + "tags": [ "Users" ], |
| 159 | + "parameters": [ |
| 160 | + { |
| 161 | + "name": "id", |
| 162 | + "in": "path", |
| 163 | + "description": "Id of user to delete", |
| 164 | + "required": true, |
| 165 | + "type": "integer", |
| 166 | + "format": "int64" |
| 167 | + } |
| 168 | + ], |
| 169 | + "responses": { |
| 170 | + "202": { |
| 171 | + "description": "User deleted successfully" |
| 172 | + }, |
| 173 | + "404": { |
| 174 | + "description": "User not found", |
| 175 | + "content": { |
| 176 | + "application/json": { |
| 177 | + "schema": { |
| 178 | + "$ref": "#/components/schemas/NotFoundError" |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + } |
| 183 | + } |
| 184 | + } |
| 185 | + } |
| 186 | + }, |
| 187 | + "components": { |
| 188 | + "schemas": { |
| 189 | + "User": { |
| 190 | + "allOf": [ |
| 191 | + { "$ref": "#/components/schemas/NewUser" }, |
| 192 | + { |
| 193 | + "required": [ "id" ], |
| 194 | + "properties": { |
| 195 | + "id": { |
| 196 | + "type": "integer", |
| 197 | + "format": "int64" |
| 198 | + } |
| 199 | + } |
| 200 | + } |
| 201 | + ] |
| 202 | + }, |
| 203 | + "NewUser": { |
| 204 | + "required": [ "name" ], |
| 205 | + "properties": { |
| 206 | + "name": { |
| 207 | + "type": "string" |
| 208 | + } |
| 209 | + } |
| 210 | + }, |
| 211 | + "ValidationError": { |
| 212 | + "properties": { |
| 213 | + "type": { |
| 214 | + "type": "string", |
| 215 | + "enum": [ "ValidationError" ] |
| 216 | + }, |
| 217 | + "details": { |
| 218 | + "type": "array", |
| 219 | + "items": { |
| 220 | + "$ref": "#/components/schemas/ValidationErrorDetail" |
| 221 | + } |
| 222 | + } |
| 223 | + } |
| 224 | + }, |
| 225 | + "ValidationErrorDetail": { |
| 226 | + "properties": { |
| 227 | + "message": { |
| 228 | + "type": "string" |
| 229 | + }, |
| 230 | + "path": { |
| 231 | + "type": "string" |
| 232 | + } |
| 233 | + } |
| 234 | + }, |
| 235 | + "NotFoundError": { |
| 236 | + "properties": { |
| 237 | + "type": { |
| 238 | + "type": "string", |
| 239 | + "enum": [ "NotFoundError" ] |
| 240 | + }, |
| 241 | + "details": { |
| 242 | + "type": "string", |
| 243 | + "enum": [ "User with id {id} not found" ] |
| 244 | + } |
| 245 | + } |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | +} |
0 commit comments