demo 20-4-2026
This commit is contained in:
32
swagger.js
32
swagger.js
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user