swagger-typescript-api 13.0.0-experimental-1 → 13.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/LICENSE +21 -21
- package/README.md +22 -12
- package/cli/constants.js +3 -3
- package/cli/execute.js +52 -31
- package/cli/index.d.ts +1 -2
- package/cli/index.js +18 -17
- package/cli/operations/display-help.js +51 -29
- package/cli/parse-args.js +3 -3
- package/cli/process-option.js +28 -20
- package/index.d.ts +113 -8
- package/index.js +158 -135
- package/package.json +35 -30
- package/src/code-formatter.js +28 -13
- package/src/code-gen-process.js +357 -259
- package/src/commands/generate-templates/configuration.js +2 -2
- package/src/commands/generate-templates/index.js +1 -2
- package/src/commands/generate-templates/templates-gen-process.js +62 -35
- package/src/component-type-name-resolver.js +44 -0
- package/src/configuration.js +167 -95
- package/src/constants.js +28 -22
- package/src/index.js +3 -4
- package/src/schema-components-map.js +39 -23
- package/src/schema-parser/base-schema-parsers/array.js +43 -0
- package/src/schema-parser/base-schema-parsers/complex.js +51 -0
- package/src/schema-parser/base-schema-parsers/discriminator.js +301 -0
- package/src/schema-parser/base-schema-parsers/enum.js +158 -0
- package/src/schema-parser/base-schema-parsers/object.js +105 -0
- package/src/schema-parser/base-schema-parsers/primitive.js +63 -0
- package/src/schema-parser/complex-schema-parsers/all-of.js +26 -0
- package/src/schema-parser/complex-schema-parsers/any-of.js +34 -0
- package/src/schema-parser/complex-schema-parsers/not.js +9 -0
- package/src/schema-parser/complex-schema-parsers/one-of.js +27 -0
- package/src/schema-parser/mono-schema-parser.js +48 -0
- package/src/schema-parser/schema-formatters.js +69 -60
- package/src/schema-parser/schema-parser-fabric.js +131 -0
- package/src/schema-parser/schema-parser.js +208 -427
- package/src/schema-parser/schema-utils.js +123 -58
- package/src/schema-parser/util/enum-key-resolver.js +26 -0
- package/src/schema-routes/schema-routes.js +1225 -0
- package/src/schema-routes/util/specific-arg-name-resolver.js +26 -0
- package/src/schema-walker.js +93 -0
- package/src/swagger-schema-resolver.js +61 -28
- package/src/templates-worker.js +240 -0
- package/src/translators/javascript.js +83 -0
- package/src/translators/translator.js +35 -0
- package/src/type-name-formatter.js +33 -18
- package/src/util/file-system.js +30 -14
- package/src/util/id.js +2 -2
- package/src/util/internal-case.js +1 -1
- package/src/util/logger.js +46 -20
- package/src/util/name-resolver.js +52 -60
- package/src/util/object-assign.js +7 -3
- package/src/util/pascal-case.js +1 -1
- package/src/util/request.js +5 -5
- package/src/util/sort-by-property.js +17 -0
- package/templates/README.md +17 -17
- package/templates/base/README.md +7 -7
- package/templates/base/data-contract-jsdoc.ejs +37 -37
- package/templates/base/data-contracts.ejs +40 -27
- package/templates/base/enum-data-contract.ejs +12 -12
- package/templates/base/http-client.ejs +3 -3
- package/templates/base/http-clients/axios-http-client.ejs +139 -138
- package/templates/base/http-clients/fetch-http-client.ejs +224 -224
- package/templates/base/interface-data-contract.ejs +10 -10
- package/templates/base/object-field-jsdoc.ejs +28 -28
- package/templates/base/route-docs.ejs +30 -30
- package/templates/base/route-name.ejs +42 -42
- package/templates/base/route-type.ejs +22 -21
- package/templates/base/type-data-contract.ejs +15 -15
- package/templates/default/README.md +6 -6
- package/templates/default/api.ejs +69 -68
- package/templates/default/procedure-call.ejs +100 -100
- package/templates/default/route-types.ejs +32 -32
- package/templates/modular/README.md +6 -6
- package/templates/modular/api.ejs +28 -28
- package/templates/modular/procedure-call.ejs +100 -100
- package/templates/modular/route-types.ejs +18 -18
- package/src/schema-parser/schema-processor.js +0 -79
- package/src/schema-parser/schema-routes.js +0 -950
- package/src/templates.js +0 -182
- package/src/translators/JavaScript.js +0 -60
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { MonoSchemaParser } = require('../mono-schema-parser');
|
|
2
|
+
const _ = require('lodash');
|
|
3
|
+
|
|
4
|
+
// T1 | T2 | (T1 & T2)
|
|
5
|
+
class AnyOfSchemaParser extends MonoSchemaParser {
|
|
6
|
+
parse() {
|
|
7
|
+
const ignoreTypes = [this.config.Ts.Keyword.Any];
|
|
8
|
+
const combined = _.map(this.schema.anyOf, (childSchema) =>
|
|
9
|
+
this.schemaParserFabric.getInlineParseContent(
|
|
10
|
+
this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema),
|
|
11
|
+
null,
|
|
12
|
+
this.schemaPath,
|
|
13
|
+
),
|
|
14
|
+
);
|
|
15
|
+
const filtered = this.schemaUtils.filterSchemaContents(
|
|
16
|
+
combined,
|
|
17
|
+
(content) => !ignoreTypes.includes(content),
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const type = this.config.Ts.UnionType(
|
|
21
|
+
_.compact([
|
|
22
|
+
...filtered,
|
|
23
|
+
filtered.length > 1 &&
|
|
24
|
+
this.config.Ts.ExpressionGroup(
|
|
25
|
+
this.config.Ts.IntersectionType(filtered),
|
|
26
|
+
),
|
|
27
|
+
]),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
return this.schemaUtils.safeAddNullToType(this.schema, type);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = { AnyOfSchemaParser };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { MonoSchemaParser } = require('../mono-schema-parser');
|
|
2
|
+
const _ = require('lodash');
|
|
3
|
+
|
|
4
|
+
// T1 | T2
|
|
5
|
+
class OneOfSchemaParser extends MonoSchemaParser {
|
|
6
|
+
parse() {
|
|
7
|
+
const ignoreTypes = [this.config.Ts.Keyword.Any];
|
|
8
|
+
const combined = _.map(this.schema.oneOf, (childSchema) =>
|
|
9
|
+
this.schemaParserFabric.getInlineParseContent(
|
|
10
|
+
this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema),
|
|
11
|
+
null,
|
|
12
|
+
this.schemaPath,
|
|
13
|
+
),
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const filtered = this.schemaUtils.filterSchemaContents(
|
|
17
|
+
combined,
|
|
18
|
+
(content) => !ignoreTypes.includes(content),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const type = this.config.Ts.UnionType(filtered);
|
|
22
|
+
|
|
23
|
+
return this.schemaUtils.safeAddNullToType(this.schema, type);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
module.exports = { OneOfSchemaParser };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
class MonoSchemaParser {
|
|
2
|
+
schema;
|
|
3
|
+
typeName;
|
|
4
|
+
schemaPath;
|
|
5
|
+
|
|
6
|
+
/** @type {Logger} */
|
|
7
|
+
logger;
|
|
8
|
+
/** @type {SchemaParser} */
|
|
9
|
+
schemaParser;
|
|
10
|
+
/** @type {SchemaParserFabric} */
|
|
11
|
+
schemaParserFabric;
|
|
12
|
+
/** @type {TypeNameFormatter} */
|
|
13
|
+
typeNameFormatter;
|
|
14
|
+
/** @type {SchemaComponentsMap} */
|
|
15
|
+
schemaComponentsMap;
|
|
16
|
+
/** @type {SchemaUtils} */
|
|
17
|
+
schemaUtils;
|
|
18
|
+
/** @type {CodeGenConfig} */
|
|
19
|
+
config;
|
|
20
|
+
/** @type {SchemaFormatters} */
|
|
21
|
+
schemaFormatters;
|
|
22
|
+
|
|
23
|
+
constructor(schemaParser, schema, typeName = null, schemaPath = []) {
|
|
24
|
+
this.schemaParser = schemaParser;
|
|
25
|
+
this.schemaParserFabric = schemaParser.schemaParserFabric;
|
|
26
|
+
this.logger = schemaParser.logger;
|
|
27
|
+
this.schema = schema;
|
|
28
|
+
this.typeName = typeName;
|
|
29
|
+
this.typeNameFormatter = schemaParser.typeNameFormatter;
|
|
30
|
+
this.schemaPath = schemaPath;
|
|
31
|
+
this.schemaComponentsMap = this.schemaParser.schemaComponentsMap;
|
|
32
|
+
this.schemaUtils = this.schemaParser.schemaUtils;
|
|
33
|
+
this.config = this.schemaParser.config;
|
|
34
|
+
this.schemaFormatters = this.schemaParser.schemaFormatters;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
parse() {
|
|
38
|
+
throw new Error('not implemented');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
buildTypeNameFromPath = () => {
|
|
42
|
+
return this.schemaUtils.buildTypeNameFromPath(this.schemaPath);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = {
|
|
47
|
+
MonoSchemaParser,
|
|
48
|
+
};
|
|
@@ -1,29 +1,24 @@
|
|
|
1
|
-
const { SCHEMA_TYPES } = require(
|
|
2
|
-
const _ = require(
|
|
1
|
+
const { SCHEMA_TYPES } = require('../constants');
|
|
2
|
+
const _ = require('lodash');
|
|
3
3
|
|
|
4
4
|
class SchemaFormatters {
|
|
5
|
-
/**
|
|
6
|
-
* @type {CodeGenConfig}
|
|
7
|
-
*/
|
|
5
|
+
/** @type {CodeGenConfig} */
|
|
8
6
|
config;
|
|
9
|
-
/**
|
|
10
|
-
* @type {Logger}
|
|
11
|
-
*/
|
|
7
|
+
/** @type {Logger} */
|
|
12
8
|
logger;
|
|
9
|
+
/** @type {TemplatesWorker} */
|
|
10
|
+
templatesWorker;
|
|
11
|
+
/** @type {SchemaUtils} */
|
|
12
|
+
schemaUtils;
|
|
13
|
+
|
|
13
14
|
/**
|
|
14
|
-
* @
|
|
15
|
-
*/
|
|
16
|
-
schemaParser;
|
|
17
|
-
/**
|
|
18
|
-
* @type {Templates}
|
|
15
|
+
* @param schemaParser {SchemaParser | SchemaParserFabric}
|
|
19
16
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
this.
|
|
25
|
-
this.schemaParser = schemaParser;
|
|
26
|
-
this.templates = templates;
|
|
17
|
+
constructor(schemaParser) {
|
|
18
|
+
this.config = schemaParser.config;
|
|
19
|
+
this.logger = schemaParser.logger;
|
|
20
|
+
this.schemaUtils = schemaParser.schemaUtils;
|
|
21
|
+
this.templatesWorker = schemaParser.templatesWorker;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
base = {
|
|
@@ -32,7 +27,9 @@ class SchemaFormatters {
|
|
|
32
27
|
return {
|
|
33
28
|
...parsedSchema,
|
|
34
29
|
$content: parsedSchema.content,
|
|
35
|
-
content: this.config.Ts.UnionType(
|
|
30
|
+
content: this.config.Ts.UnionType(
|
|
31
|
+
_.map(parsedSchema.content, ({ value }) => value),
|
|
32
|
+
),
|
|
36
33
|
};
|
|
37
34
|
}
|
|
38
35
|
|
|
@@ -42,12 +39,13 @@ class SchemaFormatters {
|
|
|
42
39
|
content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content),
|
|
43
40
|
};
|
|
44
41
|
},
|
|
45
|
-
[SCHEMA_TYPES.OBJECT]:
|
|
46
|
-
if (parsedSchema.nullable)
|
|
42
|
+
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => {
|
|
43
|
+
if (parsedSchema.nullable)
|
|
44
|
+
return this.inline[SCHEMA_TYPES.OBJECT](parsedSchema);
|
|
47
45
|
return {
|
|
48
46
|
...parsedSchema,
|
|
49
47
|
$content: parsedSchema.content,
|
|
50
|
-
content:
|
|
48
|
+
content: this.formatObjectContent(parsedSchema.content),
|
|
51
49
|
};
|
|
52
50
|
},
|
|
53
51
|
[SCHEMA_TYPES.PRIMITIVE]: (parsedSchema) => {
|
|
@@ -68,26 +66,31 @@ class SchemaFormatters {
|
|
|
68
66
|
..._.map(parsedSchema.content, ({ value }) => `${value}`),
|
|
69
67
|
parsedSchema.nullable && this.config.Ts.Keyword.Null,
|
|
70
68
|
]),
|
|
71
|
-
),
|
|
69
|
+
) || this.config.Ts.Keyword.Any,
|
|
72
70
|
};
|
|
73
71
|
},
|
|
74
|
-
[SCHEMA_TYPES.OBJECT]:
|
|
72
|
+
[SCHEMA_TYPES.OBJECT]: (parsedSchema) => {
|
|
75
73
|
if (_.isString(parsedSchema.content)) {
|
|
76
74
|
return {
|
|
77
75
|
...parsedSchema,
|
|
78
76
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
79
|
-
content: this.
|
|
77
|
+
content: this.schemaUtils.safeAddNullToType(parsedSchema.content),
|
|
80
78
|
};
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
return {
|
|
84
82
|
...parsedSchema,
|
|
85
83
|
typeIdentifier: this.config.Ts.Keyword.Type,
|
|
86
|
-
content: this.
|
|
84
|
+
content: this.schemaUtils.safeAddNullToType(
|
|
87
85
|
parsedSchema,
|
|
88
86
|
parsedSchema.content.length
|
|
89
|
-
? this.config.Ts.ObjectWrapper(
|
|
90
|
-
|
|
87
|
+
? this.config.Ts.ObjectWrapper(
|
|
88
|
+
this.formatObjectContent(parsedSchema.content),
|
|
89
|
+
)
|
|
90
|
+
: this.config.Ts.RecordType(
|
|
91
|
+
this.config.Ts.Keyword.String,
|
|
92
|
+
this.config.Ts.Keyword.Any,
|
|
93
|
+
),
|
|
91
94
|
),
|
|
92
95
|
};
|
|
93
96
|
},
|
|
@@ -95,23 +98,24 @@ class SchemaFormatters {
|
|
|
95
98
|
|
|
96
99
|
/**
|
|
97
100
|
* @param parsedSchema {Record<string, any>}
|
|
98
|
-
* @param
|
|
101
|
+
* @param formatType {"base" | "inline"}
|
|
99
102
|
*/
|
|
100
|
-
formatSchema =
|
|
103
|
+
formatSchema = (parsedSchema, formatType = 'base') => {
|
|
101
104
|
const schemaType =
|
|
102
|
-
|
|
105
|
+
_.get(parsedSchema, ['schemaType']) ||
|
|
106
|
+
_.get(parsedSchema, ['$parsed', 'schemaType']);
|
|
103
107
|
const formatterFn = _.get(this, [formatType, schemaType]);
|
|
104
|
-
return (formatterFn &&
|
|
108
|
+
return (formatterFn && formatterFn(parsedSchema)) || parsedSchema;
|
|
105
109
|
};
|
|
106
110
|
|
|
107
111
|
formatDescription = (description, inline) => {
|
|
108
|
-
if (!description) return
|
|
112
|
+
if (!description) return '';
|
|
109
113
|
|
|
110
114
|
let prettified = description;
|
|
111
115
|
|
|
112
|
-
prettified = _.replace(prettified, /\*\//g,
|
|
116
|
+
prettified = _.replace(prettified, /\*\//g, '*/');
|
|
113
117
|
|
|
114
|
-
const hasMultipleLines = _.includes(prettified,
|
|
118
|
+
const hasMultipleLines = _.includes(prettified, '\n');
|
|
115
119
|
|
|
116
120
|
if (!hasMultipleLines) return prettified;
|
|
117
121
|
|
|
@@ -120,35 +124,40 @@ class SchemaFormatters {
|
|
|
120
124
|
.split(/\n/g)
|
|
121
125
|
.map((part) => _.trim(part))
|
|
122
126
|
.compact()
|
|
123
|
-
.join(
|
|
127
|
+
.join(' ')
|
|
124
128
|
.valueOf();
|
|
125
129
|
}
|
|
126
130
|
|
|
127
|
-
return _.replace(prettified, /\n$/g,
|
|
131
|
+
return _.replace(prettified, /\n$/g, '');
|
|
128
132
|
};
|
|
129
133
|
|
|
130
|
-
formatObjectContent =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
134
|
+
formatObjectContent = (content) => {
|
|
135
|
+
const fields = [];
|
|
136
|
+
|
|
137
|
+
for (const part of content) {
|
|
138
|
+
const extraSpace = ' ';
|
|
139
|
+
const result = `${extraSpace}${part.field},\n`;
|
|
140
|
+
|
|
141
|
+
const renderedJsDoc = this.templatesWorker.renderTemplate(
|
|
142
|
+
this.config.templatesToRender.dataContractJsDoc,
|
|
143
|
+
{
|
|
144
|
+
data: part,
|
|
145
|
+
},
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
const routeNameFromTemplate = renderedJsDoc
|
|
149
|
+
.split('\n')
|
|
150
|
+
.map((c) => `${extraSpace}${c}`)
|
|
151
|
+
.join('\n');
|
|
152
|
+
|
|
153
|
+
if (routeNameFromTemplate) {
|
|
154
|
+
fields.push(`${routeNameFromTemplate}${result}`);
|
|
155
|
+
} else {
|
|
156
|
+
fields.push(`${result}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
147
159
|
|
|
148
|
-
|
|
149
|
-
}),
|
|
150
|
-
)
|
|
151
|
-
).join("");
|
|
160
|
+
return fields.join('');
|
|
152
161
|
};
|
|
153
162
|
}
|
|
154
163
|
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
const _ = require('lodash');
|
|
2
|
+
const { SchemaFormatters } = require('./schema-formatters');
|
|
3
|
+
const { SchemaUtils } = require('./schema-utils');
|
|
4
|
+
const { SchemaParser } = require('./schema-parser');
|
|
5
|
+
|
|
6
|
+
class SchemaParserFabric {
|
|
7
|
+
/** @type {CodeGenConfig} */
|
|
8
|
+
config;
|
|
9
|
+
/** @type {Logger} */
|
|
10
|
+
logger;
|
|
11
|
+
/** @type {SchemaComponentsMap} */
|
|
12
|
+
schemaComponentsMap;
|
|
13
|
+
/** @type {TypeNameFormatter} */
|
|
14
|
+
typeNameFormatter;
|
|
15
|
+
/** @type {SchemaFormatters} */
|
|
16
|
+
schemaFormatters;
|
|
17
|
+
/** @type {TemplatesWorker} */
|
|
18
|
+
templatesWorker;
|
|
19
|
+
/** @type {SchemaUtils} */
|
|
20
|
+
schemaUtils;
|
|
21
|
+
/** @type {SchemaWalker} */
|
|
22
|
+
schemaWalker;
|
|
23
|
+
|
|
24
|
+
constructor({
|
|
25
|
+
config,
|
|
26
|
+
logger,
|
|
27
|
+
templatesWorker,
|
|
28
|
+
schemaComponentsMap,
|
|
29
|
+
typeNameFormatter,
|
|
30
|
+
schemaWalker,
|
|
31
|
+
}) {
|
|
32
|
+
this.config = config;
|
|
33
|
+
this.logger = logger;
|
|
34
|
+
this.schemaComponentsMap = schemaComponentsMap;
|
|
35
|
+
this.typeNameFormatter = typeNameFormatter;
|
|
36
|
+
this.templatesWorker = templatesWorker;
|
|
37
|
+
this.schemaWalker = schemaWalker;
|
|
38
|
+
this.schemaUtils = new SchemaUtils(this);
|
|
39
|
+
this.schemaFormatters = new SchemaFormatters(this);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
createSchemaParser = ({ schema, typeName, schemaPath }) => {
|
|
43
|
+
return new SchemaParser(this, { schema, typeName, schemaPath });
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @param content schema content
|
|
49
|
+
* @param linkedSchema link content to attached schema
|
|
50
|
+
* @param linkedComponent link content and other schema props to attached component
|
|
51
|
+
* @param schemaPath
|
|
52
|
+
* @param otherSchemaProps
|
|
53
|
+
* @returns {{}}
|
|
54
|
+
*/
|
|
55
|
+
createSchema = ({
|
|
56
|
+
content,
|
|
57
|
+
linkedSchema = {},
|
|
58
|
+
linkedComponent,
|
|
59
|
+
schemaPath,
|
|
60
|
+
...otherSchemaProps
|
|
61
|
+
}) => {
|
|
62
|
+
const parser = this.createSchemaParser({
|
|
63
|
+
schema: linkedComponent || linkedSchema,
|
|
64
|
+
schemaPath,
|
|
65
|
+
});
|
|
66
|
+
const parsed = parser.parseSchema();
|
|
67
|
+
parsed.content = content;
|
|
68
|
+
Object.assign(parsed, otherSchemaProps);
|
|
69
|
+
if (linkedComponent) {
|
|
70
|
+
linkedComponent.typeData = parsed;
|
|
71
|
+
}
|
|
72
|
+
return parser.schema;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
createParsedComponent = ({ typeName, schema, schemaPath }) => {
|
|
76
|
+
const schemaCopy = _.cloneDeep(schema);
|
|
77
|
+
const customComponent = this.schemaComponentsMap.createComponent(
|
|
78
|
+
this.schemaComponentsMap.createRef(['components', 'schemas', typeName]),
|
|
79
|
+
schemaCopy,
|
|
80
|
+
);
|
|
81
|
+
const parsed = this.parseSchema(schemaCopy, null, schemaPath);
|
|
82
|
+
parsed.name = typeName;
|
|
83
|
+
customComponent.typeData = parsed;
|
|
84
|
+
|
|
85
|
+
return customComponent;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
* @param schema {any}
|
|
91
|
+
* @param typeName {null | string}
|
|
92
|
+
* @param [schemaPath] {string[]}
|
|
93
|
+
* @return {Record<string, any>}
|
|
94
|
+
*/
|
|
95
|
+
parseSchema = (schema, typeName = null, schemaPath = []) => {
|
|
96
|
+
const schemaParser = this.createSchemaParser({
|
|
97
|
+
schema,
|
|
98
|
+
typeName,
|
|
99
|
+
schemaPath,
|
|
100
|
+
});
|
|
101
|
+
return schemaParser.parseSchema();
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @param schema {any}
|
|
107
|
+
* @param typeName {null | string}
|
|
108
|
+
* @param [schemaPath] {string[]}
|
|
109
|
+
* @return {Record<string, any>}
|
|
110
|
+
*/
|
|
111
|
+
getInlineParseContent = (schema, typeName, schemaPath) => {
|
|
112
|
+
const parser = this.createSchemaParser({ schema, typeName, schemaPath });
|
|
113
|
+
return parser.getInlineParseContent();
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
*
|
|
118
|
+
* @param schema {any}
|
|
119
|
+
* @param typeName {null | string}
|
|
120
|
+
* @param [schemaPath] {string[]}
|
|
121
|
+
* @return {Record<string, any>}
|
|
122
|
+
*/
|
|
123
|
+
getParseContent = (schema, typeName, schemaPath) => {
|
|
124
|
+
const parser = this.createSchemaParser({ schema, typeName, schemaPath });
|
|
125
|
+
return parser.getParseContent();
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
module.exports = {
|
|
130
|
+
SchemaParserFabric,
|
|
131
|
+
};
|