Scheduling infrastructure for absolutely everyone.
Swagger docs improved (#2607)
Agusti Fernandezfa1b29a99fea
diff --git a/apps/swagger/lib/snippets.ts b/apps/swagger/lib/snippets.tsindex fa4d5d4c556..b1ec3fc3055 100644--- a/apps/swagger/lib/snippets.ts+++ b/apps/swagger/lib/snippets.ts@@ -77,7 +77,7 @@ export const SnippedGenerator = {// method,// targets// // Since I don't know why hostname was undefinedundefined, I harcoded it here- // ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ // ).snippets[0].content;// } catch (err) {// // set to error in case it happens the npm package has some flaws// snippet = JSON.stringify(snippet);@@ -104,12 +104,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);@@ -136,12 +132,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);@@ -168,12 +160,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);@@ -200,12 +188,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);@@ -237,7 +221,7 @@ export const SnippedGenerator = {// path,// method,// targets- // ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ // ).snippets[0].content;// } catch (err) {// // set to error in case it happens the npm package has some flaws// snippet = JSON.stringify(snippet);@@ -269,7 +253,7 @@ export const SnippedGenerator = {// path,// method,// targets- // ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ // ).snippets[0].content;// } catch (err) {// // set to error in case it happens the npm package has some flaws// snippet = JSON.stringify(snippet);@@ -296,12 +280,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);@@ -328,12 +308,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);@@ -360,12 +336,8 @@ export const SnippedGenerator = {let snippet;try {// set request snippet content- snippet = OpenAPISnippet.getEndpointSnippets(- spec,- path,- method,- targets- ).snippets[0].content.replaceAll("undefinedundefined", "https://api.cal.com");+ snippet = OpenAPISnippet.getEndpointSnippets(spec, path, method, targets).snippets[0]+ .content;} catch (err) {// set to error in case it happens the npm package has some flawssnippet = JSON.stringify(snippet);diff --git a/apps/swagger/package.json b/apps/swagger/package.jsonindex b68bafd9031..129452adfb1 100644--- a/apps/swagger/package.json+++ b/apps/swagger/package.json@@ -10,14 +10,14 @@"dependencies": {"highlight.js": "^11.5.1","isarray": "2.0.5",- "next": "12.1.4",+ "next": "12.1.5","openapi-snippet": "^0.13.0","react": "17.0.2","react-dom": "17.0.2",- "swagger-ui-react": "4.8.1"+ "swagger-ui-react": "4.10.3"},"devDependencies": {- "@types/node": "16.11.26",+ "@types/node": "17.0.27","@types/react": "17.0.43","@types/react-dom": "17.0.14","typescript": "4.6.3"diff --git a/apps/swagger/pages/index.tsx b/apps/swagger/pages/index.tsxindex 1baa91d5ed8..0631433672c 100644--- a/apps/swagger/pages/index.tsx+++ b/apps/swagger/pages/index.tsx@@ -1,12 +1,14 @@-import SwaggerUI from "swagger-ui-react";+import dynamic from "next/dynamic";import { SnippedGenerator, requestSnippets } from "@lib/snippets";+const SwaggerUI: any = dynamic(() => import("swagger-ui-react"), { ssr: false });+export default function APIDocs() {return (<SwaggerUIurl={process.env.NEXT_PUBLIC_SWAGGER_DOCS_URL || "https://api.cal.com/docs"}- supportedSubmitMethods={["get", "post", "put", "delete", "patch"]}+ supportedSubmitMethods={["get", "post", "delete", "patch"]}requestSnippetsEnabled={true}requestSnippets={requestSnippets}plugins={[SnippedGenerator]}diff --git a/package.json b/package.jsonindex 7ffb1e8fb2e..e1358293647 100644--- a/package.json+++ b/package.json@@ -17,6 +17,8 @@"deploy": "turbo run deploy","dev": "turbo run dev --scope=\"@calcom/web\"","dev:website": "yarn predev && turbo run dev --scope=\"@calcom/web\" --scope=\"@calcom/website\"",+ "dev:api": "yarn predev && turbo run dev --scope=\"@calcom/web\" --scope=\"@calcom/api\"",+ "dev:swagger": "yarn predev && turbo run dev --scope=\"@calcom/api\" --scope=\"@calcom/swagger\"","dev:console": "yarn predev && turbo run dev --scope=\"@calcom/web\" --scope=\"@calcom/console\"","docs-dev": "yarn predev && turbo run dev --scope=\"@calcom/docs\"","docs-build": "turbo run build --scope=\"@calcom/docs\" --include-dependencies",