├── .gitignore └── todolist.json /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | -------------------------------------------------------------------------------- /todolist.json: -------------------------------------------------------------------------------- 1 | { 2 | "openapi": "3.0.3", 3 | "info": { 4 | "title": "Todolist RESTful API", 5 | "version": "1", 6 | "description": "OpenAPI for Todolist RESTful API", 7 | "termsOfService": "https://www.programmerzamannow.com", 8 | "contact": { 9 | "name": "Eko Kurniawan Khannedy", 10 | "email": "echo.khannedy@gmail.com", 11 | "url": "https://www.programmerzamannow.com" 12 | }, 13 | "license": { 14 | "name": "APACHE 2.0", 15 | "url": "https://www.apache.org/licenses/LICENSE-2.0" 16 | } 17 | }, 18 | "servers": [ 19 | { 20 | "description": "Todolist RESTful API Server", 21 | "url": "https://{environment}.programmerzamannow.com/api/v1", 22 | "variables": { 23 | "environment": { 24 | "description": "Server Environment", 25 | "default": "dev", 26 | "enum": [ 27 | "dev", 28 | "qa", 29 | "prod" 30 | ] 31 | } 32 | } 33 | } 34 | ], 35 | "externalDocs": { 36 | "description": "Youtube Programmer Zaman Now", 37 | "url": "https://www.youtube.com/c/ProgrammerZamanNow" 38 | }, 39 | "paths": { 40 | "/todolist": { 41 | "get": { 42 | "security": [ 43 | { 44 | "TodolistAuth": [] 45 | } 46 | ], 47 | "tags": [ 48 | "Todolist" 49 | ], 50 | "summary": "Get all todolist", 51 | "description": "Get all active todolist by default", 52 | "parameters": [ 53 | { 54 | "name": "include_done", 55 | "in": "query", 56 | "required": false, 57 | "description": "Is include done todolist", 58 | "schema": { 59 | "type": "boolean", 60 | "nullable": true, 61 | "default": false 62 | } 63 | }, 64 | { 65 | "name": "name", 66 | "in": "query", 67 | "required": false, 68 | "description": "Filter todolist by name", 69 | "schema": { 70 | "type": "string", 71 | "nullable": true, 72 | "minLength": 1, 73 | "maxLength": 100 74 | }, 75 | "examples": { 76 | "java": { 77 | "description": "Example name Java", 78 | "value": "Java" 79 | }, 80 | "php": { 81 | "description": "Example name PHP", 82 | "value": "PHP" 83 | } 84 | } 85 | } 86 | ], 87 | "responses": { 88 | "200": { 89 | "description": "Success get all todolist", 90 | "content": { 91 | "application/json": { 92 | "schema": { 93 | "$ref": "#/components/schemas/ArrayTodolist" 94 | }, 95 | "examples": { 96 | "success": { 97 | "description": "Example success get all todolist", 98 | "value": [ 99 | { 100 | "id": "1", 101 | "name": "Java", 102 | "priority": 3, 103 | "tags": [ 104 | "Java", 105 | "Programming" 106 | ] 107 | }, 108 | { 109 | "id": "2", 110 | "name": "PHP", 111 | "priority": 5, 112 | "tags": [ 113 | "PHP", 114 | "Programming" 115 | ] 116 | } 117 | ] 118 | } 119 | } 120 | } 121 | } 122 | } 123 | } 124 | }, 125 | "post": { 126 | "security": [ 127 | { 128 | "TodolistAuth": [] 129 | } 130 | ], 131 | "tags": [ 132 | "Todolist" 133 | ], 134 | "summary": "Create new todolist", 135 | "description": "Create new todolist to database", 136 | "requestBody": { 137 | "required": true, 138 | "content": { 139 | "application/json": { 140 | "schema": { 141 | "$ref": "#/components/schemas/CreateOrUpdateTodolist" 142 | }, 143 | "examples": { 144 | "java": { 145 | "description": "Example create todolist Java", 146 | "value": { 147 | "name": "Java", 148 | "priority": 3, 149 | "tags": [ 150 | "Java", 151 | "Programming" 152 | ] 153 | } 154 | }, 155 | "php": { 156 | "description": "Example create todolist PHP", 157 | "value": { 158 | "name": "PHP", 159 | "priority": 5, 160 | "tags": [ 161 | "PHP", 162 | "Programming" 163 | ] 164 | } 165 | } 166 | } 167 | } 168 | } 169 | }, 170 | "responses": { 171 | "200": { 172 | "description": "Success create todolist", 173 | "content": { 174 | "application/json": { 175 | "schema": { 176 | "$ref": "#/components/schemas/Todolist" 177 | }, 178 | "examples": { 179 | "java": { 180 | "description": "Success create java todolist", 181 | "value": { 182 | "id": "1", 183 | "name": "Java", 184 | "priority": 3, 185 | "tags": [ 186 | "Java", 187 | "Programming" 188 | ] 189 | } 190 | }, 191 | "php": { 192 | "description": "Success create php todolist", 193 | "value": { 194 | "id": "2", 195 | "name": "PHP", 196 | "priority": 5, 197 | "tags": [ 198 | "PHP", 199 | "Programming" 200 | ] 201 | } 202 | } 203 | } 204 | } 205 | } 206 | } 207 | } 208 | } 209 | }, 210 | "/todolist/{todolistId}": { 211 | "put": { 212 | "security": [ 213 | { 214 | "TodolistAuth": [] 215 | } 216 | ], 217 | "tags": [ 218 | "Todolist" 219 | ], 220 | "summary": "Update existing todolist", 221 | "description": "Update existing todolist in database", 222 | "parameters": [ 223 | { 224 | "$ref": "#/components/parameters/TodolistId" 225 | } 226 | ], 227 | "requestBody": { 228 | "required": true, 229 | "content": { 230 | "application/json": { 231 | "schema": { 232 | "$ref": "#/components/schemas/CreateOrUpdateTodolist" 233 | }, 234 | "examples": { 235 | "java": { 236 | "description": "Example create todolist Java", 237 | "value": { 238 | "name": "Java", 239 | "priority": 3, 240 | "tags": [ 241 | "Java", 242 | "Programming" 243 | ] 244 | } 245 | }, 246 | "php": { 247 | "description": "Example create todolist PHP", 248 | "value": { 249 | "name": "PHP", 250 | "priority": 5, 251 | "tags": [ 252 | "PHP", 253 | "Programming" 254 | ] 255 | } 256 | } 257 | } 258 | } 259 | } 260 | }, 261 | "responses": { 262 | "200": { 263 | "description": "Success update todolist", 264 | "content": { 265 | "application/json": { 266 | "schema": { 267 | "$ref": "#/components/schemas/Todolist" 268 | }, 269 | "examples": { 270 | "java": { 271 | "description": "Success create java todolist", 272 | "value": { 273 | "id": "1", 274 | "name": "Java", 275 | "priority": 3, 276 | "tags": [ 277 | "Java", 278 | "Programming" 279 | ] 280 | } 281 | }, 282 | "php": { 283 | "description": "Success create php todolist", 284 | "value": { 285 | "id": "2", 286 | "name": "PHP", 287 | "priority": 5, 288 | "tags": [ 289 | "PHP", 290 | "Programming" 291 | ] 292 | } 293 | } 294 | } 295 | } 296 | } 297 | } 298 | } 299 | }, 300 | "delete": { 301 | "security": [ 302 | { 303 | "TodolistAuth": [] 304 | } 305 | ], 306 | "tags": [ 307 | "Todolist" 308 | ], 309 | "summary": "Delete existing todolist", 310 | "description": "Delete existing todolist in database", 311 | "parameters": [ 312 | { 313 | "$ref": "#/components/parameters/TodolistId" 314 | } 315 | ], 316 | "responses": { 317 | "200": { 318 | "description": "Success delete todolist", 319 | "content": { 320 | "application/json": { 321 | "schema": { 322 | "type": "object", 323 | "properties": { 324 | "success": { 325 | "type": "boolean" 326 | } 327 | } 328 | }, 329 | "examples": { 330 | "success": { 331 | "description": "Success delete todolist", 332 | "value": { 333 | "success": true 334 | } 335 | } 336 | } 337 | } 338 | } 339 | }, 340 | "404": { 341 | "description": "Failed delete not found todolist", 342 | "content": { 343 | "application/json": { 344 | "schema": { 345 | "type": "object", 346 | "properties": { 347 | "success": { 348 | "type": "boolean" 349 | } 350 | } 351 | }, 352 | "examples": { 353 | "failed": { 354 | "description": "Failed delete todolist", 355 | "value": { 356 | "success": false 357 | } 358 | } 359 | } 360 | } 361 | } 362 | } 363 | } 364 | } 365 | } 366 | }, 367 | "components": { 368 | "securitySchemes": { 369 | "TodolistAuth": { 370 | "description": "Authentication for Todolist RESTful API", 371 | "type": "apiKey", 372 | "in": "header", 373 | "name": "X-API-Key" 374 | } 375 | }, 376 | "parameters": { 377 | "TodolistId": { 378 | "name": "todolistId", 379 | "in": "path", 380 | "required": true, 381 | "description": "Todolist id for updated", 382 | "schema": { 383 | "type": "string", 384 | "minLength": 1, 385 | "maxLength": 100 386 | }, 387 | "examples": { 388 | "java": { 389 | "description": "Sample todolist id for Java", 390 | "value": "1" 391 | }, 392 | "php": { 393 | "description": "Sample todolist id for PHP", 394 | "value": "2" 395 | } 396 | } 397 | } 398 | }, 399 | "schemas": { 400 | "Todolist": { 401 | "type": "object", 402 | "properties": { 403 | "id": { 404 | "type": "string" 405 | }, 406 | "name": { 407 | "type": "string" 408 | }, 409 | "priority": { 410 | "type": "number", 411 | "format": "int32" 412 | }, 413 | "tags": { 414 | "type": "array", 415 | "items": { 416 | "type": "string" 417 | } 418 | } 419 | } 420 | }, 421 | "CreateOrUpdateTodolist": { 422 | "type": "object", 423 | "properties": { 424 | "name": { 425 | "type": "string" 426 | }, 427 | "priority": { 428 | "type": "number", 429 | "format": "int32" 430 | }, 431 | "tags": { 432 | "type": "array", 433 | "items": { 434 | "type": "string" 435 | } 436 | } 437 | } 438 | }, 439 | "ArrayTodolist": { 440 | "type": "array", 441 | "items": { 442 | "$ref": "#/components/schemas/Todolist" 443 | } 444 | } 445 | } 446 | } 447 | } 448 | --------------------------------------------------------------------------------