diff --git a/README.md b/README.md index 58efaa2..f35fe6a 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -44,7 +44,7 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -72,10 +72,10 @@ } }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -87,23 +87,13 @@ ], "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/StoreItem" - } - } - } - } + "$ref": "#/components/responses/StoreItemListResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -114,40 +104,17 @@ "AdminStore" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - } - } + "$ref": "#/components/requestBodies/StoreItemBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -159,13 +126,7 @@ ], "parameters": [ { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } + "$ref": "#/components/parameters/PathId" } ], "responses": { @@ -180,10 +141,10 @@ } }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -195,33 +156,11 @@ ], "parameters": [ { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } + "$ref": "#/components/parameters/PathId" } ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - } - } + "$ref": "#/components/requestBodies/StoreItemBody" }, "responses": { "200": { @@ -235,10 +174,10 @@ } }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -249,40 +188,17 @@ "AdminStore" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/StoreItem" - } - } - } + "$ref": "#/components/requestBodies/StoreItemBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -293,23 +209,7 @@ "Auth" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - } - } + "$ref": "#/components/requestBodies/UserModelBody" }, "responses": { "200": { @@ -323,7 +223,7 @@ } }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" } } } @@ -335,14 +235,7 @@ ], "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" } } } @@ -353,37 +246,14 @@ "Auth" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - } - } + "$ref": "#/components/requestBodies/UserModelBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" } } } @@ -394,37 +264,14 @@ "Auth" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - } - } + "$ref": "#/components/requestBodies/UserModelBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" } } } @@ -435,37 +282,14 @@ "Auth" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - } - } + "$ref": "#/components/requestBodies/UserModelBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" } } } @@ -476,37 +300,14 @@ "ContactUs" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/UserModel" - } - } - } + "$ref": "#/components/requestBodies/UserModelBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" } } } @@ -563,7 +364,7 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -575,20 +376,10 @@ ], "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/StoreItem" - } - } - } - } + "$ref": "#/components/responses/StoreItemListResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -623,7 +414,7 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -634,40 +425,17 @@ "Store" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/BuyProductReq" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/BuyProductReq" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/BuyProductReq" - } - } - } + "$ref": "#/components/requestBodies/BuyProductReqBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -679,13 +447,7 @@ ], "parameters": [ { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "integer", - "format": "int32" - } + "$ref": "#/components/parameters/PathId" } ], "responses": { @@ -700,10 +462,10 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" }, "404": { - "description": "Not Found" + "$ref": "#/components/responses/NotFoundResponse" } } } @@ -751,7 +513,7 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -786,7 +548,7 @@ } }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -797,40 +559,17 @@ "Transaction" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TransactionDBModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/TransactionDBModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/TransactionDBModel" - } - } - } + "$ref": "#/components/requestBodies/TransactionDBModelBody" }, "responses": { "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/EmptyResult" - } - } - } + "$ref": "#/components/responses/EmptyResultResponse" }, "400": { - "description": "Bad Request" + "$ref": "#/components/responses/BadRequestResponse" }, "401": { - "description": "Unauthorized" + "$ref": "#/components/responses/UnauthorizedResponse" } } } @@ -861,23 +600,7 @@ "User" ], "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/NewImageModel" - } - }, - "text/json": { - "schema": { - "$ref": "#/components/schemas/NewImageModel" - } - }, - "application/*+json": { - "schema": { - "$ref": "#/components/schemas/NewImageModel" - } - } - } + "$ref": "#/components/requestBodies/NewImageModelBody" }, "responses": { "200": { @@ -917,6 +640,148 @@ } }, "components": { + "parameters": { + "PathId": { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + }, + "requestBodies": { + "UserModelBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/UserModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/UserModel" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/UserModel" + } + } + } + }, + "StoreItemBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StoreItem" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/StoreItem" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/StoreItem" + } + } + } + }, + "BuyProductReqBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BuyProductReq" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/BuyProductReq" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/BuyProductReq" + } + } + } + }, + "TransactionDBModelBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TransactionDBModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/TransactionDBModel" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/TransactionDBModel" + } + } + } + }, + "NewImageModelBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/NewImageModel" + } + }, + "text/json": { + "schema": { + "$ref": "#/components/schemas/NewImageModel" + } + }, + "application/*+json": { + "schema": { + "$ref": "#/components/schemas/NewImageModel" + } + } + } + } + }, + "responses": { + "UnauthorizedResponse": { + "description": "Unauthorized" + }, + "BadRequestResponse": { + "description": "Bad Request" + }, + "NotFoundResponse": { + "description": "Not Found" + }, + "EmptyResultResponse": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EmptyResult" + } + } + } + }, + "StoreItemListResponse": { + "description": "Success", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/StoreItem" + } + } + } + } + } + }, "schemas": { "TransactionResp": { "type": "object", @@ -967,8 +832,9 @@ } } }, - "TransactionRespDataTableResp": { + "DataTableResp": { "type": "object", + "description": "Base paginated response wrapper. Used by TransactionRespDataTableResp and AdminUserInfoRespDataTableResp.", "properties": { "recordsTotal": { "type": "integer", @@ -977,16 +843,28 @@ "recordsFiltered": { "type": "integer", "format": "int32" - }, - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TransactionResp" - }, - "nullable": true } } }, + "TransactionRespDataTableResp": { + "allOf": [ + { + "$ref": "#/components/schemas/DataTableResp" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TransactionResp" + }, + "nullable": true + } + } + } + ] + }, "AdminUserInfoResp": { "type": "object", "properties": { @@ -1009,24 +887,23 @@ } }, "AdminUserInfoRespDataTableResp": { - "type": "object", - "properties": { - "recordsTotal": { - "type": "integer", - "format": "int32" - }, - "recordsFiltered": { - "type": "integer", - "format": "int32" + "allOf": [ + { + "$ref": "#/components/schemas/DataTableResp" }, - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/AdminUserInfoResp" - }, - "nullable": true + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AdminUserInfoResp" + }, + "nullable": true + } + } } - } + ] }, "PurcahseHistoryItemResp": { "type": "object",