@visulima/api-platform 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -0
- package/bin/index.js +46 -0
- package/dist/chunk-AOL5OFCG.mjs +284 -0
- package/dist/chunk-AOL5OFCG.mjs.map +1 -0
- package/dist/chunk-ATZDRT65.js +284 -0
- package/dist/chunk-ATZDRT65.js.map +1 -0
- package/dist/{chunk-AJKZCWFG.js → chunk-F7RHRCUQ.js} +2 -2
- package/dist/chunk-F7RHRCUQ.js.map +1 -0
- package/dist/{chunk-XXZ56SKG.mjs → chunk-RPHC5ZGB.mjs} +2 -2
- package/dist/chunk-RPHC5ZGB.mjs.map +1 -0
- package/dist/index-server.d.ts +4 -14
- package/dist/index-server.js +9 -10
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +7 -8
- package/dist/index-server.mjs.map +1 -1
- package/dist/next/cli/index.js +8 -8
- package/dist/next/cli/index.js.map +1 -1
- package/dist/next/cli/index.mjs +8 -8
- package/dist/next/cli/index.mjs.map +1 -1
- package/dist/next/index-browser.js +2 -2
- package/dist/next/index-browser.mjs +1 -1
- package/dist/next/index-server.d.ts +14 -13
- package/dist/next/index-server.js +4 -4
- package/dist/next/index-server.js.map +1 -1
- package/dist/next/index-server.mjs +2 -2
- package/dist/next/index-server.mjs.map +1 -1
- package/dist/swagger-handler-ffed72c2.d.ts +19 -0
- package/next/cli/package.json +12 -3
- package/next/package.json +9 -0
- package/package.json +20 -20
- package/recipes/api/swagger.ts +12 -0
- package/recipes/pages/redoc-ui.tsx +5 -0
- package/recipes/pages/swagger-ui.tsx +5 -0
- package/dist/chunk-2LATTLUM.mjs +0 -166
- package/dist/chunk-2LATTLUM.mjs.map +0 -1
- package/dist/chunk-AJKZCWFG.js.map +0 -1
- package/dist/chunk-S7GUPAL4.js +0 -166
- package/dist/chunk-S7GUPAL4.js.map +0 -1
- package/dist/chunk-XXZ56SKG.mjs.map +0 -1
- package/src/connect/create-node-router.ts +0 -44
- package/src/connect/handler.ts +0 -46
- package/src/connect/middleware/cors-middleware.ts +0 -10
- package/src/connect/middleware/http-header-normalizer.ts +0 -93
- package/src/connect/middleware/rate-limiter-middleware.ts +0 -43
- package/src/connect/middleware/serializers-middleware.ts +0 -121
- package/src/connect/serializers/types.d.ts +0 -1
- package/src/connect/serializers/xml.ts +0 -13
- package/src/connect/serializers/yaml.ts +0 -7
- package/src/error-handler/jsonapi-error-handler.ts +0 -46
- package/src/error-handler/problem-error-handler.ts +0 -44
- package/src/error-handler/types.d.ts +0 -14
- package/src/error-handler/utils.ts +0 -39
- package/src/index-browser.tsx +0 -1
- package/src/index-server.ts +0 -75
- package/src/next/cli/index.ts +0 -2
- package/src/next/cli/list/api-route-file-parser.ts +0 -74
- package/src/next/cli/list/collect-api-route-files.ts +0 -42
- package/src/next/cli/list/list-command.ts +0 -105
- package/src/next/cli/list/routes-render.ts +0 -62
- package/src/next/cli/list/types.d.ts +0 -1
- package/src/next/index-browser.tsx +0 -3
- package/src/next/index-server.ts +0 -6
- package/src/next/routes/api/swagger.ts +0 -23
- package/src/next/routes/pages/swagger/get-static-properties-swagger.ts +0 -32
- package/src/next/routes/pages/swagger/redoc.tsx +0 -35
- package/src/next/routes/pages/swagger/swagger.tsx +0 -44
- package/src/next/webpack/with-open-api.ts +0 -63
- package/src/swagger/extend-swagger-spec.ts +0 -167
- package/src/swagger/swagger-handler.ts +0 -83
- package/src/utils.ts +0 -37
- package/src/zod/date-in-schema.ts +0 -57
- package/src/zod/date-out-schema.ts +0 -41
- package/src/zod/index.ts +0 -9
|
@@ -5,9 +5,12 @@ import * as next_dist_server_config_shared from 'next/dist/server/config-shared'
|
|
|
5
5
|
import { BaseDefinition } from '@visulima/jsdoc-open-api';
|
|
6
6
|
import { NextConfig, NextApiRequest, NextApiResponse } from 'next';
|
|
7
7
|
import { Configuration } from 'webpack';
|
|
8
|
-
import {
|
|
8
|
+
import { S as SwaggerHandlerOptions } from '../swagger-handler-ffed72c2.js';
|
|
9
9
|
import 'redoc';
|
|
10
10
|
import 'swagger-ui-react';
|
|
11
|
+
import '@visulima/crud';
|
|
12
|
+
import 'node:http';
|
|
13
|
+
import 'openapi-types';
|
|
11
14
|
|
|
12
15
|
declare const withOpenApi: ({ definition, sources, verbose, output, }: {
|
|
13
16
|
definition: Exclude<BaseDefinition, "openapi"> & {
|
|
@@ -35,7 +38,6 @@ declare const withOpenApi: ({ definition, sources, verbose, output, }: {
|
|
|
35
38
|
fallback: next_dist_lib_load_custom_routes.Rewrite[];
|
|
36
39
|
}>) | undefined;
|
|
37
40
|
redirects?: (() => Promise<next_dist_lib_load_custom_routes.Redirect[]>) | undefined;
|
|
38
|
-
webpack5?: false | undefined;
|
|
39
41
|
excludeDefaultMomentLocales?: boolean | undefined;
|
|
40
42
|
trailingSlash?: boolean | undefined;
|
|
41
43
|
env?: Record<string, string> | undefined;
|
|
@@ -67,7 +69,7 @@ declare const withOpenApi: ({ definition, sources, verbose, output, }: {
|
|
|
67
69
|
} | undefined;
|
|
68
70
|
productionBrowserSourceMaps?: boolean | undefined;
|
|
69
71
|
optimizeFonts?: boolean | undefined;
|
|
70
|
-
reactStrictMode?: boolean | undefined;
|
|
72
|
+
reactStrictMode?: boolean | null | undefined;
|
|
71
73
|
publicRuntimeConfig?: {
|
|
72
74
|
[key: string]: any;
|
|
73
75
|
} | undefined;
|
|
@@ -77,9 +79,6 @@ declare const withOpenApi: ({ definition, sources, verbose, output, }: {
|
|
|
77
79
|
httpAgentOptions?: {
|
|
78
80
|
keepAlive?: boolean | undefined;
|
|
79
81
|
} | undefined;
|
|
80
|
-
future?: {
|
|
81
|
-
webpack5?: false | undefined;
|
|
82
|
-
} | undefined;
|
|
83
82
|
outputFileTracing?: boolean | undefined;
|
|
84
83
|
staticPageGenerationTimeout?: number | undefined;
|
|
85
84
|
crossOrigin?: false | "anonymous" | "use-credentials" | undefined;
|
|
@@ -112,18 +111,20 @@ declare const withOpenApi: ({ definition, sources, verbose, output, }: {
|
|
|
112
111
|
sourceMap?: boolean | undefined;
|
|
113
112
|
autoLabel?: "never" | "dev-only" | "always" | undefined;
|
|
114
113
|
labelFormat?: string | undefined;
|
|
114
|
+
importMap?: {
|
|
115
|
+
[importName: string]: {
|
|
116
|
+
[exportName: string]: {
|
|
117
|
+
canonicalImport?: [string, string] | undefined;
|
|
118
|
+
styledBaseImport?: [string, string] | undefined;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
} | undefined;
|
|
115
122
|
} | undefined;
|
|
116
123
|
} | undefined;
|
|
117
124
|
output?: "standalone" | undefined;
|
|
118
125
|
experimental?: next_dist_server_config_shared.ExperimentalConfig | undefined;
|
|
119
126
|
};
|
|
120
127
|
|
|
121
|
-
declare const swaggerApiRoute: (options?: Partial<
|
|
122
|
-
allowedMediaTypes: {
|
|
123
|
-
[key: string]: boolean;
|
|
124
|
-
};
|
|
125
|
-
swaggerFilePath: string;
|
|
126
|
-
crud: Exclude<ModelsToOpenApiParameters, "swagger.allowedMediaTypes">;
|
|
127
|
-
}>) => (request: NextApiRequest, response: NextApiResponse<any>) => Promise<void>;
|
|
128
|
+
declare const swaggerApiRoute: (options?: Partial<SwaggerHandlerOptions>) => (request: NextApiRequest, response: NextApiResponse<any>) => Promise<void>;
|
|
128
129
|
|
|
129
130
|
export { swaggerApiRoute, withOpenApi };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkATZDRT65js = require('../chunk-ATZDRT65.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkF7RHRCUQjs = require('../chunk-F7RHRCUQ.js');
|
|
9
9
|
require('../chunk-JC4IRQUL.js');
|
|
10
10
|
|
|
11
11
|
// src/next/webpack/with-open-api.ts
|
|
@@ -61,7 +61,7 @@ var with_open_api_default = withOpenApi;
|
|
|
61
61
|
// src/next/routes/api/swagger.ts
|
|
62
62
|
var _connect = require('@visulima/connect');
|
|
63
63
|
var swaggerApiRoute = (options = {}) => {
|
|
64
|
-
const handler =
|
|
64
|
+
const handler = _chunkATZDRT65js.swagger_handler_default.call(void 0, options);
|
|
65
65
|
const router = _connect.createNodeRouter.call(void 0, ).get(handler);
|
|
66
66
|
return router.handler();
|
|
67
67
|
};
|
|
@@ -72,5 +72,5 @@ var swagger_default2 = swaggerApiRoute;
|
|
|
72
72
|
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
exports.RedocPage =
|
|
75
|
+
exports.RedocPage = _chunkF7RHRCUQjs.redoc_default; exports.SwaggerPage = _chunkF7RHRCUQjs.swagger_default; exports.getSwaggerStaticProps = _chunkF7RHRCUQjs.get_static_properties_swagger_default; exports.swaggerApiRoute = swagger_default2; exports.withOpenApi = with_open_api_default;
|
|
76
76
|
//# sourceMappingURL=index-server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/webpack/with-open-api.ts","../../src/next/routes/api/swagger.ts"],"names":["swagger_default"],"mappings":";;;;;;;;;;;AACA,SAAS,6BAA6B;AAEtC,OAAO,QAAQ;AACf,OAAO,UAAU;AAGjB,IAAM,cAAc,CAAC;AAAA,EACjB;AAAA,EAAY;AAAA,EAAS;AAAA,EAAS,SAAS;AAE3C,MAAuI,CAAC,eAA2B;AAC/J,SAAO;AAAA,IACH,GAAG;AAAA,IACH,SAAS,CAAC,QAAuB,YAAiB;AAC9C,UAAI,CAAC,QAAQ,UAAU;AACnB,eAAO;AAAA,MACX;AAEA,UAAI,OAAO,WAAW,GAAG,GAAG;AAExB,iBAAS,OAAO,MAAM,CAAC;AAAA,MAC3B;AAEA,UAAI,CAAC,OAAO,SAAS,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,qCAAqC;AAAA,MACzD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AAI;AAAA,YACA,GAAG,QAAQ,OAAO;AAAA,YAClB,QAAQ,IAAI,CAAC,WAAW;AACpB,oBAAM,eAAe,KAAK,KAAK,QAAQ,KAAK,OAAO,QAAQ,MAAM,EAAE,CAAC;AAGpE,iBAAG,UAAU,YAAY,EAAE,YAAY;AAEvC,qBAAO;AAAA,YACX,CAAC;AAAA,YACD;AAAA,cAEI,SAAS;AAAA,cACT,GAAG;AAAA,YACP;AAAA,YACA,EAAE,QAAQ;AAAA,UACd;AAAA,QACJ;AAAA,MACJ;AAEA,UAAI,OAAO,WAAW,YAAY,YAAY;AAC1C,eAAO,WAAW,QAAQ,QAAQ,OAAO;AAAA,MAC7C;AAEA,aAAO;AAAA,IACX;AAAA,EACJ;AACJ;AAEA,IAAO,wBAAQ;;;AC9Df,SAAS,wBAAwB;AAOjC,IAAM,kBAAkB,CACpB,UAA0C,CAAC,MAC1C;AACD,QAAM,UAAU,wBAAe,OAAO;AAEtC,QAAM,SAAS,iBAAkD,EAAE,IAAI,OAAO;AAE9E,SAAO,OAAO,QAAQ;AAC1B;AAEA,IAAOA,mBAAQ","sourcesContent":["import type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport type { NextConfig } from \"next\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi = ({\n definition, sources, verbose, output = \"swagger/swagger.json\",\n// eslint-disable-next-line max-len\n}: { definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string }; sources: string[]; verbose?: boolean; output: string }) => (nextConfig: NextConfig) => {\n return {\n ...nextConfig,\n webpack: (config: Configuration, options: any) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = path.join(options.dir, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-ignore\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options);\n }\n\n return config;\n },\n };\n};\n\nexport default withOpenApi;\n","import { createNodeRouter } from \"@visulima/connect\";\n// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport type { NextApiRequest, NextApiResponse } from \"next\";\n\nimport swaggerHandler, { SwaggerHandlerOptions } from \"../../../swagger/swagger-handler\";\n\n// eslint-disable-next-line max-len\nconst swaggerApiRoute = (\n options: Partial<SwaggerHandlerOptions> = {},\n) => {\n const handler = swaggerHandler(options);\n\n const router = createNodeRouter<NextApiRequest, NextApiResponse>().get(handler);\n\n return router.handler();\n};\n\nexport default swaggerApiRoute;\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
swagger_handler_default
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-AOL5OFCG.mjs";
|
|
4
4
|
import {
|
|
5
5
|
get_static_properties_swagger_default,
|
|
6
6
|
redoc_default,
|
|
7
7
|
swagger_default
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-RPHC5ZGB.mjs";
|
|
9
9
|
import "../chunk-5VRACIDE.mjs";
|
|
10
10
|
|
|
11
11
|
// src/next/webpack/with-open-api.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/next/webpack/with-open-api.ts","../../src/next/routes/api/swagger.ts"],"sourcesContent":["import type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport type { NextConfig } from \"next\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi = ({\n definition, sources, verbose, output = \"swagger/swagger.json\",\n// eslint-disable-next-line max-len\n}: { definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string }; sources: string[]; verbose?: boolean; output: string }) => (nextConfig: NextConfig) => {\n return {\n ...nextConfig,\n webpack: (config: Configuration, options: any) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = path.join(options.dir, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-ignore\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options);\n }\n\n return config;\n },\n };\n};\n\nexport default withOpenApi;\n","import { createNodeRouter } from \"@visulima/connect\";\n// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/next/webpack/with-open-api.ts","../../src/next/routes/api/swagger.ts"],"sourcesContent":["import type { BaseDefinition } from \"@visulima/jsdoc-open-api\";\nimport { SwaggerCompilerPlugin } from \"@visulima/jsdoc-open-api\";\nimport type { NextConfig } from \"next\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { Configuration } from \"webpack\";\n\nconst withOpenApi = ({\n definition, sources, verbose, output = \"swagger/swagger.json\",\n// eslint-disable-next-line max-len\n}: { definition: Exclude<BaseDefinition, \"openapi\"> & { openapi?: string }; sources: string[]; verbose?: boolean; output: string }) => (nextConfig: NextConfig) => {\n return {\n ...nextConfig,\n webpack: (config: Configuration, options: any) => {\n if (!options.isServer) {\n return config;\n }\n\n if (output.startsWith(\"/\")) {\n // eslint-disable-next-line no-param-reassign\n output = output.slice(1);\n }\n\n if (!output.endsWith(\".json\")) {\n throw new Error(\"The output path must end with .json\");\n }\n\n // eslint-disable-next-line no-param-reassign\n config = {\n ...config,\n plugins: [\n // @ts-ignore\n ...config.plugins,\n new SwaggerCompilerPlugin(\n `${options.dir}/${output}`,\n sources.map((source) => {\n const combinedPath = path.join(options.dir, source.replace(\"./\", \"\"));\n\n // Check if the path is a directory\n fs.lstatSync(combinedPath).isDirectory();\n\n return combinedPath;\n }),\n {\n // @ts-ignore\n openapi: \"3.0.0\",\n ...definition,\n },\n { verbose },\n ),\n ],\n };\n\n if (typeof nextConfig.webpack === \"function\") {\n return nextConfig.webpack(config, options);\n }\n\n return config;\n },\n };\n};\n\nexport default withOpenApi;\n","import { createNodeRouter } from \"@visulima/connect\";\n// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport type { NextApiRequest, NextApiResponse } from \"next\";\n\nimport swaggerHandler, { SwaggerHandlerOptions } from \"../../../swagger/swagger-handler\";\n\n// eslint-disable-next-line max-len\nconst swaggerApiRoute = (\n options: Partial<SwaggerHandlerOptions> = {},\n) => {\n const handler = swaggerHandler(options);\n\n const router = createNodeRouter<NextApiRequest, NextApiResponse>().get(handler);\n\n return router.handler();\n};\n\nexport default swaggerApiRoute;\n"],"mappings":";;;;;;;;;;;AACA,SAAS,6BAA6B;AAEtC,OAAO,QAAQ;AACf,OAAO,UAAU;AAGjB,IAAM,cAAc,CAAC;AAAA,EACjB;AAAA,EAAY;AAAA,EAAS;AAAA,EAAS,SAAS;AAE3C,MAAuI,CAAC,eAA2B;AAC/J,SAAO;AAAA,IACH,GAAG;AAAA,IACH,SAAS,CAAC,QAAuB,YAAiB;AAC9C,UAAI,CAAC,QAAQ,UAAU;AACnB,eAAO;AAAA,MACX;AAEA,UAAI,OAAO,WAAW,GAAG,GAAG;AAExB,iBAAS,OAAO,MAAM,CAAC;AAAA,MAC3B;AAEA,UAAI,CAAC,OAAO,SAAS,OAAO,GAAG;AAC3B,cAAM,IAAI,MAAM,qCAAqC;AAAA,MACzD;AAGA,eAAS;AAAA,QACL,GAAG;AAAA,QACH,SAAS;AAAA,UAEL,GAAG,OAAO;AAAA,UACV,IAAI;AAAA,YACA,GAAG,QAAQ,OAAO;AAAA,YAClB,QAAQ,IAAI,CAAC,WAAW;AACpB,oBAAM,eAAe,KAAK,KAAK,QAAQ,KAAK,OAAO,QAAQ,MAAM,EAAE,CAAC;AAGpE,iBAAG,UAAU,YAAY,EAAE,YAAY;AAEvC,qBAAO;AAAA,YACX,CAAC;AAAA,YACD;AAAA,cAEI,SAAS;AAAA,cACT,GAAG;AAAA,YACP;AAAA,YACA,EAAE,QAAQ;AAAA,UACd;AAAA,QACJ;AAAA,MACJ;AAEA,UAAI,OAAO,WAAW,YAAY,YAAY;AAC1C,eAAO,WAAW,QAAQ,QAAQ,OAAO;AAAA,MAC7C;AAEA,aAAO;AAAA,IACX;AAAA,EACJ;AACJ;AAEA,IAAO,wBAAQ;;;AC9Df,SAAS,wBAAwB;AAOjC,IAAM,kBAAkB,CACpB,UAA0C,CAAC,MAC1C;AACD,QAAM,UAAU,wBAAe,OAAO;AAEtC,QAAM,SAAS,iBAAkD,EAAE,IAAI,OAAO;AAE9E,SAAO,OAAO,QAAQ;AAC1B;AAEA,IAAOA,mBAAQ;","names":["swagger_default"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModelsToOpenApiParameters, SwaggerModelsConfig } from '@visulima/crud';
|
|
2
|
+
import { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
|
+
import { OpenAPIV3 } from 'openapi-types';
|
|
4
|
+
|
|
5
|
+
declare const swaggerHandler: (options?: Partial<SwaggerHandlerOptions>) => <Request_1 extends IncomingMessage, Response_1 extends ServerResponse<IncomingMessage>>(request: Request_1, response: Response_1) => Promise<void>;
|
|
6
|
+
declare type SwaggerHandlerOptions = {
|
|
7
|
+
allowedMediaTypes: {
|
|
8
|
+
[key: string]: boolean;
|
|
9
|
+
};
|
|
10
|
+
swaggerFilePath: string;
|
|
11
|
+
crud: Exclude<ModelsToOpenApiParameters, "swagger"> & {
|
|
12
|
+
swagger?: {
|
|
13
|
+
models?: SwaggerModelsConfig<string>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
specs?: Partial<OpenAPIV3.Document>[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { SwaggerHandlerOptions as S, swaggerHandler as s };
|
package/next/cli/package.json
CHANGED
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"description": "visulima api platform",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./../../dist/next/cli/index-server.d.ts",
|
|
9
|
+
"browser": "./../../dist/next/cli/index-browser.js",
|
|
10
|
+
"require": "./../../dist/next/cli/index-server.js",
|
|
11
|
+
"import": "./../../dist/next/cli/index-server.mjs"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"main": "../../dist/next/cli/index.js",
|
|
16
|
+
"module": "../../dist/next/cli/index.mjs",
|
|
17
|
+
"types": "../../dist/next/cli/index.d.ts"
|
|
9
18
|
}
|
package/next/package.json
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"description": "visulima api platform",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./../dist/next/index-server.d.ts",
|
|
9
|
+
"browser": "./../dist/next/index-browser.js",
|
|
10
|
+
"require": "./../dist/next/index-server.js",
|
|
11
|
+
"import": "./../dist/next/index-server.mjs"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
6
15
|
"main": "../dist/next/index-server.js",
|
|
7
16
|
"module": "../dist/next/index-server.mjs",
|
|
8
17
|
"browser": "../dist/next/index-browser.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visulima/api-platform",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "visulima api platform",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anolilab",
|
|
@@ -71,26 +71,27 @@
|
|
|
71
71
|
"browser": "dist/index-browser.mjs",
|
|
72
72
|
"types": "dist/index-server.d.ts",
|
|
73
73
|
"files": [
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
74
|
+
"bin/**",
|
|
75
|
+
"next/**",
|
|
76
|
+
"dist/**",
|
|
77
|
+
"recipes/**",
|
|
77
78
|
"README.md",
|
|
78
79
|
"CHANGELOG.md",
|
|
79
80
|
"LICENSE.md"
|
|
80
81
|
],
|
|
81
82
|
"scripts": {
|
|
82
|
-
"build": "cross-env NODE_ENV=development tsup",
|
|
83
|
-
"build:prod": "cross-env NODE_ENV=production tsup",
|
|
83
|
+
"build": "rimraf dist && cross-env NODE_ENV=development tsup",
|
|
84
|
+
"build:prod": "rimraf dist && cross-env NODE_ENV=production tsup",
|
|
84
85
|
"clean": "rimraf node_modules dist",
|
|
85
86
|
"coverage": "vitest run --coverage",
|
|
86
87
|
"dev": "pnpm predev && pnpm run build --watch",
|
|
87
|
-
"lint:eslint": "cross-env NO_LOGS=true eslint --ext js,jsx,ts,tsx --max-warnings=0 --config .eslintrc.cjs",
|
|
88
|
+
"lint:eslint": "cross-env NO_LOGS=true eslint . --ext js,jsx,ts,tsx --max-warnings=0 --config .eslintrc.cjs --cache --cache-strategy content .",
|
|
88
89
|
"lint:eslint:fix": "pnpm run lint:eslint --fix",
|
|
89
90
|
"test": "vitest"
|
|
90
91
|
},
|
|
91
92
|
"dependencies": {
|
|
92
|
-
"@visulima/connect": "1.3.
|
|
93
|
-
"@visulima/jsdoc-open-api": "1.2.
|
|
93
|
+
"@visulima/connect": "1.3.1",
|
|
94
|
+
"@visulima/jsdoc-open-api": "1.2.1",
|
|
94
95
|
"accepts": "^1.3.8",
|
|
95
96
|
"case": "^1.6.3",
|
|
96
97
|
"debug": "^4.3.4",
|
|
@@ -120,14 +121,13 @@
|
|
|
120
121
|
"@types/qs": "^6.9.7",
|
|
121
122
|
"@types/react": "^18.0.21",
|
|
122
123
|
"@types/react-dom": "^18.0.6",
|
|
123
|
-
"@types/swagger-jsdoc": "^6.0.1",
|
|
124
124
|
"@types/swagger-ui-react": "^4.11.0",
|
|
125
125
|
"@types/webpack": "^5.28.0",
|
|
126
126
|
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
127
127
|
"@typescript-eslint/parser": "^5.40.0",
|
|
128
|
-
"@visulima/crud": "1.0.
|
|
129
|
-
"@visulima/readdir": "1.3.
|
|
130
|
-
"chalk": "
|
|
128
|
+
"@visulima/crud": "1.0.2",
|
|
129
|
+
"@visulima/readdir": "1.3.1",
|
|
130
|
+
"chalk": "5.1.2",
|
|
131
131
|
"commander": "^9.4.1",
|
|
132
132
|
"core-js": "^3.25.5",
|
|
133
133
|
"cors": "^2.8.5",
|
|
@@ -145,16 +145,16 @@
|
|
|
145
145
|
"eslint-plugin-optimize-regex": "^1.2.1",
|
|
146
146
|
"eslint-plugin-promise": "^6.0.1",
|
|
147
147
|
"eslint-plugin-radar": "^0.2.1",
|
|
148
|
-
"eslint-plugin-react": "7.31.
|
|
148
|
+
"eslint-plugin-react": "7.31.11",
|
|
149
149
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
150
150
|
"eslint-plugin-simple-import-sort": "^8.0.0",
|
|
151
151
|
"eslint-plugin-sort-keys-fix": "^1.1.2",
|
|
152
152
|
"eslint-plugin-testing-library": "^5.7.2",
|
|
153
|
-
"eslint-plugin-unicorn": "^
|
|
153
|
+
"eslint-plugin-unicorn": "^45.0.0",
|
|
154
154
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
|
|
155
155
|
"eslint-plugin-you-dont-need-momentjs": "^1.6.0",
|
|
156
156
|
"mobx": "^6.6.2",
|
|
157
|
-
"next": "^12.
|
|
157
|
+
"next": "^12.0.0 || ^13.0.0",
|
|
158
158
|
"next-test-api-route-handler": "^4.0.0-canary.1",
|
|
159
159
|
"node-mocks-http": "^1.11.0",
|
|
160
160
|
"openapi-types": "^12.0.2",
|
|
@@ -170,22 +170,22 @@
|
|
|
170
170
|
"swagger-ui-react": "^4.14.3",
|
|
171
171
|
"tsup": "^6.2.3",
|
|
172
172
|
"typescript": "^4.8.4",
|
|
173
|
-
"vitest": "^0.
|
|
173
|
+
"vitest": "^0.25.0",
|
|
174
174
|
"webpack": "^5.74.0",
|
|
175
175
|
"zod": "^3.19.1"
|
|
176
176
|
},
|
|
177
177
|
"peerDependencies": {
|
|
178
|
-
"next": "^12.3.1",
|
|
179
178
|
"react": "^18.2.0",
|
|
180
179
|
"react-dom": "^18.2.0",
|
|
181
180
|
"zod": "^3.19.1"
|
|
182
181
|
},
|
|
183
182
|
"optionalDependencies": {
|
|
184
|
-
"@visulima/crud": "1.0.
|
|
185
|
-
"@visulima/readdir": "1.3.
|
|
183
|
+
"@visulima/crud": "1.0.2",
|
|
184
|
+
"@visulima/readdir": "1.3.1",
|
|
186
185
|
"chalk": "4.1.2",
|
|
187
186
|
"commander": "^9.4.1",
|
|
188
187
|
"cors": "^2.8.5",
|
|
188
|
+
"next": "^12.0.0 || ^13.0.0",
|
|
189
189
|
"rate-limiter-flexible": "^2.3.11",
|
|
190
190
|
"redoc": "^2.0.0",
|
|
191
191
|
"swagger-ui-react": "^4.14.3",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { getSwaggerStaticProps as getSwaggerStaticProperties, RedocPage } from "@visulima/api-platform/next";
|
|
2
|
+
|
|
3
|
+
export const getStaticProps = getSwaggerStaticProperties(`${process.env.NEXT_PUBLIC_APP_ORIGIN}/api/swagger`);
|
|
4
|
+
|
|
5
|
+
export default RedocPage(`${process.env.NEXT_PUBLIC_APP_NAME} swagger`);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { getSwaggerStaticProps as getSwaggerStaticProperties, SwaggerPage } from "@visulima/api-platform/next";
|
|
2
|
+
|
|
3
|
+
export const getStaticProps = getSwaggerStaticProperties(`${process.env.NEXT_PUBLIC_APP_ORIGIN}/api/swagger`);
|
|
4
|
+
|
|
5
|
+
export default SwaggerPage(`${process.env.NEXT_PUBLIC_APP_NAME} swagger`);
|
package/dist/chunk-2LATTLUM.mjs
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
// src/swagger/swagger-handler.ts
|
|
2
|
-
import { modelsToOpenApi } from "@visulima/crud";
|
|
3
|
-
import debug from "debug";
|
|
4
|
-
import merge from "lodash.merge";
|
|
5
|
-
import { existsSync, readFileSync } from "fs";
|
|
6
|
-
import path from "path";
|
|
7
|
-
|
|
8
|
-
// src/connect/serializers/yaml.ts
|
|
9
|
-
import { stringify } from "yaml";
|
|
10
|
-
var yamlTransformer = (data) => stringify(data, { indent: 2 });
|
|
11
|
-
var yaml_default = yamlTransformer;
|
|
12
|
-
|
|
13
|
-
// src/swagger/extend-swagger-spec.ts
|
|
14
|
-
import { header as headerCase } from "case";
|
|
15
|
-
var extendComponentSchemas = (spec, schemaName, schema) => {
|
|
16
|
-
if (typeof spec.components !== "object") {
|
|
17
|
-
spec.components = {};
|
|
18
|
-
}
|
|
19
|
-
if (typeof spec.components.schemas !== "object") {
|
|
20
|
-
spec.components.schemas = {};
|
|
21
|
-
}
|
|
22
|
-
if (typeof spec.components.schemas[schemaName] === "undefined") {
|
|
23
|
-
spec.components.schemas[schemaName] = schema;
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var extendComponentExamples = (spec, exampleName, example) => {
|
|
27
|
-
if (typeof spec.components !== "object") {
|
|
28
|
-
spec.components = {};
|
|
29
|
-
}
|
|
30
|
-
if (typeof spec.components.examples !== "object") {
|
|
31
|
-
spec.components.examples = {};
|
|
32
|
-
}
|
|
33
|
-
if (typeof spec.components.examples[exampleName] === "undefined") {
|
|
34
|
-
spec.components.examples[exampleName] = example;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
function extendSwaggerWithMediaTypeSchema(responseSpec, allowedMediaTypes, pathKey, spec, methodSpec, status) {
|
|
38
|
-
let examples;
|
|
39
|
-
Object.entries(responseSpec.content).forEach(([mediaName, contentSpec]) => {
|
|
40
|
-
if (typeof contentSpec.schema === "object") {
|
|
41
|
-
const { schema } = contentSpec;
|
|
42
|
-
if (mediaName === "application/json" && typeof contentSpec.examples !== "undefined") {
|
|
43
|
-
examples = contentSpec.examples;
|
|
44
|
-
}
|
|
45
|
-
if (typeof schema.$ref !== "undefined") {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const schemaIsArray = schema.type === "array";
|
|
49
|
-
Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {
|
|
50
|
-
var _a, _b, _c;
|
|
51
|
-
if (!allowed) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const schemaName = `${headerCase(pathKey.trim().replace("/", ""))}${mediaType === "application/ld+json" ? ".jsonld" : ""}`;
|
|
55
|
-
extendComponentSchemas(spec, schemaName, schema);
|
|
56
|
-
if (typeof ((_c = (_b = (_a = methodSpec == null ? void 0 : methodSpec.responses) == null ? void 0 : _a[status]) == null ? void 0 : _b.content[mediaType]) == null ? void 0 : _c.schema) === "undefined") {
|
|
57
|
-
methodSpec.responses[status].content[mediaType] = { schema: {} };
|
|
58
|
-
}
|
|
59
|
-
methodSpec.responses[status].content[mediaType].schema = schemaIsArray ? {
|
|
60
|
-
type: "array",
|
|
61
|
-
items: {
|
|
62
|
-
$ref: `#/components/schemas/${schemaName}`
|
|
63
|
-
}
|
|
64
|
-
} : {
|
|
65
|
-
$ref: `#/components/schemas/${schemaName}`
|
|
66
|
-
};
|
|
67
|
-
if (typeof methodSpec.produces === "undefined") {
|
|
68
|
-
methodSpec.produces = [];
|
|
69
|
-
}
|
|
70
|
-
methodSpec.produces.push(mediaType);
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
return examples;
|
|
75
|
-
}
|
|
76
|
-
function extendSwaggerWithMediaTypeExamples(responseSpec, allowedMediaTypes, pathKey, spec, examples, methodSpec, status) {
|
|
77
|
-
Object.keys(responseSpec.content).forEach((mediaName) => {
|
|
78
|
-
if (mediaName === "application/json") {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {
|
|
82
|
-
var _a, _b, _c;
|
|
83
|
-
if (!allowed) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const examplesName = `${headerCase(pathKey.trim().replace("/", ""))}${mediaType === "application/ld+json" ? ".jsonld" : ""}`;
|
|
87
|
-
extendComponentExamples(spec, examplesName, examples);
|
|
88
|
-
if (typeof ((_c = (_b = (_a = methodSpec == null ? void 0 : methodSpec.responses) == null ? void 0 : _a[status]) == null ? void 0 : _b.content[mediaType]) == null ? void 0 : _c.examples) === "undefined") {
|
|
89
|
-
methodSpec.responses[status].content[mediaType] = { examples: {} };
|
|
90
|
-
}
|
|
91
|
-
methodSpec.responses[status].content[mediaType].examples = examples;
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function extendSwaggerSpec(spec, allowedMediaTypes) {
|
|
96
|
-
if (typeof spec === "object" && typeof spec.paths === "object") {
|
|
97
|
-
Object.entries(spec.paths).forEach(([pathKey, pathSpec]) => {
|
|
98
|
-
Object.values(pathSpec).forEach((methodSpec) => {
|
|
99
|
-
if (typeof methodSpec.responses === "object") {
|
|
100
|
-
Object.entries(methodSpec.responses).forEach(([status, responseSpec]) => {
|
|
101
|
-
if (typeof responseSpec.content === "object") {
|
|
102
|
-
let examples = extendSwaggerWithMediaTypeSchema(responseSpec, allowedMediaTypes, pathKey, spec, methodSpec, status);
|
|
103
|
-
if (typeof examples !== "undefined") {
|
|
104
|
-
extendSwaggerWithMediaTypeExamples(responseSpec, allowedMediaTypes, pathKey, spec, examples, methodSpec, status);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
return spec;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// src/swagger/swagger-handler.ts
|
|
116
|
-
var swaggerCrudDebug = debug("visulima:api-platform:swagger:crud:get-static-properties-swagger");
|
|
117
|
-
var swaggerHandler = (options = {}) => {
|
|
118
|
-
const {
|
|
119
|
-
allowedMediaTypes = {
|
|
120
|
-
"application/json": true
|
|
121
|
-
},
|
|
122
|
-
swaggerFilePath,
|
|
123
|
-
crud
|
|
124
|
-
} = options;
|
|
125
|
-
return async (request, response) => {
|
|
126
|
-
const swaggerPath = path.join(process.cwd(), swaggerFilePath || "swagger/swagger.json");
|
|
127
|
-
if (!existsSync(swaggerPath)) {
|
|
128
|
-
throw new Error(`Swagger file not found at ${swaggerPath}. Did you change the output path in "withOpenApi" inside the next.config.js file?`);
|
|
129
|
-
}
|
|
130
|
-
const fileContents = readFileSync(swaggerPath, "utf8");
|
|
131
|
-
let spec = extendSwaggerSpec(JSON.parse(fileContents), allowedMediaTypes);
|
|
132
|
-
let crudSwagger = {};
|
|
133
|
-
if (typeof crud !== "undefined") {
|
|
134
|
-
try {
|
|
135
|
-
const modelsOpenApi = await modelsToOpenApi(crud);
|
|
136
|
-
crudSwagger = {
|
|
137
|
-
components: { schemas: modelsOpenApi.schemas, examples: modelsOpenApi.examples },
|
|
138
|
-
tags: modelsOpenApi.tags,
|
|
139
|
-
paths: modelsOpenApi.paths
|
|
140
|
-
};
|
|
141
|
-
crudSwagger = extendSwaggerSpec(crudSwagger, allowedMediaTypes);
|
|
142
|
-
swaggerCrudDebug(JSON.stringify(crudSwagger, null, 2));
|
|
143
|
-
spec = merge(spec, crudSwagger);
|
|
144
|
-
} catch (error) {
|
|
145
|
-
console.log(error);
|
|
146
|
-
throw new Error("Please install @visulima/crud to use the crud swagger generator.");
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (typeof request.headers.accept === "string" && /yaml|yml/.test(request.headers.accept)) {
|
|
150
|
-
response.statusCode = 200;
|
|
151
|
-
response.setHeader("Content-Type", request.headers.accept);
|
|
152
|
-
response.end(yaml_default(spec));
|
|
153
|
-
} else {
|
|
154
|
-
response.statusCode = 200;
|
|
155
|
-
response.setHeader("Content-Type", "application/json");
|
|
156
|
-
response.end(JSON.stringify(spec, null, 2));
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
};
|
|
160
|
-
var swagger_handler_default = swaggerHandler;
|
|
161
|
-
|
|
162
|
-
export {
|
|
163
|
-
yaml_default,
|
|
164
|
-
swagger_handler_default
|
|
165
|
-
};
|
|
166
|
-
//# sourceMappingURL=chunk-2LATTLUM.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/swagger/swagger-handler.ts","../src/connect/serializers/yaml.ts","../src/swagger/extend-swagger-spec.ts"],"sourcesContent":["// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport type { ModelsToOpenApiParameters, SwaggerModelsConfig } from \"@visulima/crud\";\n// eslint-disable-next-line unicorn/prevent-abbreviations,import/no-extraneous-dependencies\nimport { modelsToOpenApi } from \"@visulima/crud\";\nimport debug from \"debug\";\nimport merge from \"lodash.merge\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport path from \"node:path\";\nimport type { OAS3Definition, Tag } from \"swagger-jsdoc\";\n\nimport yamlTransformer from \"../connect/serializers/yaml\";\nimport extendSwaggerSpec from \"./extend-swagger-spec\";\n\n// eslint-disable-next-line testing-library/no-debugging-utils\nconst swaggerCrudDebug = debug(\"visulima:api-platform:swagger:crud:get-static-properties-swagger\");\n\nconst swaggerHandler = (\n options: Partial<{\n allowedMediaTypes: { [key: string]: boolean };\n swaggerFilePath: string;\n crud: Exclude<ModelsToOpenApiParameters, \"swagger\"> & {\n swagger?: {\n models?: SwaggerModelsConfig<string>;\n };\n };\n }> = {},\n) => {\n const {\n allowedMediaTypes = {\n \"application/json\": true,\n },\n swaggerFilePath,\n crud,\n } = options;\n\n return async <Request extends IncomingMessage, Response extends ServerResponse>(request: Request, response: Response) => {\n const swaggerPath = path.join(process.cwd(), swaggerFilePath || \"swagger/swagger.json\");\n\n if (!existsSync(swaggerPath)) {\n throw new Error(`Swagger file not found at ${swaggerPath}. Did you change the output path in \"withOpenApi\" inside the next.config.js file?`);\n }\n\n const fileContents = readFileSync(swaggerPath, \"utf8\");\n\n let spec = extendSwaggerSpec(JSON.parse(fileContents) as OAS3Definition, allowedMediaTypes) as OAS3Definition;\n let crudSwagger: Partial<OAS3Definition> = {};\n\n if (typeof crud !== \"undefined\") {\n try {\n const modelsOpenApi = await modelsToOpenApi(crud);\n\n crudSwagger = {\n components: { schemas: modelsOpenApi.schemas, examples: modelsOpenApi.examples },\n tags: modelsOpenApi.tags as Tag[],\n paths: modelsOpenApi.paths,\n };\n\n crudSwagger = extendSwaggerSpec(crudSwagger, allowedMediaTypes);\n\n swaggerCrudDebug(JSON.stringify(crudSwagger, null, 2));\n\n spec = merge(spec, crudSwagger);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.log(error);\n throw new Error(\"Please install @visulima/crud to use the crud swagger generator.\");\n }\n }\n\n if (typeof request.headers.accept === \"string\" && /yaml|yml/.test(request.headers.accept)) {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", request.headers.accept);\n response.end(yamlTransformer(spec));\n } else {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", \"application/json\");\n response.end(JSON.stringify(spec, null, 2));\n }\n };\n};\n\nexport default swaggerHandler;\n","import { stringify } from \"yaml\";\n\nimport type { Serializer } from \"./types\";\n\nconst yamlTransformer: Serializer = (data) => stringify(data, { indent: 2 });\n\nexport default yamlTransformer;\n","import { header as headerCase } from \"case\";\nimport type { OpenAPIV3 } from \"openapi-types\";\nimport type { OAS3Definition, Operation, Responses } from \"swagger-jsdoc\";\n\nconst extendComponentSchemas = (spec: Partial<OAS3Definition>, schemaName: string, schema: OpenAPIV3.SchemaObject) => {\n if (typeof spec.components !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components = {};\n }\n\n if (typeof spec.components.schemas !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.schemas = {};\n }\n\n if (typeof spec.components.schemas[schemaName] === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.schemas[schemaName] = schema;\n }\n};\n\nconst extendComponentExamples = (spec: Partial<OAS3Definition>, exampleName: string, example: OpenAPIV3.SchemaObject) => {\n if (typeof spec.components !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components = {};\n }\n\n if (typeof spec.components.examples !== \"object\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.examples = {};\n }\n\n if (typeof spec.components.examples[exampleName] === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n spec.components.examples[exampleName] = example;\n }\n};\n\nfunction extendSwaggerWithMediaTypeSchema(\n responseSpec: OpenAPIV3.ResponseObject,\n allowedMediaTypes: { [p: string]: boolean } | undefined,\n pathKey: string,\n spec: Partial<OAS3Definition>,\n methodSpec: Operation,\n status: string,\n) {\n let examples:\n | {\n [media: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject;\n }\n | undefined;\n\n Object.entries(responseSpec.content as object).forEach(([mediaName, contentSpec]) => {\n if (typeof contentSpec.schema === \"object\") {\n const { schema } = contentSpec;\n\n if (mediaName === \"application/json\" && typeof contentSpec.examples !== \"undefined\") {\n examples = contentSpec.examples;\n }\n\n if (typeof (schema as OpenAPIV3.ReferenceObject).$ref !== \"undefined\") {\n return;\n }\n\n const schemaIsArray = (schema as OpenAPIV3.SchemaObject).type === \"array\";\n\n Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n // eslint-disable-next-line max-len\n const schemaName = `${headerCase(pathKey.trim().replace(\"/\", \"\"))}${mediaType === \"application/ld+json\" ? \".jsonld\" : \"\"}`;\n\n extendComponentSchemas(spec as OAS3Definition, schemaName, schema as OpenAPIV3.SchemaObject);\n\n if (typeof methodSpec?.responses?.[status]?.content[mediaType]?.schema === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType] = { schema: {} };\n }\n\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType].schema = schemaIsArray\n ? {\n type: \"array\",\n items: {\n $ref: `#/components/schemas/${schemaName}`,\n },\n }\n : {\n $ref: `#/components/schemas/${schemaName}`,\n };\n\n if (typeof methodSpec.produces === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n methodSpec.produces = [];\n }\n\n methodSpec.produces.push(mediaType);\n });\n }\n });\n\n return examples;\n}\n\nfunction extendSwaggerWithMediaTypeExamples(\n responseSpec: OpenAPIV3.ResponseObject,\n allowedMediaTypes: { [p: string]: boolean } | undefined,\n pathKey: string,\n spec: Partial<OAS3Definition>,\n examples: { [p: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject } | undefined,\n methodSpec: Operation,\n status: string,\n) {\n Object.keys(responseSpec.content as object).forEach((mediaName) => {\n if (mediaName === \"application/json\") {\n return;\n }\n\n Object.entries(allowedMediaTypes || {}).forEach(([mediaType, allowed]) => {\n if (!allowed) {\n return;\n }\n\n // eslint-disable-next-line max-len\n const examplesName = `${headerCase(pathKey.trim().replace(\"/\", \"\"))}${mediaType === \"application/ld+json\" ? \".jsonld\" : \"\"}`;\n\n extendComponentExamples(spec as OAS3Definition, examplesName, examples as OpenAPIV3.SchemaObject);\n\n if (typeof methodSpec?.responses?.[status]?.content[mediaType]?.examples === \"undefined\") {\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType] = { examples: {} };\n }\n\n // eslint-disable-next-line no-param-reassign\n (methodSpec.responses as Responses)[status].content[mediaType].examples = examples;\n });\n });\n}\n\n// eslint-disable-next-line radar/cognitive-complexity\nexport default function extendSwaggerSpec(spec: Partial<OAS3Definition>, allowedMediaTypes?: { [key: string]: boolean }): Partial<OAS3Definition> {\n if (typeof spec === \"object\" && typeof spec.paths === \"object\") {\n Object.entries(spec.paths).forEach(([pathKey, pathSpec]) => {\n Object.values(pathSpec).forEach((methodSpec) => {\n if (typeof methodSpec.responses === \"object\") {\n Object.entries<OpenAPIV3.ResponseObject>(methodSpec.responses).forEach(([status, responseSpec]) => {\n if (typeof responseSpec.content === \"object\") {\n let examples:\n | {\n [media: string]: OpenAPIV3.ReferenceObject | OpenAPIV3.ExampleObject;\n }\n | undefined = extendSwaggerWithMediaTypeSchema(responseSpec, allowedMediaTypes, pathKey, spec, methodSpec, status);\n\n if (typeof examples !== \"undefined\") {\n extendSwaggerWithMediaTypeExamples(responseSpec, allowedMediaTypes, pathKey, spec, examples, methodSpec, status);\n }\n }\n });\n }\n });\n });\n }\n\n return spec;\n}\n"],"mappings":";AAGA,SAAS,uBAAuB;AAChC,OAAO,WAAW;AAClB,OAAO,WAAW;AAClB,SAAS,YAAY,oBAAoB;AAEzC,OAAO,UAAU;;;ACRjB,SAAS,iBAAiB;AAI1B,IAAM,kBAA8B,CAAC,SAAS,UAAU,MAAM,EAAE,QAAQ,EAAE,CAAC;AAE3E,IAAO,eAAQ;;;ACNf,SAAS,UAAU,kBAAkB;AAIrC,IAAM,yBAAyB,CAAC,MAA+B,YAAoB,WAAmC;AAClH,MAAI,OAAO,KAAK,eAAe,UAAU;AAEr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Ac,SAAS;AAAA,UAC/E,MAAM,cAAc;AAAA,UACpB,OAAO,cAAc;AAAA,QACzB;AAEA,sBAAc,kBAAkB,aAAa,iBAAiB;AAE9D,yBAAiB,KAAK,UAAU,aAAa,MAAM,CAAC,CAAC;AAErD,eAAO,MAAM,MAAM,WAAW;AAAA,MAClC,SAAS,OAAP;AAEE,gBAAQ,IAAI,KAAK;AACjB,cAAM,IAAI,MAAM,kEAAkE;AAAA,MACtF;AAAA,IACJ;AAEA,QAAI,OAAO,QAAQ,QAAQ,WAAW,YAAY,WAAW,KAAK,QAAQ,QAAQ,MAAM,GAAG;AACvF,eAAS,aAAa;AACtB,eAAS,UAAU,gBAAgB,QAAQ,QAAQ,MAAM;AACzD,eAAS,IAAI,aAAgB,IAAI,CAAC;AAAA,IACtC,OAAO;AACH,eAAS,aAAa;AACtB,eAAS,UAAU,gBAAgB,kBAAkB;AACrD,eAAS,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;AAAA,IAC9C;AAAA,EACJ;AACJ;AAEA,IAAO,0BAAQ;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/next/routes/pages/swagger/redoc.tsx","../src/next/routes/pages/swagger/swagger.tsx","../src/next/routes/pages/swagger/get-static-properties-swagger.ts"],"names":["Head","React"],"mappings":";AAGA,OAAO,UAAU;AACjB,OAAO,WAAW;AAIlB,SAAS,uBAAuB;AAKhC,IAAM,mBAI0D,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,MAC3F,0DACI,oCAAC,YACG,oCAAC,eAAO,IAAK,GACb,oCAAC,eACI;AAAA;AAAA;AAAA;AAAA,CAKL,CACJ,GAEA,oCAAC;AAAA,EAAiB,GAAG;AAAA,EAAS,MAAM;AAAA,CAAa,CACrD;AAGZ,IAAO,gBAAQ;;;ACjCf,OAAO,aAAa;AAEpB,OAAOA,WAAU;AAEjB,OAAOC,YAAW;AAKlB,IAAM,YAAY,QAIf,OAAO,qBAAqB,EAAE,KAAK,MAAM,CAAC;AAC7C,QAIG,OAAO,oCAAoC,EAAE,KAAK,MAAM,CAAC;AAG5D,IAAM,qBAI0D,CAAC,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,YAAY,MAC3F,gBAAAA,OAAA,cAAAA,OAAA,gBACI,gBAAAA,OAAA,cAACD,OAAA,MACG,gBAAAC,OAAA,cAAC,eAAO,IAAK,GACb,gBAAAA,OAAA,cAAC,eACI;AAAA;AAAA;AAAA;AAAA,CAKL,CACJ,GAEA,gBAAAA,OAAA,cAAC;AAAA,EAAW,GAAG;AAAA,EAAS,MAAM;AAAA,CAAa,CAC/C;AAGZ,IAAO,kBAAQ;;;AC1Cf,OAAO,WAAW;AAKlB,IAAM,eAAe,MAAM,6DAA6D;AAGxF,IAAM,iBAEgB,CAAC,eAAe,YAKhC;AAEF,QAAM,WAAW,MAAM,MAAM,UAAU;AACvC,QAAM,cAAc,MAAM,SAAS,KAAK;AAExC,eAAa,WAAW;AAExB,SAAO;AAAA,IACH,OAAO;AAAA,MACH;AAAA,MACA,aAAa,KAAK,MAAM,KAAK,UAAU,WAAW,CAAC;AAAA,IACvD;AAAA,EACJ;AACJ;AAEA,IAAO,wCAAQ","sourcesContent":["// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { InferGetStaticPropsType, NextPage } from \"next\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\nimport React from \"react\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { RedocStandaloneProps } from \"redoc\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { RedocStandalone } from \"redoc\";\n\nimport getStaticProps from \"./get-static-properties-swagger\";\n\n// eslint-disable-next-line max-len\nconst RedocApiDocument: (\n name: string,\n swagger?: Exclude<RedocStandaloneProps, \"spec\">,\n // eslint-disable-next-line max-len,unicorn/no-useless-undefined\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (name, swagger = {}) => ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <RedocStandalone {...swagger} spec={swaggerData} />\n </>\n);\n\nexport default RedocApiDocument;\n","import type { InferGetStaticPropsType, NextPage } from \"next\";\nimport dynamic from \"next/dynamic\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport Head from \"next/head\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport React from \"react\";\nimport type { SwaggerUIProps } from \"swagger-ui-react\";\n\nimport getStaticProps from \"./get-static-properties-swagger\";\n// eslint-disable-next-line import/no-extraneous-dependencies\nconst SwaggerUI = dynamic<{\n spec: any;\n // @ts-ignore\n // eslint-disable-next-line import/no-extraneous-dependencies\n}>(import(\"swagger-ui-react\"), { ssr: false });\ndynamic<{\n spec: any;\n // @ts-ignore\n // eslint-disable-next-line import/no-extraneous-dependencies\n}>(import(\"swagger-ui-react/swagger-ui.css\"), { ssr: false });\n\n// eslint-disable-next-line max-len\nconst SwaggerApiDocument: (\n name: string,\n swagger?: Exclude<SwaggerUIProps, \"spec\">,\n // eslint-disable-next-line max-len,unicorn/no-useless-undefined\n) => NextPage<InferGetStaticPropsType<typeof getStaticProps>> = (name, swagger = {}) => ({ swaggerData }: InferGetStaticPropsType<typeof getStaticProps>) => (\n <>\n <Head>\n <title>{name}</title>\n <style>\n {`\nbody {\n background: #fafafa !important;\n}\n`}\n </style>\n </Head>\n {/* eslint-disable-next-line react/jsx-props-no-spreading */}\n <SwaggerUI {...swagger} spec={swaggerData} />\n </>\n);\n\nexport default SwaggerApiDocument;\n","// eslint-disable-next-line unicorn/prevent-abbreviations\nimport debug from \"debug\";\nimport type { GetStaticProps } from \"next\";\nimport type { OAS3Definition } from \"swagger-jsdoc\";\n\n// eslint-disable-next-line testing-library/no-debugging-utils\nconst swaggerDebug = debug(\"visulima:api-platform:swagger:get-static-properties-swagger\");\n\n// eslint-disable-next-line unicorn/consistent-function-scoping\nconst getStaticProps: (\n swaggerUrl: string,\n) => GetStaticProps = (swaggerUrl) => async (): Promise<{\n props: {\n swaggerUrl: string;\n swaggerData: OAS3Definition;\n };\n}> => {\n // eslint-disable-next-line compat/compat\n const response = await fetch(swaggerUrl);\n const swaggerData = await response.json();\n\n swaggerDebug(swaggerData);\n\n return {\n props: {\n swaggerUrl,\n swaggerData: JSON.parse(JSON.stringify(swaggerData)),\n },\n };\n};\n\nexport default getStaticProps;\n"]}
|