cal.pub0.org/pages/api/docs.ts

23 lines
688 B
TypeScript
Raw Normal View History

import jsonSchema from "@/json-schema/json-schema.json";
import pjson from "@/package.json";
import { withSwagger } from "next-swagger-doc";
2022-04-15 14:10:57 +00:00
import { withCors } from "@lib/helpers/withCors";
2022-04-15 15:04:17 +00:00
import { withCorsMiddleware } from "@lib/helpers/withCorsMiddleware";
2022-04-15 14:10:57 +00:00
const swaggerHandler = withSwagger({
definition: {
openapi: "3.0.0",
info: {
title: `${pjson.name}: ${pjson.description}`,
version: pjson.version,
},
components: { schemas: { ...jsonSchema.definitions } },
definitions: jsonSchema.definitions,
},
apiFolder: "pages/api",
tags: ["users", "teams", "memeberships"],
sort: true,
});
2022-04-15 15:04:17 +00:00
export default withCorsMiddleware()(swaggerHandler());