@asyncapi/react-component 1.0.0-next.9 → 1.0.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/README.md +121 -36
- package/browser/index.js +32 -16
- package/browser/index.js.LICENSE.txt +88 -0
- package/browser/standalone/index.js +32 -45
- package/browser/standalone/index.js.LICENSE.txt +112 -0
- package/browser/standalone/without-parser.js +14 -41
- package/browser/standalone/without-parser.js.LICENSE.txt +110 -0
- package/browser/without-parser.js +14 -12
- package/browser/without-parser.js.LICENSE.txt +86 -0
- package/lib/cjs/components/Bindings.js +14 -5
- package/lib/cjs/components/Bindings.js.map +1 -1
- package/lib/cjs/components/CollapseButton.js +11 -7
- package/lib/cjs/components/CollapseButton.js.map +1 -1
- package/lib/cjs/components/Extensions.js +4 -3
- package/lib/cjs/components/Extensions.js.map +1 -1
- package/lib/cjs/components/Href.js +2 -1
- package/lib/cjs/components/Href.js.map +1 -1
- package/lib/cjs/components/JSONSnippet.js +2 -1
- package/lib/cjs/components/JSONSnippet.js.map +1 -1
- package/lib/cjs/components/Markdown.js +3 -2
- package/lib/cjs/components/Markdown.js.map +1 -1
- package/lib/cjs/components/Schema.js +74 -59
- package/lib/cjs/components/Schema.js.map +1 -1
- package/lib/cjs/components/Tag.js +3 -2
- package/lib/cjs/components/Tag.js.map +1 -1
- package/lib/cjs/components/Tags.js +3 -2
- package/lib/cjs/components/Tags.js.map +1 -1
- package/lib/cjs/components/index.js +5 -1
- package/lib/cjs/components/index.js.map +1 -1
- package/lib/cjs/config/config.js.map +1 -1
- package/lib/cjs/config/default.js +9 -1
- package/lib/cjs/config/default.js.map +1 -1
- package/lib/cjs/config/index.js +5 -1
- package/lib/cjs/config/index.js.map +1 -1
- package/lib/cjs/constants.js +12 -48
- package/lib/cjs/constants.js.map +1 -1
- package/lib/cjs/containers/AsyncApi/AsyncApi.js +28 -12
- package/lib/cjs/containers/AsyncApi/AsyncApi.js.map +1 -1
- package/lib/cjs/containers/AsyncApi/Layout.js +33 -21
- package/lib/cjs/containers/AsyncApi/Layout.js.map +1 -1
- package/lib/cjs/containers/AsyncApi/Standalone.js +8 -2
- package/lib/cjs/containers/AsyncApi/Standalone.js.map +1 -1
- package/lib/cjs/containers/Error/Error.js +4 -3
- package/lib/cjs/containers/Error/Error.js.map +1 -1
- package/lib/cjs/containers/Info/Info.js +11 -10
- package/lib/cjs/containers/Info/Info.js.map +1 -1
- package/lib/cjs/containers/Messages/Message.js +23 -10
- package/lib/cjs/containers/Messages/Message.js.map +1 -1
- package/lib/cjs/containers/Messages/MessageExample.js +25 -13
- package/lib/cjs/containers/Messages/MessageExample.js.map +1 -1
- package/lib/cjs/containers/Messages/Messages.js +14 -9
- package/lib/cjs/containers/Messages/Messages.js.map +1 -1
- package/lib/cjs/containers/Operations/Operation.js +88 -38
- package/lib/cjs/containers/Operations/Operation.js.map +1 -1
- package/lib/cjs/containers/Operations/Operations.js +20 -13
- package/lib/cjs/containers/Operations/Operations.js.map +1 -1
- package/lib/cjs/containers/Schemas/Schema.js +21 -0
- package/lib/cjs/containers/Schemas/Schema.js.map +1 -0
- package/lib/cjs/containers/Schemas/Schemas.js +29 -0
- package/lib/cjs/containers/Schemas/Schemas.js.map +1 -0
- package/lib/cjs/containers/Servers/Security.js +150 -0
- package/lib/cjs/containers/Servers/Security.js.map +1 -0
- package/lib/cjs/containers/Servers/Server.js +15 -8
- package/lib/cjs/containers/Servers/Server.js.map +1 -1
- package/lib/cjs/containers/Servers/Servers.js +12 -7
- package/lib/cjs/containers/Servers/Servers.js.map +1 -1
- package/lib/cjs/containers/Sidebar/Sidebar.js +201 -141
- package/lib/cjs/containers/Sidebar/Sidebar.js.map +1 -1
- package/lib/cjs/contexts/index.js +6 -1
- package/lib/cjs/contexts/index.js.map +1 -1
- package/lib/cjs/contexts/useConfig.js +10 -0
- package/lib/cjs/contexts/useConfig.js.map +1 -0
- package/lib/cjs/contexts/useSpec.js +7 -3
- package/lib/cjs/contexts/useSpec.js.map +1 -1
- package/lib/cjs/helpers/bindingsHelpers.js +24 -0
- package/lib/cjs/helpers/bindingsHelpers.js.map +1 -0
- package/lib/cjs/helpers/common.js +17 -0
- package/lib/cjs/helpers/common.js.map +1 -0
- package/lib/cjs/helpers/index.js +6 -3
- package/lib/cjs/helpers/index.js.map +1 -1
- package/lib/cjs/helpers/marked.js +2 -2
- package/lib/cjs/helpers/marked.js.map +1 -1
- package/lib/cjs/helpers/message.js +39 -9
- package/lib/cjs/helpers/message.js.map +1 -1
- package/lib/cjs/helpers/parser.js +16 -15
- package/lib/cjs/helpers/parser.js.map +1 -1
- package/lib/cjs/helpers/schema.js +100 -73
- package/lib/cjs/helpers/schema.js.map +1 -1
- package/lib/cjs/helpers/server.js +49 -0
- package/lib/cjs/helpers/server.js.map +1 -1
- package/lib/cjs/helpers/specification.js +36 -21
- package/lib/cjs/helpers/specification.js.map +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/types.js +4 -51
- package/lib/cjs/types.js.map +1 -1
- package/lib/cjs/without-parser.js.map +1 -1
- package/lib/esm/components/Bindings.js +12 -4
- package/lib/esm/components/Bindings.js.map +1 -1
- package/lib/esm/components/CollapseButton.js +9 -6
- package/lib/esm/components/CollapseButton.js.map +1 -1
- package/lib/esm/components/Extensions.js +2 -2
- package/lib/esm/components/Extensions.js.map +1 -1
- package/lib/esm/components/Href.js.map +1 -1
- package/lib/esm/components/JSONSnippet.js.map +1 -1
- package/lib/esm/components/Markdown.js +1 -1
- package/lib/esm/components/Markdown.js.map +1 -1
- package/lib/esm/components/Schema.js +68 -58
- package/lib/esm/components/Schema.js.map +1 -1
- package/lib/esm/components/Tag.js +1 -1
- package/lib/esm/components/Tag.js.map +1 -1
- package/lib/esm/components/Tags.js +1 -1
- package/lib/esm/components/Tags.js.map +1 -1
- package/lib/esm/components/index.js.map +1 -1
- package/lib/esm/config/config.js.map +1 -1
- package/lib/esm/config/default.js +9 -1
- package/lib/esm/config/default.js.map +1 -1
- package/lib/esm/config/index.js.map +1 -1
- package/lib/esm/constants.js +10 -47
- package/lib/esm/constants.js.map +1 -1
- package/lib/esm/containers/AsyncApi/AsyncApi.js +22 -10
- package/lib/esm/containers/AsyncApi/AsyncApi.js.map +1 -1
- package/lib/esm/containers/AsyncApi/Layout.js +28 -20
- package/lib/esm/containers/AsyncApi/Layout.js.map +1 -1
- package/lib/esm/containers/AsyncApi/Standalone.js +3 -1
- package/lib/esm/containers/AsyncApi/Standalone.js.map +1 -1
- package/lib/esm/containers/Error/Error.js +2 -2
- package/lib/esm/containers/Error/Error.js.map +1 -1
- package/lib/esm/containers/Info/Info.js +8 -8
- package/lib/esm/containers/Info/Info.js.map +1 -1
- package/lib/esm/containers/Messages/Message.js +21 -9
- package/lib/esm/containers/Messages/Message.js.map +1 -1
- package/lib/esm/containers/Messages/MessageExample.js +17 -11
- package/lib/esm/containers/Messages/MessageExample.js.map +1 -1
- package/lib/esm/containers/Messages/Messages.js +13 -9
- package/lib/esm/containers/Messages/Messages.js.map +1 -1
- package/lib/esm/containers/Operations/Operation.js +87 -39
- package/lib/esm/containers/Operations/Operation.js.map +1 -1
- package/lib/esm/containers/Operations/Operations.js +19 -13
- package/lib/esm/containers/Operations/Operations.js.map +1 -1
- package/lib/esm/containers/Schemas/Schema.js +14 -0
- package/lib/esm/containers/Schemas/Schema.js.map +1 -0
- package/lib/esm/containers/Schemas/Schemas.js +22 -0
- package/lib/esm/containers/Schemas/Schemas.js.map +1 -0
- package/lib/esm/containers/Servers/Security.js +143 -0
- package/lib/esm/containers/Servers/Security.js.map +1 -0
- package/lib/esm/containers/Servers/Server.js +15 -9
- package/lib/esm/containers/Servers/Server.js.map +1 -1
- package/lib/esm/containers/Servers/Servers.js +11 -7
- package/lib/esm/containers/Servers/Servers.js.map +1 -1
- package/lib/esm/containers/Sidebar/Sidebar.js +191 -136
- package/lib/esm/containers/Sidebar/Sidebar.js.map +1 -1
- package/lib/esm/contexts/index.js +1 -0
- package/lib/esm/contexts/index.js.map +1 -1
- package/lib/esm/contexts/useConfig.js +6 -0
- package/lib/esm/contexts/useConfig.js.map +1 -0
- package/lib/esm/contexts/useSpec.js +2 -2
- package/lib/esm/contexts/useSpec.js.map +1 -1
- package/lib/esm/helpers/bindingsHelpers.js +21 -0
- package/lib/esm/helpers/bindingsHelpers.js.map +1 -0
- package/lib/esm/helpers/common.js +14 -0
- package/lib/esm/helpers/common.js.map +1 -0
- package/lib/esm/helpers/index.js +1 -2
- package/lib/esm/helpers/index.js.map +1 -1
- package/lib/esm/helpers/marked.js +1 -1
- package/lib/esm/helpers/marked.js.map +1 -1
- package/lib/esm/helpers/message.js +38 -8
- package/lib/esm/helpers/message.js.map +1 -1
- package/lib/esm/helpers/parser.js +17 -13
- package/lib/esm/helpers/parser.js.map +1 -1
- package/lib/esm/helpers/schema.js +97 -67
- package/lib/esm/helpers/schema.js.map +1 -1
- package/lib/esm/helpers/server.js +49 -0
- package/lib/esm/helpers/server.js.map +1 -1
- package/lib/esm/helpers/specification.js +36 -18
- package/lib/esm/helpers/specification.js.map +1 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/types.js +2 -46
- package/lib/esm/types.js.map +1 -1
- package/lib/esm/without-parser.js.map +1 -1
- package/lib/types/components/Bindings.d.ts +2 -1
- package/lib/types/components/Bindings.d.ts.map +1 -1
- package/lib/types/components/CollapseButton.d.ts +1 -0
- package/lib/types/components/CollapseButton.d.ts.map +1 -1
- package/lib/types/components/Extensions.d.ts.map +1 -1
- package/lib/types/components/Schema.d.ts +5 -4
- package/lib/types/components/Schema.d.ts.map +1 -1
- package/lib/types/components/Tag.d.ts +2 -2
- package/lib/types/components/Tag.d.ts.map +1 -1
- package/lib/types/components/Tags.d.ts +2 -2
- package/lib/types/components/Tags.d.ts.map +1 -1
- package/lib/types/config/config.d.ts +8 -0
- package/lib/types/config/config.d.ts.map +1 -1
- package/lib/types/config/default.d.ts.map +1 -1
- package/lib/types/constants.d.ts +10 -26
- package/lib/types/constants.d.ts.map +1 -1
- package/lib/types/containers/AsyncApi/AsyncApi.d.ts +2 -2
- package/lib/types/containers/AsyncApi/AsyncApi.d.ts.map +1 -1
- package/lib/types/containers/AsyncApi/Layout.d.ts +2 -2
- package/lib/types/containers/AsyncApi/Layout.d.ts.map +1 -1
- package/lib/types/containers/AsyncApi/Standalone.d.ts +2 -2
- package/lib/types/containers/AsyncApi/Standalone.d.ts.map +1 -1
- package/lib/types/containers/Info/Info.d.ts.map +1 -1
- package/lib/types/containers/Messages/Message.d.ts +3 -2
- package/lib/types/containers/Messages/Message.d.ts.map +1 -1
- package/lib/types/containers/Messages/MessageExample.d.ts +5 -4
- package/lib/types/containers/Messages/MessageExample.d.ts.map +1 -1
- package/lib/types/containers/Messages/Messages.d.ts.map +1 -1
- package/lib/types/containers/Operations/Operation.d.ts +4 -3
- package/lib/types/containers/Operations/Operation.d.ts.map +1 -1
- package/lib/types/containers/Operations/Operations.d.ts.map +1 -1
- package/lib/types/containers/Schemas/Schema.d.ts +9 -0
- package/lib/types/containers/Schemas/Schema.d.ts.map +1 -0
- package/lib/types/containers/Schemas/Schemas.d.ts +3 -0
- package/lib/types/containers/Schemas/Schemas.d.ts.map +1 -0
- package/lib/types/containers/Servers/Security.d.ts +10 -0
- package/lib/types/containers/Servers/Security.d.ts.map +1 -0
- package/lib/types/containers/Servers/Server.d.ts +2 -2
- package/lib/types/containers/Servers/Server.d.ts.map +1 -1
- package/lib/types/containers/Servers/Servers.d.ts.map +1 -1
- package/lib/types/containers/Sidebar/Sidebar.d.ts +1 -9
- package/lib/types/containers/Sidebar/Sidebar.d.ts.map +1 -1
- package/lib/types/contexts/index.d.ts +1 -0
- package/lib/types/contexts/index.d.ts.map +1 -1
- package/lib/types/contexts/useConfig.d.ts +5 -0
- package/lib/types/contexts/useConfig.d.ts.map +1 -0
- package/lib/types/contexts/useSpec.d.ts +3 -5
- package/lib/types/contexts/useSpec.d.ts.map +1 -1
- package/lib/types/helpers/bindingsHelpers.d.ts +8 -0
- package/lib/types/helpers/bindingsHelpers.d.ts.map +1 -0
- package/lib/types/helpers/common.d.ts +5 -0
- package/lib/types/helpers/common.d.ts.map +1 -0
- package/lib/types/helpers/index.d.ts +1 -2
- package/lib/types/helpers/index.d.ts.map +1 -1
- package/lib/types/helpers/message.d.ts +4 -3
- package/lib/types/helpers/message.d.ts.map +1 -1
- package/lib/types/helpers/parser.d.ts.map +1 -1
- package/lib/types/helpers/schema.d.ts +10 -10
- package/lib/types/helpers/schema.d.ts.map +1 -1
- package/lib/types/helpers/server.d.ts +6 -1
- package/lib/types/helpers/server.d.ts.map +1 -1
- package/lib/types/helpers/specification.d.ts +7 -4
- package/lib/types/helpers/specification.d.ts.map +1 -1
- package/lib/types/types.d.ts +12 -305
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +29 -16
- package/styles/default.css +752 -658
- package/styles/default.min.css +3 -3
- package/lib/cjs/containers/Servers/ServerSecurity.js +0 -101
- package/lib/cjs/containers/Servers/ServerSecurity.js.map +0 -1
- package/lib/cjs/helpers/bemClasses.js +0 -49
- package/lib/cjs/helpers/bemClasses.js.map +0 -1
- package/lib/cjs/helpers/toKebabCase.js +0 -15
- package/lib/cjs/helpers/toKebabCase.js.map +0 -1
- package/lib/esm/containers/Servers/ServerSecurity.js +0 -95
- package/lib/esm/containers/Servers/ServerSecurity.js.map +0 -1
- package/lib/esm/helpers/bemClasses.js +0 -46
- package/lib/esm/helpers/bemClasses.js.map +0 -1
- package/lib/esm/helpers/toKebabCase.js +0 -11
- package/lib/esm/helpers/toKebabCase.js.map +0 -1
- package/lib/types/containers/Servers/ServerSecurity.d.ts +0 -8
- package/lib/types/containers/Servers/ServerSecurity.d.ts.map +0 -1
- package/lib/types/helpers/bemClasses.d.ts +0 -14
- package/lib/types/helpers/bemClasses.d.ts.map +0 -1
- package/lib/types/helpers/toKebabCase.d.ts +0 -2
- package/lib/types/helpers/toKebabCase.d.ts.map +0 -1
package/lib/cjs/helpers/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -10,9 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./common"), exports);
|
|
14
18
|
__exportStar(require("./marked"), exports);
|
|
15
|
-
__exportStar(require("./toKebabCase"), exports);
|
|
16
19
|
__exportStar(require("./parser"), exports);
|
|
17
20
|
__exportStar(require("./specification"), exports);
|
|
18
21
|
__exportStar(require("./server"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB;AACzB,kDAAgC;AAChC,2CAAyB;AACzB,4CAA0B;AAC1B,2CAAyB","sourcesContent":["export * from './common';\nexport * from './marked';\nexport * from './parser';\nexport * from './specification';\nexport * from './server';\nexport * from './message';\nexport * from './schema';\n"]}
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.hljs = exports.renderMarkdown = void 0;
|
|
7
|
-
var marked_1 =
|
|
7
|
+
var marked_1 = require("marked");
|
|
8
8
|
var core_1 = __importDefault(require("highlight.js/lib/core"));
|
|
9
9
|
exports.hljs = core_1.default;
|
|
10
10
|
var json_1 = __importDefault(require("highlight.js/lib/languages/json"));
|
|
@@ -28,7 +28,7 @@ var markedOptions = {
|
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
function renderMarkdown(content) {
|
|
31
|
-
return marked_1.
|
|
31
|
+
return (0, marked_1.marked)(content, markedOptions);
|
|
32
32
|
}
|
|
33
33
|
exports.renderMarkdown = renderMarkdown;
|
|
34
34
|
//# sourceMappingURL=marked.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marked.js","sourceRoot":"","sources":["../../../src/helpers/marked.ts"],"names":[],"mappings":";;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"marked.js","sourceRoot":"","sources":["../../../src/helpers/marked.ts"],"names":[],"mappings":";;;;;;AAAA,iCAAgC;AAGhC,+DAAyC;AAgChC,eAhCF,cAAI,CAgCE;AA7Bb,yEAAmD;AACnD,cAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,cAAI,CAAC,CAAC;AAGpC,yEAAmD;AACnD,cAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,cAAI,CAAC,CAAC;AAGpC,yEAAmD;AACnD,cAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,cAAI,CAAC,CAAC;AAEpC,IAAM,aAAa,GAAyB;IAC1C,UAAU,EAAE,gBAAgB;IAC5B,SAAS,EAAE,UAAC,IAAI,EAAE,QAAQ;QACxB,IAAI,CAAC,cAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;YAC/B,OAAO,IAAI,CAAC;SACb;QACD,IAAI;YACF,OAAO,cAAI,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,UAAA,EAAE,CAAC,CAAC,KAAK,CAAC;SACjD;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,IAAI,CAAC;SACb;IACH,CAAC;CACF,CAAC;AAEF,SAAgB,cAAc,CAAC,OAAe;IAC5C,OAAO,IAAA,eAAM,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;AACxC,CAAC;AAFD,wCAEC","sourcesContent":["import { marked } from 'marked';\n\n// @ts-ignore\nimport hljs from 'highlight.js/lib/core';\n\n// @ts-ignore\nimport json from 'highlight.js/lib/languages/json';\nhljs.registerLanguage('json', json);\n\n// @ts-ignore\nimport yaml from 'highlight.js/lib/languages/yaml';\nhljs.registerLanguage('yaml', yaml);\n\n// @ts-ignore\nimport bash from 'highlight.js/lib/languages/bash';\nhljs.registerLanguage('bash', bash);\n\nconst markedOptions: marked.MarkedOptions = {\n langPrefix: 'hljs language-',\n highlight: (code, language) => {\n if (!hljs.getLanguage(language)) {\n return code;\n }\n try {\n return hljs.highlight(code, { language }).value;\n } catch (e) {\n return code;\n }\n },\n};\n\nexport function renderMarkdown(content: string): string {\n return marked(content, markedOptions);\n}\n\nexport { hljs };\n"]}
|
|
@@ -8,7 +8,7 @@ var MessageHelpers = (function () {
|
|
|
8
8
|
MessageHelpers.generateExample = function (schema, options) {
|
|
9
9
|
if (options === void 0) { options = {}; }
|
|
10
10
|
try {
|
|
11
|
-
return this.sanitizeExample(openapi_sampler_1.sample(schema, options)) || '';
|
|
11
|
+
return this.sanitizeExample((0, openapi_sampler_1.sample)(schema, options)) || '';
|
|
12
12
|
}
|
|
13
13
|
catch (e) {
|
|
14
14
|
return '';
|
|
@@ -29,24 +29,54 @@ var MessageHelpers = (function () {
|
|
|
29
29
|
return schema;
|
|
30
30
|
};
|
|
31
31
|
MessageHelpers.getPayloadExamples = function (msg) {
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
var _a;
|
|
33
|
+
var examples = msg.examples().all();
|
|
34
|
+
if (examples.some(function (e) { return e.hasPayload(); })) {
|
|
35
|
+
var messageExamples = examples
|
|
36
|
+
.flatMap(function (e) {
|
|
37
|
+
if (!e.payload()) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
name: e.name(),
|
|
42
|
+
summary: e.summary(),
|
|
43
|
+
example: e.payload(),
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
.filter(Boolean);
|
|
47
|
+
if (messageExamples.length > 0) {
|
|
48
|
+
return messageExamples;
|
|
49
|
+
}
|
|
35
50
|
}
|
|
36
51
|
var payload = msg.payload();
|
|
37
52
|
if (payload && payload.examples()) {
|
|
38
|
-
return payload.examples();
|
|
53
|
+
return (_a = payload.examples()) === null || _a === void 0 ? void 0 : _a.map(function (example) { return ({ example: example }); });
|
|
39
54
|
}
|
|
40
55
|
return;
|
|
41
56
|
};
|
|
42
57
|
MessageHelpers.getHeadersExamples = function (msg) {
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
58
|
+
var _a;
|
|
59
|
+
var examples = msg.examples().all();
|
|
60
|
+
if (examples.some(function (e) { return e.hasHeaders(); })) {
|
|
61
|
+
var messageExamples = examples
|
|
62
|
+
.flatMap(function (e) {
|
|
63
|
+
if (!e.hasHeaders()) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
name: e.name(),
|
|
68
|
+
summary: e.summary(),
|
|
69
|
+
example: e.headers(),
|
|
70
|
+
};
|
|
71
|
+
})
|
|
72
|
+
.filter(Boolean);
|
|
73
|
+
if (messageExamples.length > 0) {
|
|
74
|
+
return messageExamples;
|
|
75
|
+
}
|
|
46
76
|
}
|
|
47
77
|
var headers = msg.headers();
|
|
48
78
|
if (headers && headers.examples()) {
|
|
49
|
-
return headers.examples();
|
|
79
|
+
return (_a = headers.examples()) === null || _a === void 0 ? void 0 : _a.map(function (example) { return ({ example: example }); });
|
|
50
80
|
}
|
|
51
81
|
return;
|
|
52
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/helpers/message.ts"],"names":[],"mappings":";;;AAEA,mDAAyC;
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/helpers/message.ts"],"names":[],"mappings":"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","sourcesContent":["import { MessageInterface } from '@asyncapi/parser';\n// @ts-ignore\nimport { sample } from 'openapi-sampler';\n\nimport { MessageExample } from '../types';\n\nexport class MessageHelpers {\n static generateExample(schema: any, options: any = {}) {\n try {\n return this.sanitizeExample(sample(schema, options)) || '';\n } catch (e) {\n return '';\n }\n }\n\n static sanitizeExample(schema: any): any {\n if (typeof schema === 'object' && schema && !Array.isArray(schema)) {\n return Object.entries(schema).reduce((obj, [propertyName, property]) => {\n if (\n !propertyName.startsWith('x-parser-') &&\n !propertyName.startsWith('x-schema-private-')\n ) {\n obj[propertyName] = this.sanitizeExample(property);\n }\n return obj;\n }, {});\n }\n return schema;\n }\n\n static getPayloadExamples(\n msg: MessageInterface,\n ): MessageExample[] | undefined {\n const examples = msg.examples().all();\n\n if (examples.some(e => e.hasPayload())) {\n const messageExamples = examples\n .flatMap(e => {\n if (!e.payload()) {\n return;\n }\n return {\n name: e.name(),\n summary: e.summary(),\n example: e.payload(),\n };\n })\n .filter(Boolean) as MessageExample[];\n\n if (messageExamples.length > 0) {\n return messageExamples;\n }\n }\n\n const payload = msg.payload();\n if (payload && payload.examples()) {\n return payload.examples()?.map(example => ({ example }));\n }\n\n return;\n }\n\n static getHeadersExamples(\n msg: MessageInterface,\n ): MessageExample[] | undefined {\n const examples = msg.examples().all();\n if (examples.some(e => e.hasHeaders())) {\n const messageExamples = examples\n .flatMap(e => {\n if (!e.hasHeaders()) {\n return;\n }\n return {\n name: e.name(),\n summary: e.summary(),\n example: e.headers(),\n };\n })\n .filter(Boolean) as MessageExample[];\n\n if (messageExamples.length > 0) {\n return messageExamples;\n }\n }\n\n const headers = msg.headers();\n if (headers && headers.examples()) {\n return headers.examples()?.map(example => ({ example }));\n }\n\n return;\n }\n}\n"]}
|
|
@@ -35,31 +35,31 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
39
|
exports.Parser = void 0;
|
|
43
40
|
var parser_1 = require("@asyncapi/parser");
|
|
44
|
-
var openapi_schema_parser_1 =
|
|
45
|
-
var
|
|
41
|
+
var openapi_schema_parser_1 = require("@asyncapi/openapi-schema-parser");
|
|
42
|
+
var protobuf_schema_parser_1 = require("@asyncapi/protobuf-schema-parser");
|
|
43
|
+
var avro_schema_parser_1 = require("@asyncapi/avro-schema-parser");
|
|
46
44
|
var constants_1 = require("../constants");
|
|
47
|
-
parser_1.
|
|
48
|
-
|
|
45
|
+
var asyncapiParser = new parser_1.Parser();
|
|
46
|
+
asyncapiParser.registerSchemaParser((0, openapi_schema_parser_1.OpenAPISchemaParser)());
|
|
47
|
+
asyncapiParser.registerSchemaParser((0, avro_schema_parser_1.AvroSchemaParser)());
|
|
48
|
+
asyncapiParser.registerSchemaParser((0, protobuf_schema_parser_1.ProtoBuffSchemaParser)());
|
|
49
49
|
var Parser = (function () {
|
|
50
50
|
function Parser() {
|
|
51
51
|
}
|
|
52
52
|
Parser.parse = function (content, parserOptions) {
|
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
|
-
var
|
|
54
|
+
var document_1, err_1;
|
|
55
55
|
return __generator(this, function (_a) {
|
|
56
56
|
switch (_a.label) {
|
|
57
57
|
case 0:
|
|
58
58
|
_a.trys.push([0, 2, , 3]);
|
|
59
|
-
return [4,
|
|
59
|
+
return [4, asyncapiParser.parse(content, parserOptions)];
|
|
60
60
|
case 1:
|
|
61
|
-
|
|
62
|
-
return [2, { asyncapi:
|
|
61
|
+
document_1 = (_a.sent()).document;
|
|
62
|
+
return [2, { asyncapi: document_1 }];
|
|
63
63
|
case 2:
|
|
64
64
|
err_1 = _a.sent();
|
|
65
65
|
return [2, this.handleError(err_1)];
|
|
@@ -70,15 +70,16 @@ var Parser = (function () {
|
|
|
70
70
|
};
|
|
71
71
|
Parser.parseFromUrl = function (arg, parserOptions) {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
-
var
|
|
73
|
+
var fromResult, document_2, err_2;
|
|
74
74
|
return __generator(this, function (_a) {
|
|
75
75
|
switch (_a.label) {
|
|
76
76
|
case 0:
|
|
77
77
|
_a.trys.push([0, 2, , 3]);
|
|
78
|
-
|
|
78
|
+
fromResult = (0, parser_1.fromURL)(asyncapiParser, arg.url, arg.requestOptions);
|
|
79
|
+
return [4, fromResult.parse(parserOptions)];
|
|
79
80
|
case 1:
|
|
80
|
-
|
|
81
|
-
return [2, { asyncapi:
|
|
81
|
+
document_2 = (_a.sent()).document;
|
|
82
|
+
return [2, { asyncapi: document_2 }];
|
|
82
83
|
case 2:
|
|
83
84
|
err_2 = _a.sent();
|
|
84
85
|
return [2, this.handleError(err_2)];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/helpers/parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/helpers/parser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAqE;AACrE,yEAAsE;AACtE,2EAAyE;AACzE,mEAAgE;AAIhE,0CAAsD;AAEtD,IAAM,cAAc,GAAG,IAAI,eAAc,EAAE,CAAC;AAC5C,cAAc,CAAC,oBAAoB,CAAC,IAAA,2CAAmB,GAAE,CAAC,CAAC;AAC3D,cAAc,CAAC,oBAAoB,CAAC,IAAA,qCAAgB,GAAE,CAAC,CAAC;AACxD,cAAc,CAAC,oBAAoB,CAAC,IAAA,8CAAqB,GAAE,CAAC,CAAC;AAE7D;IAAA;IAsCA,CAAC;IArCc,YAAK,GAAlB,UACE,OAAqB,EACrB,aAAmB;;;;;;;wBAGI,WAAM,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,aAAa,CAAC,EAAA;;wBAA/D,aAAa,CAAA,SAAkD,CAAA,SAAvD;wBAChB,WAAO,EAAE,QAAQ,EAAE,UAAQ,EAAE,EAAC;;;wBAE9B,WAAO,IAAI,CAAC,WAAW,CAAC,KAAkB,CAAC,EAAC;;;;;KAE/C;IAEY,mBAAY,GAAzB,UACE,GAA4B,EAC5B,aAAmB;;;;;;;wBAGX,UAAU,GAAG,IAAA,gBAAO,EACxB,cAAc,EACd,GAAG,CAAC,GAAG,EACP,GAAG,CAAC,cAAqB,CAC1B,CAAC;wBACmB,WAAM,UAAU,CAAC,KAAK,CAAC,aAAa,CAAC,EAAA;;wBAAlD,aAAa,CAAA,SAAqC,CAAA,SAA1C;wBAChB,WAAO,EAAE,QAAQ,EAAE,UAAQ,EAAE,EAAC;;;wBAE9B,WAAO,IAAI,CAAC,WAAW,CAAC,KAAkB,CAAC,EAAC;;;;;KAE/C;IAEc,kBAAW,GAAG,UAAC,GAAgB;QAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,kCAAsB,EAAE;YACvC,OAAO;gBACL,KAAK,EAAE,GAAG;aACX,CAAC;SACH;QACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IACxB,CAAC,CAAC;IACJ,aAAC;CAAA,AAtCD,IAsCC;AAtCY,wBAAM","sourcesContent":["import { Parser as AsyncapiParser, fromURL } from '@asyncapi/parser';\nimport { OpenAPISchemaParser } from '@asyncapi/openapi-schema-parser';\nimport { ProtoBuffSchemaParser } from '@asyncapi/protobuf-schema-parser';\nimport { AvroSchemaParser } from '@asyncapi/avro-schema-parser';\n\nimport { ErrorObject, ParserReturn, FetchingSchemaInterface } from '../types';\n\nimport { VALIDATION_ERRORS_TYPE } from '../constants';\n\nconst asyncapiParser = new AsyncapiParser();\nasyncapiParser.registerSchemaParser(OpenAPISchemaParser());\nasyncapiParser.registerSchemaParser(AvroSchemaParser());\nasyncapiParser.registerSchemaParser(ProtoBuffSchemaParser());\n\nexport class Parser {\n static async parse(\n content: string | any,\n parserOptions?: any,\n ): Promise<ParserReturn> {\n try {\n const { document } = await asyncapiParser.parse(content, parserOptions);\n return { asyncapi: document };\n } catch (err) {\n return this.handleError(err as ErrorObject);\n }\n }\n\n static async parseFromUrl(\n arg: FetchingSchemaInterface,\n parserOptions?: any,\n ): Promise<ParserReturn> {\n try {\n const fromResult = fromURL(\n asyncapiParser,\n arg.url,\n arg.requestOptions as any,\n );\n const { document } = await fromResult.parse(parserOptions);\n return { asyncapi: document };\n } catch (err) {\n return this.handleError(err as ErrorObject);\n }\n }\n\n private static handleError = (err: ErrorObject): ParserReturn => {\n if (err.type === VALIDATION_ERRORS_TYPE) {\n return {\n error: err,\n };\n }\n return { error: err };\n };\n}\n"]}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
4
12
|
};
|
|
5
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
14
|
exports.SchemaHelpers = exports.SchemaCustomTypes = void 0;
|
|
7
|
-
var
|
|
15
|
+
var parser_1 = require("@asyncapi/parser");
|
|
8
16
|
var SchemaCustomTypes;
|
|
9
17
|
(function (SchemaCustomTypes) {
|
|
10
18
|
SchemaCustomTypes["ANY"] = "any";
|
|
@@ -78,23 +86,24 @@ var SchemaHelpers = (function () {
|
|
|
78
86
|
type = this.toType(type, schema);
|
|
79
87
|
var combinedType = this.toCombinedType(schema);
|
|
80
88
|
if (type && combinedType) {
|
|
81
|
-
return type
|
|
89
|
+
return "".concat(type, " ").concat(combinedType);
|
|
82
90
|
}
|
|
83
91
|
if (combinedType) {
|
|
84
92
|
return combinedType;
|
|
85
93
|
}
|
|
86
94
|
return type;
|
|
87
95
|
};
|
|
88
|
-
SchemaHelpers.prettifyValue = function (value) {
|
|
96
|
+
SchemaHelpers.prettifyValue = function (value, strict) {
|
|
97
|
+
if (strict === void 0) { strict = true; }
|
|
89
98
|
var typeOf = typeof value;
|
|
90
99
|
if (typeOf === 'string') {
|
|
91
|
-
return "\""
|
|
100
|
+
return strict ? "\"".concat(value, "\"") : value;
|
|
92
101
|
}
|
|
93
102
|
if (typeOf === 'number' || typeOf === 'bigint' || typeOf === 'boolean') {
|
|
94
|
-
return value;
|
|
103
|
+
return "".concat(value);
|
|
95
104
|
}
|
|
96
105
|
if (Array.isArray(value)) {
|
|
97
|
-
return "["
|
|
106
|
+
return "[".concat(value.toString(), "]");
|
|
98
107
|
}
|
|
99
108
|
return JSON.stringify(value);
|
|
100
109
|
};
|
|
@@ -132,6 +141,8 @@ var SchemaHelpers = (function () {
|
|
|
132
141
|
if (schema.oneOf() ||
|
|
133
142
|
schema.anyOf() ||
|
|
134
143
|
schema.allOf() ||
|
|
144
|
+
Object.keys(schema.properties() || {}).length > 0 ||
|
|
145
|
+
schema.items() ||
|
|
135
146
|
schema.not() ||
|
|
136
147
|
schema.if() ||
|
|
137
148
|
schema.then() ||
|
|
@@ -146,63 +157,69 @@ var SchemaHelpers = (function () {
|
|
|
146
157
|
};
|
|
147
158
|
SchemaHelpers.serverVariablesToSchema = function (urlVariables) {
|
|
148
159
|
var _a;
|
|
149
|
-
if (!urlVariables ||
|
|
160
|
+
if (!urlVariables || urlVariables.length === 0) {
|
|
150
161
|
return undefined;
|
|
151
162
|
}
|
|
163
|
+
var obj = {};
|
|
164
|
+
urlVariables.all().forEach(function (variable) {
|
|
165
|
+
obj[variable.id()] = __assign({}, (variable.json() || {}));
|
|
166
|
+
obj[variable.id()].type = 'string';
|
|
167
|
+
});
|
|
152
168
|
var json = (_a = {
|
|
153
169
|
type: 'object',
|
|
154
|
-
properties:
|
|
155
|
-
|
|
156
|
-
obj[urlName] = Object.assign({}, url.json());
|
|
157
|
-
obj[urlName].type = 'string';
|
|
158
|
-
return obj;
|
|
159
|
-
}, {}),
|
|
160
|
-
required: Object.keys(urlVariables)
|
|
170
|
+
properties: obj,
|
|
171
|
+
required: Object.keys(obj)
|
|
161
172
|
},
|
|
162
|
-
_a[this.extRenderType] = false,
|
|
163
173
|
_a[this.extRenderAdditionalInfo] = false,
|
|
164
174
|
_a);
|
|
165
|
-
return new
|
|
175
|
+
return new parser_1.SchemaV2(json);
|
|
166
176
|
};
|
|
167
177
|
SchemaHelpers.parametersToSchema = function (parameters) {
|
|
168
178
|
var _a;
|
|
169
179
|
var _this = this;
|
|
170
|
-
if (!parameters ||
|
|
180
|
+
if (!parameters || parameters.isEmpty()) {
|
|
171
181
|
return undefined;
|
|
172
182
|
}
|
|
183
|
+
var obj = {};
|
|
184
|
+
parameters.all().forEach(function (parameter) {
|
|
185
|
+
var _a;
|
|
186
|
+
var parameterSchema = parameter.schema();
|
|
187
|
+
obj[parameter.id()] = __assign({}, ((_a = parameterSchema === null || parameterSchema === void 0 ? void 0 : parameterSchema.json()) !== null && _a !== void 0 ? _a : {}));
|
|
188
|
+
obj[parameter.id()].description = parameter.hasDescription()
|
|
189
|
+
? parameter.description()
|
|
190
|
+
: undefined;
|
|
191
|
+
obj[parameter.id()][_this.extParameterLocation] = parameter.hasLocation()
|
|
192
|
+
? parameter.location()
|
|
193
|
+
: undefined;
|
|
194
|
+
});
|
|
173
195
|
var json = (_a = {
|
|
174
196
|
type: 'object',
|
|
175
|
-
properties:
|
|
176
|
-
|
|
177
|
-
obj[paramaterName] = Object.assign({}, parameter.schema().json());
|
|
178
|
-
obj[paramaterName].description =
|
|
179
|
-
parameter.description() || obj[paramaterName].description;
|
|
180
|
-
obj[paramaterName][_this.extParameterLocation] = parameter.location();
|
|
181
|
-
return obj;
|
|
182
|
-
}, {}),
|
|
183
|
-
required: Object.keys(parameters)
|
|
197
|
+
properties: obj,
|
|
198
|
+
required: Object.keys(obj)
|
|
184
199
|
},
|
|
185
|
-
_a[this.extRenderType] = false,
|
|
186
200
|
_a[this.extRenderAdditionalInfo] = false,
|
|
187
201
|
_a);
|
|
188
|
-
return new
|
|
202
|
+
return new parser_1.SchemaV2(json);
|
|
189
203
|
};
|
|
190
204
|
SchemaHelpers.jsonToSchema = function (value) {
|
|
191
205
|
var json = this.jsonFieldToSchema(value);
|
|
192
|
-
return new
|
|
206
|
+
return new parser_1.SchemaV2(json);
|
|
193
207
|
};
|
|
194
208
|
SchemaHelpers.getCustomExtensions = function (value) {
|
|
195
209
|
if (!value || typeof value.extensions !== 'function') {
|
|
196
210
|
return;
|
|
197
211
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
212
|
+
var extensions = value.extensions();
|
|
213
|
+
var filteredExtensions = {};
|
|
214
|
+
for (var _i = 0, _a = extensions.all(); _i < _a.length; _i++) {
|
|
215
|
+
var ext = _a[_i];
|
|
216
|
+
var extType = ext;
|
|
217
|
+
if (!extType.id().startsWith('x-parser-') &&
|
|
218
|
+
!extType.id().startsWith('x-schema-private-')) {
|
|
219
|
+
filteredExtensions[extType.id()] = extType.value();
|
|
203
220
|
}
|
|
204
|
-
|
|
205
|
-
|
|
221
|
+
}
|
|
222
|
+
return filteredExtensions;
|
|
206
223
|
};
|
|
207
224
|
SchemaHelpers.getDependentRequired = function (propertyName, schema) {
|
|
208
225
|
var dependentRequired = [];
|
|
@@ -238,38 +255,43 @@ var SchemaHelpers = (function () {
|
|
|
238
255
|
type: 'object',
|
|
239
256
|
properties: Object.entries(records).reduce(function (obj, _a) {
|
|
240
257
|
var propertyName = _a[0], propertySchema = _a[1];
|
|
241
|
-
obj[propertyName] =
|
|
258
|
+
obj[propertyName] = __assign({}, (propertySchema.json() || {}));
|
|
242
259
|
return obj;
|
|
243
260
|
}, {})
|
|
244
261
|
},
|
|
245
|
-
_a[this.extRenderType] = false,
|
|
246
262
|
_a[this.extRenderAdditionalInfo] = false,
|
|
247
263
|
_a);
|
|
248
|
-
return new
|
|
264
|
+
return new parser_1.SchemaV2(json);
|
|
249
265
|
};
|
|
250
266
|
SchemaHelpers.toType = function (type, schema) {
|
|
251
|
-
|
|
267
|
+
if (schema.isCircular()) {
|
|
268
|
+
return type;
|
|
269
|
+
}
|
|
252
270
|
if (type === 'array') {
|
|
253
271
|
var items = schema.items();
|
|
254
272
|
if (Array.isArray(items)) {
|
|
255
|
-
|
|
256
|
-
var additionalItems = schema.additionalItems();
|
|
257
|
-
if (additionalItems === undefined || additionalItems.json()) {
|
|
258
|
-
var additionalType = additionalItems === undefined || additionalItems.json() === true
|
|
259
|
-
? SchemaCustomTypes.ANY
|
|
260
|
-
: this.toSchemaType(additionalItems);
|
|
261
|
-
return "tuple<" + (types ||
|
|
262
|
-
SchemaCustomTypes.UNKNOWN) + ", ...optional<" + additionalType + ">>";
|
|
263
|
-
}
|
|
264
|
-
return "tuple<" + (types || SchemaCustomTypes.UNKNOWN) + ">";
|
|
273
|
+
return this.toItemsType(items, schema);
|
|
265
274
|
}
|
|
266
275
|
if (!items) {
|
|
267
|
-
return "array<"
|
|
276
|
+
return "array<".concat(SchemaCustomTypes.ANY, ">");
|
|
268
277
|
}
|
|
269
|
-
return "array<"
|
|
278
|
+
return "array<".concat(this.toSchemaType(items) || SchemaCustomTypes.UNKNOWN, ">");
|
|
270
279
|
}
|
|
271
280
|
return type;
|
|
272
281
|
};
|
|
282
|
+
SchemaHelpers.toItemsType = function (items, schema) {
|
|
283
|
+
var _this = this;
|
|
284
|
+
var types = items.map(function (item) { return _this.toSchemaType(item); }).join(', ');
|
|
285
|
+
var additionalItems = schema.additionalItems();
|
|
286
|
+
if (additionalItems !== undefined && additionalItems !== false) {
|
|
287
|
+
var additionalType = additionalItems === true
|
|
288
|
+
? SchemaCustomTypes.ANY
|
|
289
|
+
: this.toSchemaType(additionalItems);
|
|
290
|
+
return "tuple<".concat(types ||
|
|
291
|
+
SchemaCustomTypes.UNKNOWN, ", ...optional<").concat(additionalType, ">>");
|
|
292
|
+
}
|
|
293
|
+
return "tuple<".concat(types || SchemaCustomTypes.UNKNOWN, ">");
|
|
294
|
+
};
|
|
273
295
|
SchemaHelpers.toCombinedType = function (schema) {
|
|
274
296
|
var oneOf = schema.oneOf();
|
|
275
297
|
if (oneOf) {
|
|
@@ -344,58 +366,65 @@ var SchemaHelpers = (function () {
|
|
|
344
366
|
}
|
|
345
367
|
var strigifiedMultipleOf = multipleOf.toString(10);
|
|
346
368
|
if (!/^0\.0*1$/.test(strigifiedMultipleOf)) {
|
|
347
|
-
return "multiple of "
|
|
369
|
+
return "multiple of ".concat(strigifiedMultipleOf);
|
|
348
370
|
}
|
|
349
|
-
return "decimal places <= "
|
|
371
|
+
return "decimal places <= ".concat(strigifiedMultipleOf.split('.')[1].length);
|
|
350
372
|
};
|
|
351
373
|
SchemaHelpers.humanizeRangeConstraint = function (description, min, max) {
|
|
352
374
|
var stringRange;
|
|
353
375
|
if (min !== undefined && max !== undefined) {
|
|
354
376
|
if (min === max) {
|
|
355
|
-
stringRange = min
|
|
377
|
+
stringRange = "".concat(min, " ").concat(description);
|
|
356
378
|
}
|
|
357
379
|
else {
|
|
358
|
-
stringRange = "[ "
|
|
380
|
+
stringRange = "[ ".concat(min, " .. ").concat(max, " ] ").concat(description);
|
|
359
381
|
}
|
|
360
382
|
}
|
|
361
383
|
else if (max !== undefined) {
|
|
362
|
-
stringRange = "<= "
|
|
384
|
+
stringRange = "<= ".concat(max, " ").concat(description);
|
|
363
385
|
}
|
|
364
386
|
else if (min !== undefined) {
|
|
365
387
|
if (min === 1) {
|
|
366
388
|
stringRange = 'non-empty';
|
|
367
389
|
}
|
|
368
390
|
else {
|
|
369
|
-
stringRange = ">= "
|
|
391
|
+
stringRange = ">= ".concat(min, " ").concat(description);
|
|
370
392
|
}
|
|
371
393
|
}
|
|
372
394
|
return stringRange;
|
|
373
395
|
};
|
|
374
396
|
SchemaHelpers.jsonFieldToSchema = function (value) {
|
|
375
|
-
var _a, _b, _c;
|
|
397
|
+
var _a, _b, _c, _d;
|
|
376
398
|
var _this = this;
|
|
377
|
-
if (
|
|
378
|
-
var str = typeof value.toString === 'function' ? value.toString() : value;
|
|
399
|
+
if (value === undefined || value === null) {
|
|
379
400
|
return _a = {
|
|
380
401
|
type: 'string',
|
|
381
|
-
const:
|
|
402
|
+
const: ''
|
|
382
403
|
},
|
|
383
404
|
_a[this.extRawValue] = true,
|
|
384
405
|
_a;
|
|
385
406
|
}
|
|
407
|
+
if (typeof value !== 'object') {
|
|
408
|
+
var str = typeof value.toString === 'function' ? value.toString() : value;
|
|
409
|
+
return _b = {
|
|
410
|
+
type: 'string',
|
|
411
|
+
const: str
|
|
412
|
+
},
|
|
413
|
+
_b[this.extRawValue] = true,
|
|
414
|
+
_b;
|
|
415
|
+
}
|
|
386
416
|
if (this.isJSONSchema(value)) {
|
|
387
417
|
return value;
|
|
388
418
|
}
|
|
389
419
|
if (Array.isArray(value)) {
|
|
390
|
-
return
|
|
420
|
+
return _c = {
|
|
391
421
|
type: 'array',
|
|
392
422
|
items: value.map(function (v) { return _this.jsonFieldToSchema(v); })
|
|
393
423
|
},
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
_b;
|
|
424
|
+
_c[this.extRenderAdditionalInfo] = false,
|
|
425
|
+
_c;
|
|
397
426
|
}
|
|
398
|
-
return
|
|
427
|
+
return _d = {
|
|
399
428
|
type: 'object',
|
|
400
429
|
properties: Object.entries(value).reduce(function (obj, _a) {
|
|
401
430
|
var k = _a[0], v = _a[1];
|
|
@@ -403,9 +432,8 @@ var SchemaHelpers = (function () {
|
|
|
403
432
|
return obj;
|
|
404
433
|
}, {})
|
|
405
434
|
},
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
_c;
|
|
435
|
+
_d[this.extRenderAdditionalInfo] = false,
|
|
436
|
+
_d;
|
|
409
437
|
};
|
|
410
438
|
SchemaHelpers.isJSONSchema = function (value) {
|
|
411
439
|
if (value &&
|
|
@@ -417,7 +445,6 @@ var SchemaHelpers = (function () {
|
|
|
417
445
|
}
|
|
418
446
|
return false;
|
|
419
447
|
};
|
|
420
|
-
SchemaHelpers.extRenderType = 'x-schema-private-render-type';
|
|
421
448
|
SchemaHelpers.extRenderAdditionalInfo = 'x-schema-private-render-additional-info';
|
|
422
449
|
SchemaHelpers.extRawValue = 'x-schema-private-raw-value';
|
|
423
450
|
SchemaHelpers.extParameterLocation = 'x-schema-private-parameter-location';
|