added swagger
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { GetStaticProps, InferGetStaticPropsType } from 'next';
|
||||
import { createSwaggerSpec } from 'next-swagger-doc';
|
||||
import dynamic from 'next/dynamic';
|
||||
import 'swagger-ui-react/swagger-ui.css';
|
||||
|
||||
const SwaggerUI = dynamic<{
|
||||
spec: any;
|
||||
}>(import('swagger-ui-react'), { ssr: false });
|
||||
|
||||
function ApiDoc({ spec }: InferGetStaticPropsType<typeof getStaticProps>) {
|
||||
return <SwaggerUI spec={spec} />;
|
||||
}
|
||||
|
||||
export const getStaticProps: GetStaticProps = async () => {
|
||||
const spec: Record<string, any> = createSwaggerSpec({
|
||||
|
||||
definition: {
|
||||
openapi: '3.0.0',
|
||||
info: {
|
||||
title: 'PEDW API',
|
||||
description: "something here",
|
||||
version: '1.0',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
props: {
|
||||
spec,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default ApiDoc;
|
||||
Reference in New Issue
Block a user