51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
|
import { Operation } from "express-openapi";
|
||
|
|
||
|
// ./api-v1/paths/worlds.js
|
||
|
export default function () {
|
||
|
let operations = {
|
||
|
POST
|
||
|
};
|
||
|
|
||
|
// Define the Action.
|
||
|
async function POST(req, res, next) {
|
||
|
res.status(200).json('HELLO ' + req.body.greeter);
|
||
|
}
|
||
|
|
||
|
// Define the apiDoc for this specific Funtion
|
||
|
POST.apiDoc = {
|
||
|
summary: 'Says Hello to the greater',
|
||
|
operationId: 'getHello',
|
||
|
parameters: [
|
||
|
{
|
||
|
name: "body",
|
||
|
in: "body",
|
||
|
description: "Body of the Message",
|
||
|
required: true,
|
||
|
schema: {
|
||
|
description: "The Body. Containing The Greeter Object",
|
||
|
properties: {
|
||
|
greeter: {
|
||
|
type: "string"
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
],
|
||
|
responses: {
|
||
|
200: {
|
||
|
description: 'The Greeting Message',
|
||
|
schema: {
|
||
|
type: 'string',
|
||
|
}
|
||
|
},
|
||
|
default: {
|
||
|
description: 'An error occurred',
|
||
|
schema: {
|
||
|
additionalProperties: true
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
} as Operation;
|
||
|
|
||
|
return operations;
|
||
|
}
|