demo 20-4-2026

This commit is contained in:
taDuc
2026-04-19 23:43:31 +07:00
parent 34e709cea4
commit 7804ef842b
6 changed files with 105 additions and 17 deletions

View File

@@ -24,9 +24,15 @@ const openApiSpec = {
ErrorResponse: {
type: "object",
properties: {
error: { type: "string" },
status: { type: "string", enum: ["error"] },
data: { nullable: true },
message: { type: "string" },
errors: {
type: "array",
items: {},
},
},
required: ["error"],
required: ["status", "data", "message", "errors"],
},
Entity: {
type: "object",
@@ -366,7 +372,7 @@ function objectResponse(description, ref) {
description,
content: {
"application/json": {
schema: { $ref: ref },
schema: successEnvelopeSchema({ $ref: ref }),
},
},
};
@@ -377,15 +383,31 @@ function arrayResponse(description, itemRef) {
description,
content: {
"application/json": {
schema: {
schema: successEnvelopeSchema({
type: "array",
items: { $ref: itemRef },
},
}),
},
},
};
}
function successEnvelopeSchema(dataSchema) {
return {
type: "object",
properties: {
status: { type: "string", enum: ["success"] },
data: dataSchema,
message: { type: "string" },
errors: {
type: "array",
items: {},
},
},
required: ["status", "data", "message", "errors"],
};
}
function jsonBody(schema) {
return {
required: true,