added swagger

This commit is contained in:
2023-03-01 15:47:55 +00:00
parent c38d67a37f
commit d8f0972170
12 changed files with 186 additions and 10 deletions
+34
View File
@@ -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;
+13
View File
@@ -0,0 +1,13 @@
import { withSwagger } from 'next-swagger-doc';
const swaggerHandler = withSwagger({
definition: {
openapi: '3.0.0',
info: {
title: 'NextJS Swagger',
version: '0.1.0',
},
},
apiFolder: 'pages/api',
});
export default swaggerHandler();
+23
View File
@@ -1,3 +1,26 @@
/**
* @swagger
* /api/documents/download/{id}:
* get:
* tags:
* - Documents
* description: Get document
* parameters:
* - name: id
* in: path
* description: iShare ID
* type: string
* required: true
* default: A21852159
* - name: hash
* in: query
* description: Hashe stirng
* default: 25d7ae78acb551d9e051b98fc425ebee9b201ba203afe4fc9d330e2b7895e072
* responses:
* 200:
* description: Success
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, consoleLogger } from "../../../../actions";
+12
View File
@@ -1,3 +1,15 @@
/**
* @swagger
* /api/email/notify:
* get:
* tags:
* - Email
* description: Send email via gov notify
* responses:
* 200:
* description: Success
*/
import { consoleLogger } from "../../../actions";
export default async function ApiProxy(req, res) {
-10
View File
@@ -6,16 +6,6 @@ import {
azureHeaders,
consoleLogger,
} from "../../../actions";
/**
* @swagger
* /api/endpoint/getappealtypes_api:
* get:
* description: Returns appeal types
* responses:
* 200:
* description:
*
*/
const WORDKEY = process.env.HASHKEY;
+11
View File
@@ -1,3 +1,14 @@
/**
* @swagger
* /api/endpoint/getlogin_api:
* get:
* tags: [Login]
* description: Returns the hello world
* responses:
* 200:
* description: hello world
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
+11
View File
@@ -1,3 +1,14 @@
/**
* @swagger
* /api/endpoint/getlpa_api:
* get:
* tags: [Search]
* description: Get list of LPA's
* responses:
* 200:
* description: Success
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import {