@alagoni97/cli 0.72.1
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/LICENSE +201 -0
- package/README.md +336 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.mjs +3 -0
- package/bin/run.cmd +3 -0
- package/bin/run.mjs +4 -0
- package/dist/LoggingInterface.d.ts +123 -0
- package/dist/LoggingInterface.js +300 -0
- package/dist/PersistedConfig.d.ts +46 -0
- package/dist/PersistedConfig.js +94 -0
- package/dist/browser/adapters/output.d.ts +69 -0
- package/dist/browser/adapters/output.js +91 -0
- package/dist/browser/config.d.ts +18 -0
- package/dist/browser/config.js +59 -0
- package/dist/browser/generate.d.ts +20 -0
- package/dist/browser/generate.js +129 -0
- package/dist/browser/index.d.ts +17 -0
- package/dist/browser/index.js +26 -0
- package/dist/browser/parser.d.ts +9 -0
- package/dist/browser/parser.js +61 -0
- package/dist/browser/shims/asyncapi-parser.d.ts +30 -0
- package/dist/browser/shims/asyncapi-parser.js +52 -0
- package/dist/browser/shims/fs.d.ts +190 -0
- package/dist/browser/shims/fs.js +188 -0
- package/dist/browser/shims/json-schema-ref-parser.d.ts +73 -0
- package/dist/browser/shims/json-schema-ref-parser.js +246 -0
- package/dist/browser/shims/swagger-parser.d.ts +20 -0
- package/dist/browser/shims/swagger-parser.js +40 -0
- package/dist/codegen/configurationSchemaBuilder.d.ts +15 -0
- package/dist/codegen/configurationSchemaBuilder.js +48 -0
- package/dist/codegen/configurations.d.ts +29 -0
- package/dist/codegen/configurations.js +260 -0
- package/dist/codegen/detection.d.ts +19 -0
- package/dist/codegen/detection.js +174 -0
- package/dist/codegen/errors.d.ts +111 -0
- package/dist/codegen/errors.js +352 -0
- package/dist/codegen/generators/generic/custom.d.ts +75 -0
- package/dist/codegen/generators/generic/custom.js +66 -0
- package/dist/codegen/generators/index.d.ts +14 -0
- package/dist/codegen/generators/index.js +42 -0
- package/dist/codegen/generators/typescript/channels/asyncapi.d.ts +10 -0
- package/dist/codegen/generators/typescript/channels/asyncapi.js +131 -0
- package/dist/codegen/generators/typescript/channels/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/channels/index.js +142 -0
- package/dist/codegen/generators/typescript/channels/openapi.d.ts +9 -0
- package/dist/codegen/generators/typescript/channels/openapi.js +168 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/index.js +149 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.d.ts +5 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishExchange.js +106 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/publishQueue.js +102 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/amqp/subscribeQueue.js +133 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/express.js +100 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.d.ts +5 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/fetch.js +144 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/eventsource/index.js +132 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/client.d.ts +10 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/client.js +224 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/common-types.d.ts +14 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/common-types.js +800 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/index.js +96 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/security.d.ts +48 -0
- package/dist/codegen/generators/typescript/channels/protocols/http/security.js +491 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/index.js +127 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/publish.js +108 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/subscribe.js +154 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.d.ts +11 -0
- package/dist/codegen/generators/typescript/channels/protocols/kafka/utils.js +58 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.d.ts +6 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/index.js +113 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/publish.js +99 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/mqtt/subscribe.js +186 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/corePublish.js +90 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreReply.js +142 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreRequest.js +100 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/coreSubscribe.js +143 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/index.d.ts +11 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/index.js +224 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPublish.js +89 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPullSubscribe.js +146 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/jetstreamPushSubscription.js +149 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/utils.d.ts +35 -0
- package/dist/codegen/generators/typescript/channels/protocols/nats/utils.js +120 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/index.js +152 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/publish.js +64 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/register.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/register.js +115 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.d.ts +3 -0
- package/dist/codegen/generators/typescript/channels/protocols/websocket/subscribe.js +151 -0
- package/dist/codegen/generators/typescript/channels/types.d.ts +181 -0
- package/dist/codegen/generators/typescript/channels/types.js +131 -0
- package/dist/codegen/generators/typescript/channels/utils.d.ts +64 -0
- package/dist/codegen/generators/typescript/channels/utils.js +163 -0
- package/dist/codegen/generators/typescript/client/index.d.ts +8 -0
- package/dist/codegen/generators/typescript/client/index.js +61 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/corePublish.js +53 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/coreSubscribe.js +90 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetStreamPullSubscription.js +83 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPublish.js +54 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.d.ts +6 -0
- package/dist/codegen/generators/typescript/client/protocols/nats/jetstreamPushSubscription.js +82 -0
- package/dist/codegen/generators/typescript/client/protocols/nats.d.ts +2 -0
- package/dist/codegen/generators/typescript/client/protocols/nats.js +182 -0
- package/dist/codegen/generators/typescript/client/types.d.ts +49 -0
- package/dist/codegen/generators/typescript/client/types.js +37 -0
- package/dist/codegen/generators/typescript/headers.d.ts +54 -0
- package/dist/codegen/generators/typescript/headers.js +138 -0
- package/dist/codegen/generators/typescript/index.d.ts +7 -0
- package/dist/codegen/generators/typescript/index.js +38 -0
- package/dist/codegen/generators/typescript/models.d.ts +21761 -0
- package/dist/codegen/generators/typescript/models.js +64 -0
- package/dist/codegen/generators/typescript/parameters.d.ts +37 -0
- package/dist/codegen/generators/typescript/parameters.js +101 -0
- package/dist/codegen/generators/typescript/payloads.d.ts +73 -0
- package/dist/codegen/generators/typescript/payloads.js +250 -0
- package/dist/codegen/generators/typescript/types.d.ts +34 -0
- package/dist/codegen/generators/typescript/types.js +70 -0
- package/dist/codegen/generators/typescript/utils.d.ts +38 -0
- package/dist/codegen/generators/typescript/utils.js +195 -0
- package/dist/codegen/index.d.ts +7 -0
- package/dist/codegen/index.js +38 -0
- package/dist/codegen/inputs/asyncapi/generators/headers.d.ts +3 -0
- package/dist/codegen/inputs/asyncapi/generators/headers.js +41 -0
- package/dist/codegen/inputs/asyncapi/generators/parameters.d.ts +14 -0
- package/dist/codegen/inputs/asyncapi/generators/parameters.js +120 -0
- package/dist/codegen/inputs/asyncapi/generators/payloads.d.ts +16 -0
- package/dist/codegen/inputs/asyncapi/generators/payloads.js +124 -0
- package/dist/codegen/inputs/asyncapi/generators/types.d.ts +9 -0
- package/dist/codegen/inputs/asyncapi/generators/types.js +61 -0
- package/dist/codegen/inputs/asyncapi/index.d.ts +1 -0
- package/dist/codegen/inputs/asyncapi/index.js +7 -0
- package/dist/codegen/inputs/asyncapi/parser.d.ts +4 -0
- package/dist/codegen/inputs/asyncapi/parser.js +90 -0
- package/dist/codegen/inputs/index.d.ts +3 -0
- package/dist/codegen/inputs/index.js +19 -0
- package/dist/codegen/inputs/jsonschema/generators/index.d.ts +1 -0
- package/dist/codegen/inputs/jsonschema/generators/index.js +5 -0
- package/dist/codegen/inputs/jsonschema/generators/models.d.ts +7 -0
- package/dist/codegen/inputs/jsonschema/generators/models.js +26 -0
- package/dist/codegen/inputs/jsonschema/index.d.ts +1 -0
- package/dist/codegen/inputs/jsonschema/index.js +7 -0
- package/dist/codegen/inputs/jsonschema/parser.d.ts +31 -0
- package/dist/codegen/inputs/jsonschema/parser.js +128 -0
- package/dist/codegen/inputs/openapi/generators/headers.d.ts +3 -0
- package/dist/codegen/inputs/openapi/generators/headers.js +101 -0
- package/dist/codegen/inputs/openapi/generators/parameters.d.ts +10 -0
- package/dist/codegen/inputs/openapi/generators/parameters.js +852 -0
- package/dist/codegen/inputs/openapi/generators/payloads.d.ts +3 -0
- package/dist/codegen/inputs/openapi/generators/payloads.js +231 -0
- package/dist/codegen/inputs/openapi/generators/types.d.ts +9 -0
- package/dist/codegen/inputs/openapi/generators/types.js +86 -0
- package/dist/codegen/inputs/openapi/index.d.ts +2 -0
- package/dist/codegen/inputs/openapi/index.js +8 -0
- package/dist/codegen/inputs/openapi/parser.d.ts +4 -0
- package/dist/codegen/inputs/openapi/parser.js +115 -0
- package/dist/codegen/inputs/openapi/security.d.ts +56 -0
- package/dist/codegen/inputs/openapi/security.js +193 -0
- package/dist/codegen/modelina/index.d.ts +2 -0
- package/dist/codegen/modelina/index.js +20 -0
- package/dist/codegen/modelina/presets/index.d.ts +3 -0
- package/dist/codegen/modelina/presets/index.js +14 -0
- package/dist/codegen/modelina/presets/primitives.d.ts +34 -0
- package/dist/codegen/modelina/presets/primitives.js +211 -0
- package/dist/codegen/modelina/presets/union.d.ts +33 -0
- package/dist/codegen/modelina/presets/union.js +197 -0
- package/dist/codegen/modelina/presets/validation.d.ts +66 -0
- package/dist/codegen/modelina/presets/validation.js +183 -0
- package/dist/codegen/modelina/types.d.ts +61845 -0
- package/dist/codegen/modelina/types.js +412 -0
- package/dist/codegen/output/filesystem.d.ts +30 -0
- package/dist/codegen/output/filesystem.js +61 -0
- package/dist/codegen/output/index.d.ts +16 -0
- package/dist/codegen/output/index.js +57 -0
- package/dist/codegen/output/memory.d.ts +54 -0
- package/dist/codegen/output/memory.js +81 -0
- package/dist/codegen/output/modelina.d.ts +30 -0
- package/dist/codegen/output/modelina.js +30 -0
- package/dist/codegen/output/types.d.ts +47 -0
- package/dist/codegen/output/types.js +6 -0
- package/dist/codegen/renderer.d.ts +13 -0
- package/dist/codegen/renderer.js +309 -0
- package/dist/codegen/schemaPostProcess.d.ts +25 -0
- package/dist/codegen/schemaPostProcess.js +38 -0
- package/dist/codegen/types.d.ts +285187 -0
- package/dist/codegen/types.js +177 -0
- package/dist/codegen/utils.d.ts +126 -0
- package/dist/codegen/utils.js +373 -0
- package/dist/commands/base.d.ts +18 -0
- package/dist/commands/base.js +59 -0
- package/dist/commands/generate.d.ts +46 -0
- package/dist/commands/generate.js +305 -0
- package/dist/commands/init.d.ts +55 -0
- package/dist/commands/init.js +544 -0
- package/dist/commands/telemetry.d.ts +25 -0
- package/dist/commands/telemetry.js +115 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +35 -0
- package/dist/telemetry/anonymize.d.ts +19 -0
- package/dist/telemetry/anonymize.js +73 -0
- package/dist/telemetry/collector.d.ts +26 -0
- package/dist/telemetry/collector.js +57 -0
- package/dist/telemetry/config.d.ts +32 -0
- package/dist/telemetry/config.js +97 -0
- package/dist/telemetry/events.d.ts +72 -0
- package/dist/telemetry/events.js +5 -0
- package/dist/telemetry/index.d.ts +46 -0
- package/dist/telemetry/index.js +91 -0
- package/dist/telemetry/notice.d.ts +8 -0
- package/dist/telemetry/notice.js +50 -0
- package/dist/telemetry/sender.d.ts +14 -0
- package/dist/telemetry/sender.js +125 -0
- package/dist/utils/gitignore.d.ts +66 -0
- package/dist/utils/gitignore.js +111 -0
- package/dist/utils/inputSource.d.ts +3 -0
- package/dist/utils/inputSource.js +26 -0
- package/dist/utils/refResolvers.d.ts +29 -0
- package/dist/utils/refResolvers.js +83 -0
- package/dist/utils/remoteFetch.d.ts +18 -0
- package/dist/utils/remoteFetch.js +64 -0
- package/oclif.manifest.json +510 -0
- package/package.json +155 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateAsyncAPITypes = void 0;
|
|
4
|
+
async function generateAsyncAPITypes(asyncapiDocument, generator) {
|
|
5
|
+
const allChannels = asyncapiDocument.allChannels().all();
|
|
6
|
+
const channelAddressUnion = allChannels
|
|
7
|
+
.map((channel) => {
|
|
8
|
+
return `'${channel.address()}'`;
|
|
9
|
+
})
|
|
10
|
+
.join(' | ');
|
|
11
|
+
let result = `export type Topics = ${channelAddressUnion};\n`;
|
|
12
|
+
// For version 3.x+ we generate additional topic ID types and helper functions
|
|
13
|
+
if (!asyncapiDocument.version().startsWith('2.')) {
|
|
14
|
+
const channelIdUnion = allChannels
|
|
15
|
+
.map((channel) => {
|
|
16
|
+
return `'${channel.id()}'`;
|
|
17
|
+
})
|
|
18
|
+
.join(' | ');
|
|
19
|
+
const channelIdSwitch = allChannels
|
|
20
|
+
.map((channel) => {
|
|
21
|
+
return `case '${channel.id()}':
|
|
22
|
+
return '${channel.address()}';`;
|
|
23
|
+
})
|
|
24
|
+
.join('\n ');
|
|
25
|
+
const channelAddressSwitch = allChannels
|
|
26
|
+
.map((channel) => {
|
|
27
|
+
return `case '${channel.address()}':
|
|
28
|
+
return '${channel.id()}';`;
|
|
29
|
+
})
|
|
30
|
+
.join('\n ');
|
|
31
|
+
const topicIdsPart = `export type TopicIds = ${channelIdUnion};\n`;
|
|
32
|
+
const toTopicIdsPart = `export function ToTopicIds(topic: Topics): TopicIds {
|
|
33
|
+
switch (topic) {
|
|
34
|
+
${channelAddressSwitch}
|
|
35
|
+
default:
|
|
36
|
+
throw new Error('Unknown topic: ' + topic);
|
|
37
|
+
}
|
|
38
|
+
}\n`;
|
|
39
|
+
const toTopicsPart = `export function ToTopics(topicId: TopicIds): Topics {
|
|
40
|
+
switch (topicId) {
|
|
41
|
+
${channelIdSwitch}
|
|
42
|
+
default:
|
|
43
|
+
throw new Error('Unknown topic ID: ' + topicId);
|
|
44
|
+
}
|
|
45
|
+
}\n`;
|
|
46
|
+
const topicsMap = `export const TopicsMap: Record<TopicIds, Topics> = {
|
|
47
|
+
${allChannels
|
|
48
|
+
.map((channel) => {
|
|
49
|
+
return ` '${channel.id()}': '${channel.address()}'`;
|
|
50
|
+
})
|
|
51
|
+
.join(', \n')}
|
|
52
|
+
};\n`;
|
|
53
|
+
result += topicIdsPart + toTopicIdsPart + toTopicsPart + topicsMap;
|
|
54
|
+
}
|
|
55
|
+
const filePath = `${generator.outputPath}/Types.ts`;
|
|
56
|
+
return {
|
|
57
|
+
result,
|
|
58
|
+
files: [{ path: filePath, content: result }]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.generateAsyncAPITypes = generateAsyncAPITypes;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadAsyncapi, loadAsyncapiDocument, loadAsyncapiFromMemory } from './parser';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAsyncapiFromMemory = exports.loadAsyncapiDocument = exports.loadAsyncapi = void 0;
|
|
4
|
+
var parser_1 = require("./parser");
|
|
5
|
+
Object.defineProperty(exports, "loadAsyncapi", { enumerable: true, get: function () { return parser_1.loadAsyncapi; } });
|
|
6
|
+
Object.defineProperty(exports, "loadAsyncapiDocument", { enumerable: true, get: function () { return parser_1.loadAsyncapiDocument; } });
|
|
7
|
+
Object.defineProperty(exports, "loadAsyncapiFromMemory", { enumerable: true, get: function () { return parser_1.loadAsyncapiFromMemory; } });
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InputAuthConfig, RunGeneratorContext } from '../../types';
|
|
2
|
+
export declare function loadAsyncapi(context: RunGeneratorContext): Promise<import("@asyncapi/parser").AsyncAPIDocumentInterface | undefined>;
|
|
3
|
+
export declare function loadAsyncapiDocument(documentPath: string, auth?: InputAuthConfig): Promise<import("@asyncapi/parser").AsyncAPIDocumentInterface | undefined>;
|
|
4
|
+
export declare function loadAsyncapiFromMemory(input: string): Promise<import("@asyncapi/parser").AsyncAPIDocumentInterface | undefined>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadAsyncapiFromMemory = exports.loadAsyncapiDocument = exports.loadAsyncapi = void 0;
|
|
4
|
+
const parser_1 = require("@asyncapi/parser");
|
|
5
|
+
const avro_schema_parser_1 = require("@asyncapi/avro-schema-parser");
|
|
6
|
+
const openapi_schema_parser_1 = require("@asyncapi/openapi-schema-parser");
|
|
7
|
+
const raml_dt_schema_parser_1 = require("@asyncapi/raml-dt-schema-parser");
|
|
8
|
+
const protobuf_schema_parser_1 = require("@asyncapi/protobuf-schema-parser");
|
|
9
|
+
const fs_1 = require("fs");
|
|
10
|
+
const LoggingInterface_1 = require("../../../LoggingInterface");
|
|
11
|
+
const errors_1 = require("../../errors");
|
|
12
|
+
const inputSource_1 = require("../../../utils/inputSource");
|
|
13
|
+
const remoteFetch_1 = require("../../../utils/remoteFetch");
|
|
14
|
+
const refResolvers_1 = require("../../../utils/refResolvers");
|
|
15
|
+
const SHARED_PARSER_OPTIONS = {
|
|
16
|
+
ruleset: {
|
|
17
|
+
core: false,
|
|
18
|
+
recommended: false
|
|
19
|
+
},
|
|
20
|
+
schemaParsers: [
|
|
21
|
+
(0, avro_schema_parser_1.AvroSchemaParser)(),
|
|
22
|
+
(0, openapi_schema_parser_1.OpenAPISchemaParser)(),
|
|
23
|
+
(0, raml_dt_schema_parser_1.RamlDTSchemaParser)(),
|
|
24
|
+
(0, protobuf_schema_parser_1.ProtoBuffSchemaParser)()
|
|
25
|
+
]
|
|
26
|
+
};
|
|
27
|
+
const sharedParser = new parser_1.Parser({ ...SHARED_PARSER_OPTIONS });
|
|
28
|
+
function buildParserWithAuth(auth, rootUrl) {
|
|
29
|
+
return new parser_1.Parser({
|
|
30
|
+
...SHARED_PARSER_OPTIONS,
|
|
31
|
+
__unstable: {
|
|
32
|
+
resolver: {
|
|
33
|
+
// The resolver shape comes from `@stoplight/spectral-ref-resolver`
|
|
34
|
+
// and accepts `string | undefined | Promise<string | undefined>`.
|
|
35
|
+
// Our resolver factory always returns a string.
|
|
36
|
+
resolvers: (0, refResolvers_1.createAsyncapiResolvers)(auth, { rootUrl })
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async function loadAsyncapi(context) {
|
|
42
|
+
return loadAsyncapiDocument(context.documentPath, context.inputAuth);
|
|
43
|
+
}
|
|
44
|
+
exports.loadAsyncapi = loadAsyncapi;
|
|
45
|
+
async function loadAsyncapiDocument(documentPath, auth) {
|
|
46
|
+
LoggingInterface_1.Logger.verbose(`Loading AsyncAPI document from ${documentPath}`);
|
|
47
|
+
let content;
|
|
48
|
+
if ((0, inputSource_1.isRemoteUrl)(documentPath)) {
|
|
49
|
+
const fetched = await (0, remoteFetch_1.fetchRemoteDocument)(documentPath, auth);
|
|
50
|
+
content = fetched.content;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
try {
|
|
54
|
+
content = (0, fs_1.readFileSync)(documentPath, 'utf-8');
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
58
|
+
inputPath: documentPath,
|
|
59
|
+
inputType: 'asyncapi',
|
|
60
|
+
errorMessage: `Could not read file: ${error}`
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const parser = (0, inputSource_1.isRemoteUrl)(documentPath) && auth
|
|
65
|
+
? buildParserWithAuth(auth, documentPath)
|
|
66
|
+
: sharedParser;
|
|
67
|
+
const document = await parser.parse(content, { source: documentPath });
|
|
68
|
+
if (document.diagnostics.length > 0) {
|
|
69
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
70
|
+
inputPath: documentPath,
|
|
71
|
+
inputType: 'asyncapi',
|
|
72
|
+
errorMessage: JSON.stringify(document.diagnostics, null, 2)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
LoggingInterface_1.Logger.debug(`AsyncAPI document loaded successfully`);
|
|
76
|
+
return document.document;
|
|
77
|
+
}
|
|
78
|
+
exports.loadAsyncapiDocument = loadAsyncapiDocument;
|
|
79
|
+
async function loadAsyncapiFromMemory(input) {
|
|
80
|
+
const document = await sharedParser.parse(input);
|
|
81
|
+
if (document.diagnostics.length > 0) {
|
|
82
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
83
|
+
inputPath: 'memory',
|
|
84
|
+
inputType: 'asyncapi',
|
|
85
|
+
errorMessage: JSON.stringify(document.diagnostics, null, 2)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return document.document;
|
|
89
|
+
}
|
|
90
|
+
exports.loadAsyncapiFromMemory = loadAsyncapiFromMemory;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
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);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./asyncapi"), exports);
|
|
18
|
+
__exportStar(require("./openapi"), exports);
|
|
19
|
+
__exportStar(require("./jsonschema"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { processJsonSchemaModels } from './models';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processJsonSchemaModels = void 0;
|
|
4
|
+
var models_1 = require("./models");
|
|
5
|
+
Object.defineProperty(exports, "processJsonSchemaModels", { enumerable: true, get: function () { return models_1.processJsonSchemaModels; } });
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { JsonSchemaDocument } from '../parser';
|
|
2
|
+
/**
|
|
3
|
+
* Process JSON Schema document for models generation
|
|
4
|
+
* Since the models generator works directly with the raw document,
|
|
5
|
+
* we simply return the document as-is after validation.
|
|
6
|
+
*/
|
|
7
|
+
export declare function processJsonSchemaModels(jsonSchemaDocument: JsonSchemaDocument): JsonSchemaDocument;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processJsonSchemaModels = void 0;
|
|
4
|
+
const LoggingInterface_1 = require("../../../../LoggingInterface");
|
|
5
|
+
/**
|
|
6
|
+
* Process JSON Schema document for models generation
|
|
7
|
+
* Since the models generator works directly with the raw document,
|
|
8
|
+
* we simply return the document as-is after validation.
|
|
9
|
+
*/
|
|
10
|
+
function processJsonSchemaModels(jsonSchemaDocument) {
|
|
11
|
+
if (!jsonSchemaDocument) {
|
|
12
|
+
throw new Error('Expected JSON Schema input, was not given');
|
|
13
|
+
}
|
|
14
|
+
LoggingInterface_1.Logger.info('Processing JSON Schema document for models generation');
|
|
15
|
+
// Validate that the document has content that can be used for model generation
|
|
16
|
+
const hasType = jsonSchemaDocument.type !== undefined;
|
|
17
|
+
const hasProperties = jsonSchemaDocument.properties !== undefined;
|
|
18
|
+
const hasDefinitions = jsonSchemaDocument.definitions !== undefined ||
|
|
19
|
+
jsonSchemaDocument.$defs !== undefined;
|
|
20
|
+
if (!hasType && !hasProperties && !hasDefinitions) {
|
|
21
|
+
LoggingInterface_1.Logger.warn('JSON Schema document appears to have no definitions or type information for model generation');
|
|
22
|
+
}
|
|
23
|
+
// For models generator, we return the document as-is since Modelina can work with raw JSON Schema
|
|
24
|
+
return jsonSchemaDocument;
|
|
25
|
+
}
|
|
26
|
+
exports.processJsonSchemaModels = processJsonSchemaModels;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadJsonSchema, loadJsonSchemaDocument, loadJsonSchemaFromMemory, JsonSchemaDocument } from './parser';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadJsonSchemaFromMemory = exports.loadJsonSchemaDocument = exports.loadJsonSchema = void 0;
|
|
4
|
+
var parser_1 = require("./parser");
|
|
5
|
+
Object.defineProperty(exports, "loadJsonSchema", { enumerable: true, get: function () { return parser_1.loadJsonSchema; } });
|
|
6
|
+
Object.defineProperty(exports, "loadJsonSchemaDocument", { enumerable: true, get: function () { return parser_1.loadJsonSchemaDocument; } });
|
|
7
|
+
Object.defineProperty(exports, "loadJsonSchemaFromMemory", { enumerable: true, get: function () { return parser_1.loadJsonSchemaFromMemory; } });
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { InputAuthConfig, RunGeneratorContext } from '../../types';
|
|
2
|
+
export interface JsonSchemaDocument {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
$schema?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
properties?: {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
};
|
|
9
|
+
definitions?: {
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
$defs?: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Load JSON Schema document from file path or remote URL in context.
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadJsonSchema(context: RunGeneratorContext): Promise<JsonSchemaDocument>;
|
|
20
|
+
/**
|
|
21
|
+
* Load JSON Schema document from a file path or http(s) URL.
|
|
22
|
+
*
|
|
23
|
+
* URL format detection: prefers `Content-Type` (`application/json` →
|
|
24
|
+
* JSON, `*yaml*` → YAML), falls back to URL extension, then to
|
|
25
|
+
* JSON-first-then-YAML for ambiguous cases.
|
|
26
|
+
*/
|
|
27
|
+
export declare function loadJsonSchemaDocument(filePath: string, auth?: InputAuthConfig): Promise<JsonSchemaDocument>;
|
|
28
|
+
/**
|
|
29
|
+
* Load JSON Schema document from memory.
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadJsonSchemaFromMemory(document: JsonSchemaDocument, documentPath?: string): JsonSchemaDocument;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadJsonSchemaFromMemory = exports.loadJsonSchemaDocument = exports.loadJsonSchema = void 0;
|
|
7
|
+
const LoggingInterface_1 = require("../../../LoggingInterface");
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const yaml_1 = require("yaml");
|
|
10
|
+
const errors_1 = require("../../errors");
|
|
11
|
+
const inputSource_1 = require("../../../utils/inputSource");
|
|
12
|
+
const remoteFetch_1 = require("../../../utils/remoteFetch");
|
|
13
|
+
/**
|
|
14
|
+
* Load JSON Schema document from file path or remote URL in context.
|
|
15
|
+
*/
|
|
16
|
+
async function loadJsonSchema(context) {
|
|
17
|
+
return loadJsonSchemaDocument(context.documentPath, context.inputAuth);
|
|
18
|
+
}
|
|
19
|
+
exports.loadJsonSchema = loadJsonSchema;
|
|
20
|
+
/**
|
|
21
|
+
* Load JSON Schema document from a file path or http(s) URL.
|
|
22
|
+
*
|
|
23
|
+
* URL format detection: prefers `Content-Type` (`application/json` →
|
|
24
|
+
* JSON, `*yaml*` → YAML), falls back to URL extension, then to
|
|
25
|
+
* JSON-first-then-YAML for ambiguous cases.
|
|
26
|
+
*/
|
|
27
|
+
async function loadJsonSchemaDocument(filePath, auth) {
|
|
28
|
+
LoggingInterface_1.Logger.verbose(`Loading JSON Schema document from ${filePath}`);
|
|
29
|
+
try {
|
|
30
|
+
let content;
|
|
31
|
+
let contentType = null;
|
|
32
|
+
if ((0, inputSource_1.isRemoteUrl)(filePath)) {
|
|
33
|
+
const fetched = await (0, remoteFetch_1.fetchRemoteDocument)(filePath, auth);
|
|
34
|
+
content = fetched.content;
|
|
35
|
+
contentType = fetched.contentType;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
if (!filePath.endsWith('.json') &&
|
|
39
|
+
!filePath.endsWith('.yaml') &&
|
|
40
|
+
!filePath.endsWith('.yml')) {
|
|
41
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
42
|
+
inputPath: filePath,
|
|
43
|
+
inputType: 'jsonschema',
|
|
44
|
+
errorMessage: `Unsupported file format. Use .json, .yaml, or .yml`
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
content = fs_1.default.readFileSync(filePath, 'utf8');
|
|
48
|
+
}
|
|
49
|
+
const document = parseDocument(content, filePath, contentType);
|
|
50
|
+
validateJsonSchemaDocument(document, filePath);
|
|
51
|
+
return document;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (error?.type) {
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
if (error instanceof Error) {
|
|
58
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
59
|
+
inputPath: filePath,
|
|
60
|
+
inputType: 'jsonschema',
|
|
61
|
+
errorMessage: error.message
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
65
|
+
inputPath: filePath,
|
|
66
|
+
inputType: 'jsonschema',
|
|
67
|
+
errorMessage: 'Unknown error'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.loadJsonSchemaDocument = loadJsonSchemaDocument;
|
|
72
|
+
function parseDocument(content, source, contentType) {
|
|
73
|
+
const ct = contentType?.toLowerCase() ?? '';
|
|
74
|
+
const isYaml = ct.includes('yaml') || source.endsWith('.yaml') || source.endsWith('.yml');
|
|
75
|
+
const isJson = ct.includes('json') || source.endsWith('.json');
|
|
76
|
+
if (isJson && !isYaml) {
|
|
77
|
+
return JSON.parse(content);
|
|
78
|
+
}
|
|
79
|
+
if (isYaml && !isJson) {
|
|
80
|
+
return (0, yaml_1.parse)(content);
|
|
81
|
+
}
|
|
82
|
+
// Ambiguous → JSON-first-then-YAML.
|
|
83
|
+
try {
|
|
84
|
+
return JSON.parse(content);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
return (0, yaml_1.parse)(content);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Load JSON Schema document from memory.
|
|
92
|
+
*/
|
|
93
|
+
function loadJsonSchemaFromMemory(document, documentPath) {
|
|
94
|
+
const path = documentPath || 'memory';
|
|
95
|
+
LoggingInterface_1.Logger.verbose(`Loading JSON Schema document from ${path}`);
|
|
96
|
+
validateJsonSchemaDocument(document, path);
|
|
97
|
+
return document;
|
|
98
|
+
}
|
|
99
|
+
exports.loadJsonSchemaFromMemory = loadJsonSchemaFromMemory;
|
|
100
|
+
/**
|
|
101
|
+
* Basic validation for JSON Schema document.
|
|
102
|
+
*/
|
|
103
|
+
function validateJsonSchemaDocument(document, source) {
|
|
104
|
+
if (!document || typeof document !== 'object') {
|
|
105
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
106
|
+
inputPath: source,
|
|
107
|
+
inputType: 'jsonschema',
|
|
108
|
+
errorMessage: 'Document must be an object'
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (document.$schema && typeof document.$schema !== 'string') {
|
|
112
|
+
throw (0, errors_1.createInputDocumentError)({
|
|
113
|
+
inputPath: source,
|
|
114
|
+
inputType: 'jsonschema',
|
|
115
|
+
errorMessage: '$schema must be a string'
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (!document.$schema) {
|
|
119
|
+
LoggingInterface_1.Logger.warn(`JSON Schema document from ${source} does not specify a $schema version. Consider adding one for better validation.`);
|
|
120
|
+
}
|
|
121
|
+
const hasType = document.type !== undefined;
|
|
122
|
+
const hasProperties = document.properties !== undefined;
|
|
123
|
+
const hasDefinitions = document.definitions !== undefined || document.$defs !== undefined;
|
|
124
|
+
if (!hasType && !hasProperties && !hasDefinitions) {
|
|
125
|
+
LoggingInterface_1.Logger.warn(`JSON Schema document from ${source} appears to be empty or incomplete. It should have 'type', 'properties', 'definitions', or '$defs' for code generation.`);
|
|
126
|
+
}
|
|
127
|
+
LoggingInterface_1.Logger.debug(`Successfully validated JSON Schema document from ${source}`);
|
|
128
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import { ProcessedHeadersData } from '../../../generators/typescript/headers';
|
|
3
|
+
export declare function processOpenAPIHeaders(openapiDocument: OpenAPIV3.Document | OpenAPIV2.Document | OpenAPIV3_1.Document): ProcessedHeadersData;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.processOpenAPIHeaders = void 0;
|
|
4
|
+
const utils_1 = require("../../../generators/typescript/utils");
|
|
5
|
+
// Helper function to convert OpenAPI header schema to JSON Schema
|
|
6
|
+
function convertHeaderSchemaToJsonSchema(header) {
|
|
7
|
+
let schema;
|
|
8
|
+
if (header.schema) {
|
|
9
|
+
// OpenAPI 3.x format
|
|
10
|
+
schema = { ...header.schema };
|
|
11
|
+
}
|
|
12
|
+
else if (header.type) {
|
|
13
|
+
// OpenAPI 2.x format
|
|
14
|
+
schema = {
|
|
15
|
+
type: header.type,
|
|
16
|
+
...(header.format && { format: header.format }),
|
|
17
|
+
...(header.enum && { enum: header.enum }),
|
|
18
|
+
...(header.minimum !== undefined && { minimum: header.minimum }),
|
|
19
|
+
...(header.maximum !== undefined && { maximum: header.maximum }),
|
|
20
|
+
...(header.minLength !== undefined && {
|
|
21
|
+
minLength: header.minLength
|
|
22
|
+
}),
|
|
23
|
+
...(header.maxLength !== undefined && {
|
|
24
|
+
maxLength: header.maxLength
|
|
25
|
+
}),
|
|
26
|
+
...(header.pattern && { pattern: header.pattern })
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
// Fallback to string type
|
|
31
|
+
schema = { type: 'string' };
|
|
32
|
+
}
|
|
33
|
+
return schema;
|
|
34
|
+
}
|
|
35
|
+
// Extract header parameters from OpenAPI operations
|
|
36
|
+
function extractHeadersFromOperations(paths) {
|
|
37
|
+
const operationHeaders = {};
|
|
38
|
+
for (const [pathKey, pathItem] of Object.entries(paths)) {
|
|
39
|
+
for (const [method, operation] of Object.entries(pathItem)) {
|
|
40
|
+
const operationObj = operation;
|
|
41
|
+
// Collect header parameters from operation and path-level
|
|
42
|
+
const allParameters = operationObj.parameters ?? [];
|
|
43
|
+
const headerParams = allParameters.filter((param) => {
|
|
44
|
+
return param.in === 'header';
|
|
45
|
+
});
|
|
46
|
+
if (allParameters.length > 0) {
|
|
47
|
+
const operationId = operationObj.operationId ??
|
|
48
|
+
`${method}${pathKey.replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
49
|
+
operationHeaders[operationId] = headerParams;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return operationHeaders;
|
|
54
|
+
}
|
|
55
|
+
// OpenAPI input processor
|
|
56
|
+
function processOpenAPIHeaders(openapiDocument) {
|
|
57
|
+
const channelHeaders = {};
|
|
58
|
+
// Extract header parameters from all operations
|
|
59
|
+
const operationHeaders = extractHeadersFromOperations(openapiDocument.paths ?? {});
|
|
60
|
+
// Process each operation that has header parameters
|
|
61
|
+
for (const [operationId, headerParams] of Object.entries(operationHeaders)) {
|
|
62
|
+
if (headerParams.length === 0) {
|
|
63
|
+
channelHeaders[operationId] = undefined;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
// Create a JSON Schema object for the headers
|
|
67
|
+
const properties = {};
|
|
68
|
+
const required = [];
|
|
69
|
+
for (const param of headerParams) {
|
|
70
|
+
const paramName = param.name;
|
|
71
|
+
const paramSchema = convertHeaderSchemaToJsonSchema(param);
|
|
72
|
+
// Add description if available
|
|
73
|
+
if (param.description) {
|
|
74
|
+
paramSchema.description = param.description;
|
|
75
|
+
}
|
|
76
|
+
properties[paramName] = paramSchema;
|
|
77
|
+
// Check if header is required
|
|
78
|
+
if (param.required === true) {
|
|
79
|
+
required.push(paramName);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Create the complete schema object
|
|
83
|
+
const schemaObj = {
|
|
84
|
+
type: 'object',
|
|
85
|
+
additionalProperties: false,
|
|
86
|
+
properties,
|
|
87
|
+
$id: (0, utils_1.pascalCase)(`${operationId}_headers`),
|
|
88
|
+
$schema: 'http://json-schema.org/draft-07/schema'
|
|
89
|
+
};
|
|
90
|
+
// Add required array if there are required parameters
|
|
91
|
+
if (required.length > 0) {
|
|
92
|
+
schemaObj.required = required;
|
|
93
|
+
}
|
|
94
|
+
channelHeaders[operationId] = {
|
|
95
|
+
schema: schemaObj,
|
|
96
|
+
schemaId: (0, utils_1.pascalCase)(`${operationId}_headers`)
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return { channelHeaders };
|
|
100
|
+
}
|
|
101
|
+
exports.processOpenAPIHeaders = processOpenAPIHeaders;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';
|
|
2
|
+
import { ProcessedParameterSchemaData } from '../../asyncapi/generators/parameters';
|
|
3
|
+
import { TypeScriptFileGenerator } from '@asyncapi/modelina';
|
|
4
|
+
export declare function processOpenAPIParameters(openapiDocument: OpenAPIV3.Document | OpenAPIV2.Document | OpenAPIV3_1.Document): ProcessedParameterSchemaData;
|
|
5
|
+
export declare function convertParameterSchemaToJsonSchema(parameter: any): any;
|
|
6
|
+
export declare function createParameterSchema(operationId: string, parameters: any[], schemaIdSuffix: string, path?: string): {
|
|
7
|
+
schema: any;
|
|
8
|
+
schemaId: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function createOpenAPIGenerator(): TypeScriptFileGenerator;
|