nope/open-api/helloWorldService.ts

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-08-19 06:36:59 +00:00
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;
}