@goast/typescript 0.2.10 → 0.2.12
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/cjs/lib/generators/models/model-generator.js +4 -2
- package/cjs/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +5 -1
- package/esm/lib/generators/models/model-generator.js +4 -2
- package/esm/lib/generators/services/easy-network-stub/easy-network-stub-generator.js +5 -1
- package/package.json +1 -1
|
@@ -102,7 +102,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_1.TypeScriptFileGen
|
|
|
102
102
|
getIndexer(ctx, schema) {
|
|
103
103
|
var _a;
|
|
104
104
|
return schema.additionalProperties
|
|
105
|
-
? ast_1.ts.indexer(
|
|
105
|
+
? ast_1.ts.indexer(ast_1.ts.refs.string(), (_a = (schema.additionalProperties === true ? null : this.getType(ctx, schema.additionalProperties))) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), { readonly: ctx.config.immutableTypes })
|
|
106
106
|
: null;
|
|
107
107
|
}
|
|
108
108
|
getProperties(ctx, schema) {
|
|
@@ -170,7 +170,9 @@ class DefaultTypeScriptModelGenerator extends file_generator_1.TypeScriptFileGen
|
|
|
170
170
|
schema.allOf.length > 0 || schema.anyOf.length > 0 ? this.getCombinedType(ctx, schema) : null,
|
|
171
171
|
].filter(core_1.notNullish);
|
|
172
172
|
if (parts.length === 0) {
|
|
173
|
-
parts.push(ast_1.ts.objectType(
|
|
173
|
+
parts.push(ast_1.ts.objectType({
|
|
174
|
+
members: [ast_1.ts.indexer(ast_1.ts.refs.string(), ast_1.ts.refs.never(), { readonly: ctx.config.immutableTypes })],
|
|
175
|
+
}));
|
|
174
176
|
}
|
|
175
177
|
return ast_1.ts.intersectionType(parts);
|
|
176
178
|
}
|
|
@@ -137,7 +137,11 @@ class DefaultTypeScriptEasyNetworkStubGenerator extends file_generator_1.TypeScr
|
|
|
137
137
|
let path = endpoint.path;
|
|
138
138
|
let isFirstQueryParam = true;
|
|
139
139
|
for (const param of endpoint.parameters) {
|
|
140
|
-
|
|
140
|
+
let type = ((_b = (param.schema && ((_a = ctx.input.models[param.schema.id]) === null || _a === void 0 ? void 0 : _a.component))) !== null && _b !== void 0 ? _b : ast_1.ts.refs.unknown.name).replace(/^readonly /, '');
|
|
141
|
+
const arrayMatch = /^\((.*)\)\[\]$/.exec(type);
|
|
142
|
+
if (arrayMatch !== null) {
|
|
143
|
+
type = `${arrayMatch[1]}[]`;
|
|
144
|
+
}
|
|
141
145
|
if (param.target === 'path') {
|
|
142
146
|
path = path.replace(`{${param.name}}`, `{${param.name}${param.required ? '' : '?'}:${type}}`);
|
|
143
147
|
}
|
|
@@ -99,7 +99,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
99
99
|
getIndexer(ctx, schema) {
|
|
100
100
|
var _a;
|
|
101
101
|
return schema.additionalProperties
|
|
102
|
-
? ts.indexer(
|
|
102
|
+
? ts.indexer(ts.refs.string(), (_a = (schema.additionalProperties === true ? null : this.getType(ctx, schema.additionalProperties))) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), { readonly: ctx.config.immutableTypes })
|
|
103
103
|
: null;
|
|
104
104
|
}
|
|
105
105
|
getProperties(ctx, schema) {
|
|
@@ -167,7 +167,9 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
167
167
|
schema.allOf.length > 0 || schema.anyOf.length > 0 ? this.getCombinedType(ctx, schema) : null,
|
|
168
168
|
].filter(notNullish);
|
|
169
169
|
if (parts.length === 0) {
|
|
170
|
-
parts.push(ts.objectType(
|
|
170
|
+
parts.push(ts.objectType({
|
|
171
|
+
members: [ts.indexer(ts.refs.string(), ts.refs.never(), { readonly: ctx.config.immutableTypes })],
|
|
172
|
+
}));
|
|
171
173
|
}
|
|
172
174
|
return ts.intersectionType(parts);
|
|
173
175
|
}
|
|
@@ -134,7 +134,11 @@ export class DefaultTypeScriptEasyNetworkStubGenerator extends TypeScriptFileGen
|
|
|
134
134
|
let path = endpoint.path;
|
|
135
135
|
let isFirstQueryParam = true;
|
|
136
136
|
for (const param of endpoint.parameters) {
|
|
137
|
-
|
|
137
|
+
let type = ((_b = (param.schema && ((_a = ctx.input.models[param.schema.id]) === null || _a === void 0 ? void 0 : _a.component))) !== null && _b !== void 0 ? _b : ts.refs.unknown.name).replace(/^readonly /, '');
|
|
138
|
+
const arrayMatch = /^\((.*)\)\[\]$/.exec(type);
|
|
139
|
+
if (arrayMatch !== null) {
|
|
140
|
+
type = `${arrayMatch[1]}[]`;
|
|
141
|
+
}
|
|
138
142
|
if (param.target === 'path') {
|
|
139
143
|
path = path.replace(`{${param.name}}`, `{${param.name}${param.required ? '' : '?'}:${type}}`);
|
|
140
144
|
}
|