@goast/typescript 0.7.3 → 0.7.4
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/esm/src/config.d.ts +5 -0
- package/esm/src/config.d.ts.map +1 -1
- package/esm/src/config.js +1 -0
- package/esm/src/generators/models/model-generator.d.ts +2 -1
- package/esm/src/generators/models/model-generator.d.ts.map +1 -1
- package/esm/src/generators/models/model-generator.js +13 -4
- package/esm/src/generators/services/angular-services/angular-service-generator.d.ts +4 -1
- package/esm/src/generators/services/angular-services/angular-service-generator.d.ts.map +1 -1
- package/esm/src/generators/services/angular-services/angular-service-generator.js +13 -4
- package/esm/src/generators/services/fetch-clients/fetch-client-generator.d.ts +4 -1
- package/esm/src/generators/services/fetch-clients/fetch-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/fetch-clients/fetch-client-generator.js +14 -2
- package/esm/src/generators/services/k6-clients/k6-client-generator.d.ts +4 -1
- package/esm/src/generators/services/k6-clients/k6-client-generator.d.ts.map +1 -1
- package/esm/src/generators/services/k6-clients/k6-client-generator.js +21 -3
- package/esm/src/utils.d.ts +2 -1
- package/esm/src/utils.d.ts.map +1 -1
- package/esm/src/utils.js +7 -1
- package/package.json +2 -2
- package/script/src/config.d.ts +5 -0
- package/script/src/config.d.ts.map +1 -1
- package/script/src/config.js +1 -0
- package/script/src/generators/models/model-generator.d.ts +2 -1
- package/script/src/generators/models/model-generator.d.ts.map +1 -1
- package/script/src/generators/models/model-generator.js +13 -4
- package/script/src/generators/services/angular-services/angular-service-generator.d.ts +4 -1
- package/script/src/generators/services/angular-services/angular-service-generator.d.ts.map +1 -1
- package/script/src/generators/services/angular-services/angular-service-generator.js +12 -3
- package/script/src/generators/services/fetch-clients/fetch-client-generator.d.ts +4 -1
- package/script/src/generators/services/fetch-clients/fetch-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/fetch-clients/fetch-client-generator.js +13 -1
- package/script/src/generators/services/k6-clients/k6-client-generator.d.ts +4 -1
- package/script/src/generators/services/k6-clients/k6-client-generator.d.ts.map +1 -1
- package/script/src/generators/services/k6-clients/k6-client-generator.js +20 -2
- package/script/src/utils.d.ts +2 -1
- package/script/src/utils.d.ts.map +1 -1
- package/script/src/utils.js +9 -1
- package/src/src/config.ts +7 -0
- package/src/src/generators/models/model-generator.ts +16 -4
- package/src/src/generators/services/angular-services/angular-service-generator.ts +20 -3
- package/src/src/generators/services/angular-services/angular-services-generator.ts +1 -1
- package/src/src/generators/services/fetch-clients/fetch-client-generator.ts +21 -1
- package/src/src/generators/services/k6-clients/k6-client-generator.ts +46 -15
- package/src/src/utils.ts +9 -2
package/esm/src/config.d.ts
CHANGED
|
@@ -56,6 +56,11 @@ export type TypeScriptGeneratorConfig = OpenApiGeneratorConfig & {
|
|
|
56
56
|
* @default true
|
|
57
57
|
*/
|
|
58
58
|
useSingleQuotes: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to include the source OpenAPI document path in the generated documentation comments.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
includeSourceInDocs: boolean;
|
|
59
64
|
};
|
|
60
65
|
export declare const defaultTypeScriptGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptGeneratorConfig>;
|
|
61
66
|
//# sourceMappingURL=config.d.ts.map
|
package/esm/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEjH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,GAAG;IAC/D;;;OAGG;IACH,uBAAuB,EAAE,uBAAuB,CAAC;IAEjD;;;OAGG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;;OAGG;IACH,c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,OAAO,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,+BAA+B,CAAC,yBAAyB,CAiBvG,CAAC"}
|
package/esm/src/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiSchema, type AppendValueGroup, type ArrayLikeApiSchema, type CombinedLikeApiSchema, type MaybePromise, type Nullable, type ObjectLikeApiSchema, type StringLikeApiSchema } from '@goast/core';
|
|
1
|
+
import { type ApiSchema, type AppendValueGroup, type ArrayLikeApiSchema, type BasicAppendValue, type CombinedLikeApiSchema, type MaybePromise, type Nullable, type ObjectLikeApiSchema, type StringLikeApiSchema } from '@goast/core';
|
|
2
2
|
import { ts } from '../../ast/index.js';
|
|
3
3
|
import type { TypeScriptComponentOutputKind } from '../../common-results.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
@@ -31,6 +31,7 @@ export declare class DefaultTypeScriptModelGenerator extends TypeScriptFileGener
|
|
|
31
31
|
protected getCombinedType(ctx: Context, schema: CombinedLikeApiSchema): ts.Type<Builder>;
|
|
32
32
|
protected getOneOfType(ctx: Context, schema: ApiSchema<'oneOf'>): ts.Type<Builder>;
|
|
33
33
|
protected getMultiType(ctx: Context, schema: ApiSchema<'multi-type'>): ts.Type<Builder>;
|
|
34
|
+
protected getSchemaDocDescription(ctx: Context, schema: ApiSchema): BasicAppendValue<Builder>;
|
|
34
35
|
protected shouldGenerateTypeDeclaration(ctx: Context, schema: ApiSchema): boolean;
|
|
35
36
|
protected resolveInterfaceSchema(ctx: Context): ApiSchema<'object'> | undefined;
|
|
36
37
|
protected getDeclarationTypeName(ctx: Context, schema: ApiSchema): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAA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,MAAM,EAAE,SAAS,GAAG,MAAM;IAInF,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAI3E,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAIlE,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAM7F,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;CAO/D"}
|
|
@@ -2,6 +2,7 @@ import { resolve } from 'node:path';
|
|
|
2
2
|
import { appendValueGroup, DEFAULT_IGNORED_SCHEMA_PROPERTIES, getSchemaReference, getSourceDisplayName, notNullish, resolveAnyOfAndAllOf, toCasing, } from '@goast/core';
|
|
3
3
|
import { ts } from '../../ast/index.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
5
|
+
import { getSourceDocLine } from '../../utils.js';
|
|
5
6
|
import { TypeScriptFileGenerator } from '../file-generator.js';
|
|
6
7
|
export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
7
8
|
generate(ctx) {
|
|
@@ -84,7 +85,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
84
85
|
var _a, _b;
|
|
85
86
|
return ts.enum(this.getDeclarationTypeName(ctx, ctx.schema), {
|
|
86
87
|
doc: ts.doc({
|
|
87
|
-
description: ctx.schema
|
|
88
|
+
description: this.getSchemaDocDescription(ctx, ctx.schema),
|
|
88
89
|
tags: [ctx.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
89
90
|
}),
|
|
90
91
|
export: true,
|
|
@@ -95,7 +96,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
95
96
|
return ts.interface(this.getDeclarationTypeName(ctx, ctx.schema), {
|
|
96
97
|
export: true,
|
|
97
98
|
doc: ts.doc({
|
|
98
|
-
description:
|
|
99
|
+
description: this.getSchemaDocDescription(ctx, schema),
|
|
99
100
|
tags: [ctx.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
100
101
|
}),
|
|
101
102
|
members: [...this.getProperties(ctx, schema), this.getIndexer(ctx, schema)],
|
|
@@ -107,7 +108,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
107
108
|
const result = ts.typeAlias(this.getDeclarationTypeName(ctx, schema), (_a = (hasDiscriminator ? this.getDiscriminatorType(ctx, schema) : this.getType(ctx, schema, { skipSchemas: true }))) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), {
|
|
108
109
|
export: true,
|
|
109
110
|
doc: ts.doc({
|
|
110
|
-
description:
|
|
111
|
+
description: this.getSchemaDocDescription(ctx, schema),
|
|
111
112
|
tags: [ctx.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
112
113
|
}),
|
|
113
114
|
});
|
|
@@ -164,7 +165,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
164
165
|
return Array.from(schema.properties.values()).map((property) => {
|
|
165
166
|
return ts.property(property.name, {
|
|
166
167
|
doc: ts.doc({
|
|
167
|
-
description: property.schema
|
|
168
|
+
description: this.getSchemaDocDescription(ctx, property.schema),
|
|
168
169
|
tags: [property.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
169
170
|
}),
|
|
170
171
|
readonly: ctx.config.immutableTypes,
|
|
@@ -310,6 +311,14 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator {
|
|
|
310
311
|
}
|
|
311
312
|
}));
|
|
312
313
|
}
|
|
314
|
+
getSchemaDocDescription(ctx, schema) {
|
|
315
|
+
var _a;
|
|
316
|
+
const docSegments = [(_a = schema.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
317
|
+
if (ctx.config.includeSourceInDocs) {
|
|
318
|
+
docSegments.push(getSourceDocLine(schema));
|
|
319
|
+
}
|
|
320
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
321
|
+
}
|
|
313
322
|
shouldGenerateTypeDeclaration(ctx, schema) {
|
|
314
323
|
var _a;
|
|
315
324
|
// All named schemas should have its own type declaration
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type MaybePromise } from '@goast/core';
|
|
1
|
+
import { type ApiComponent, type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type BasicAppendValue, type MaybePromise } from '@goast/core';
|
|
2
2
|
import { ts } from '../../../ast/index.js';
|
|
3
3
|
import type { TypeScriptExportOutput } from '../../../common-results.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
@@ -22,6 +22,9 @@ export declare class DefaultTypeScriptAngularServiceGenerator extends TypeScript
|
|
|
22
22
|
protected getEndpointParamsType(ctx: Context, endpoint: ApiEndpoint): ts.TypeAlias<Builder>;
|
|
23
23
|
protected getClass(ctx: Context): ts.Class<Builder>;
|
|
24
24
|
protected getEndpointMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
25
|
+
protected getDocDescription<T>(ctx: Context, component: ApiComponent<T> & {
|
|
26
|
+
description?: string;
|
|
27
|
+
}): BasicAppendValue<Builder>;
|
|
25
28
|
protected getEndpointRequestContentType(ctx: Context, endpoint: ApiEndpoint): string;
|
|
26
29
|
protected getEndpointSuccessResponseType(ctx: Context, endpoint: ApiEndpoint): string;
|
|
27
30
|
protected getEndpointSuccessResponse(_ctx: Context, endpoint: ApiEndpoint): ApiResponse | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-service-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/angular-services/angular-service-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"angular-service-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/angular-services/angular-service-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAIlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,wCAAwC,EAAE,uCAAuC,EAAE,MAAM,aAAa,CAAC;AAErH,KAAK,OAAO,GAAG,wCAAwC,CAAC;AACxD,KAAK,MAAM,GAAG,uCAAuC,CAAC;AACtD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,iCAAiC,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAChF,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,wCAAyC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CACnG,YAAW,iCAAiC;IACrC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;IA4BnD,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAetF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAmErG,SAAS,CAAC,sBAAsB,CAC9B,G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AAS,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIhF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIlF,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI5E,SAAS,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQlD,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQxD,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO;IAI1E,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;IAMnH,OAAO,CAAC,yBAAyB;CAGlC"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
|
-
import { appendValueGroup, builderTemplate as s, getSourceDisplayName, toCasing, } from '@goast/core';
|
|
2
|
+
import { appendValueGroup, builderTemplate as s, getSourceDisplayName, notNullish, toCasing, } from '@goast/core';
|
|
3
3
|
import { ts } from '../../../ast/index.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
5
|
+
import { getSourceDocLine } from '../../../utils.js';
|
|
5
6
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
6
7
|
export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGenerator {
|
|
7
8
|
generate(ctx) {
|
|
@@ -141,7 +142,7 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
141
142
|
const schema = parameter.schema;
|
|
142
143
|
type.members.push(ts.property(toCasing(parameter.name, ctx.config.propertyNameCasing), {
|
|
143
144
|
doc: ts.doc({
|
|
144
|
-
description:
|
|
145
|
+
description: this.getDocDescription(ctx, parameter),
|
|
145
146
|
tags: [parameter.deprecated ? ts.docTag('deprecated') : null],
|
|
146
147
|
}),
|
|
147
148
|
type: schema ? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id]) : this.getAnyType(ctx),
|
|
@@ -152,7 +153,7 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
152
153
|
const body = endpoint.requestBody;
|
|
153
154
|
const schema = body.content[0].schema;
|
|
154
155
|
type.members.push(ts.property('body', {
|
|
155
|
-
doc: ts.doc({ description:
|
|
156
|
+
doc: ts.doc({ description: this.getDocDescription(ctx, body) }),
|
|
156
157
|
type: schema ? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id]) : this.getAnyType(ctx),
|
|
157
158
|
optional: !body.required,
|
|
158
159
|
}));
|
|
@@ -209,7 +210,7 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
209
210
|
ts.parameter('context', { optional: true, type: ts.refs.angular.httpContext() }),
|
|
210
211
|
],
|
|
211
212
|
doc: ts.doc({
|
|
212
|
-
description:
|
|
213
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
213
214
|
tags: [endpoint.deprecated ? ts.docTag('deprecated') : null],
|
|
214
215
|
}),
|
|
215
216
|
returnType,
|
|
@@ -255,6 +256,14 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
255
256
|
], '\n'),
|
|
256
257
|
});
|
|
257
258
|
}
|
|
259
|
+
getDocDescription(ctx, component) {
|
|
260
|
+
var _a;
|
|
261
|
+
const docSegments = [(_a = component.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
262
|
+
if (ctx.config.includeSourceInDocs) {
|
|
263
|
+
docSegments.push(getSourceDocLine(component));
|
|
264
|
+
}
|
|
265
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
266
|
+
}
|
|
258
267
|
getEndpointRequestContentType(ctx, endpoint) {
|
|
259
268
|
var _a, _b, _c;
|
|
260
269
|
return (_c = (_a = ctx.config.defaultRequestContentType) !== null && _a !== void 0 ? _a : (_b = endpoint === null || endpoint === void 0 ? void 0 : endpoint.requestBody) === null || _b === void 0 ? void 0 : _b.content[0].type) !== null && _c !== void 0 ? _c : 'application/json';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiEndpoint, type ApiSchema, type AppendValueGroup, type MaybePromise } from '@goast/core';
|
|
1
|
+
import { type ApiComponent, type ApiEndpoint, type ApiSchema, type AppendValueGroup, type BasicAppendValue, type MaybePromise } from '@goast/core';
|
|
2
2
|
import { ts } from '../../../ast/index.js';
|
|
3
3
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
4
4
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
@@ -18,6 +18,9 @@ export declare class DefaultTypeScriptFetchClientGenerator extends TypeScriptFil
|
|
|
18
18
|
protected getDefaultOptionsConstant(ctx: Context): ts.Variable<Builder>;
|
|
19
19
|
protected getClass(ctx: Context): ts.Class<Builder>;
|
|
20
20
|
protected getServiceMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
21
|
+
protected getDocDescription<T>(ctx: Context, component: ApiComponent<T> & {
|
|
22
|
+
description?: string;
|
|
23
|
+
}): BasicAppendValue<Builder>;
|
|
21
24
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder>;
|
|
22
25
|
protected shouldGenerateInterface(ctx: Context): boolean;
|
|
23
26
|
protected shouldGenerateClass(ctx: Context): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/fetch-clients/fetch-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"fetch-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/fetch-clients/fetch-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,qCAAqC,EAAE,oCAAoC,EAAE,MAAM,aAAa,CAAC;AAE/G,KAAK,OAAO,GAAG,qCAAqC,CAAC;AACrD,KAAK,MAAM,GAAG,oCAAoC,CAAC;AACnD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,8BAA8B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC7E,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CAC/C;AAED,qBAAa,qCAAsC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAChG,YAAW,8BAA8B;IAClC,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,YAAY,CAAC,MAAM,CAAC;IA4CnD,SAAS,CAAC,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAI1E,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC;IAe3D,SAAS,CAAC,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,EAAE,CAAC,MAAM,CAAC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D,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI7D,OAAO,CAAC,iBAAiB;CAK1B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
|
-
import { appendValueGroup, builderTemplate as s, getSourceDisplayName, toCasing, } from '@goast/core';
|
|
2
|
+
import { appendValueGroup, builderTemplate as s, getSourceDisplayName, notNullish, toCasing, } from '@goast/core';
|
|
3
3
|
import { ts } from '../../../ast/index.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
5
|
+
import { getSourceDocLine } from '../../../utils.js';
|
|
5
6
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
6
7
|
export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerator {
|
|
7
8
|
generate(ctx) {
|
|
@@ -59,7 +60,10 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
|
|
|
59
60
|
const bodySchema = (_b = (_a = endpoint.requestBody) === null || _a === void 0 ? void 0 : _a.content[0]) === null || _b === void 0 ? void 0 : _b.schema;
|
|
60
61
|
const responseSchema = this.getResponseSchema(ctx, endpoint);
|
|
61
62
|
return ts.method(toCasing(endpoint.name, ctx.config.functionNameCasing), {
|
|
62
|
-
doc: ts.doc({
|
|
63
|
+
doc: ts.doc({
|
|
64
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
65
|
+
tags: [endpoint.deprecated ? ts.docTag('deprecated') : null],
|
|
66
|
+
}),
|
|
63
67
|
parameters: [
|
|
64
68
|
params.length > 0
|
|
65
69
|
? ts.parameter('params', {
|
|
@@ -165,6 +169,14 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
|
|
|
165
169
|
return method;
|
|
166
170
|
}
|
|
167
171
|
// #endregion
|
|
172
|
+
getDocDescription(ctx, component) {
|
|
173
|
+
var _a;
|
|
174
|
+
const docSegments = [(_a = component.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
175
|
+
if (ctx.config.includeSourceInDocs) {
|
|
176
|
+
docSegments.push(getSourceDocLine(component));
|
|
177
|
+
}
|
|
178
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
179
|
+
}
|
|
168
180
|
getSchemaType(ctx, schema, fallback) {
|
|
169
181
|
const output = schema && ctx.input.typescript.models[schema.id];
|
|
170
182
|
if (!output)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type MaybePromise } from '@goast/core';
|
|
1
|
+
import { type ApiComponent, type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type BasicAppendValue, type MaybePromise } from '@goast/core';
|
|
2
2
|
import { ts } from '../../../ast/index.js';
|
|
3
3
|
import type { TypeScriptExportOutput } from '../../../common-results.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
@@ -24,6 +24,9 @@ export declare class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGe
|
|
|
24
24
|
protected getEndpointMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
25
25
|
protected getGetK6ParamsMethod(ctx: Context): ts.Method<Builder>;
|
|
26
26
|
protected getEndpointSuccessResponse(_ctx: Context, endpoint: ApiEndpoint): ApiResponse | undefined;
|
|
27
|
+
protected getDocDescription<T>(ctx: Context, component: ApiComponent<T> & {
|
|
28
|
+
description?: string;
|
|
29
|
+
}): BasicAppendValue<Builder>;
|
|
27
30
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, options?: TypeScriptImportOptions & {
|
|
28
31
|
fallback?: ts.Type<Builder>;
|
|
29
32
|
}): ts.Type<Builder>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,2BAA2B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC1E,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;CACnD;AAED,qBAAa,kCAAmC,SAAQ,uBAAuB,CAAC,OAAO,EAAE,MAAM,CAC7F,YAAW,2BAA2B;IACtB,QAAQ,CAAC,GAAG,EAAE,kCAAkC,GAAG,YAAY,CAAC,iCAAiC,CAAC;IA4BlH,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC;IAetF,SAAS,CAAC,2BAA2B,C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QAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;KAAE,GAClE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;IAMnB,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAI5C,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI3E,SAAS,CAAC,yBAAyB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIhF,SAAS,CAAC,2BAA2B,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAIlF,SAAS,CAAC,qBAAqB,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,MAAM;IAI5E,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAU3C,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQxD,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO;CAG3E"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
|
-
import { appendValueGroup, builderTemplate as s, getSourceDisplayName, toCasing, } from '@goast/core';
|
|
2
|
+
import { appendValueGroup, builderTemplate as s, getSourceDisplayName, notNullish, toCasing, } from '@goast/core';
|
|
3
3
|
import { ts } from '../../../ast/index.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
5
|
+
import { getSourceDocLine } from '../../../utils.js';
|
|
5
6
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
6
7
|
export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator {
|
|
7
8
|
generate(ctx) {
|
|
@@ -148,6 +149,7 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
148
149
|
.map((parameter) => {
|
|
149
150
|
const schema = parameter.schema;
|
|
150
151
|
return {
|
|
152
|
+
schema,
|
|
151
153
|
name: toCasing(parameter.name, ctx.config.propertyNameCasing),
|
|
152
154
|
type: schema
|
|
153
155
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
@@ -160,6 +162,7 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
160
162
|
const body = endpoint.requestBody;
|
|
161
163
|
const schema = body.content[0].schema;
|
|
162
164
|
properties.push({
|
|
165
|
+
schema,
|
|
163
166
|
name: 'body',
|
|
164
167
|
type: schema
|
|
165
168
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
@@ -185,7 +188,14 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
185
188
|
members: properties.map((p) => ts.property(p.name, {
|
|
186
189
|
type: p.type,
|
|
187
190
|
optional: !p.required,
|
|
188
|
-
doc: p.description
|
|
191
|
+
doc: p.description
|
|
192
|
+
? ts.doc({
|
|
193
|
+
description: [
|
|
194
|
+
p.description,
|
|
195
|
+
p.schema ? getSourceDocLine(p.schema) : null,
|
|
196
|
+
].filter(notNullish).join('\n\n'),
|
|
197
|
+
})
|
|
198
|
+
: undefined,
|
|
189
199
|
})),
|
|
190
200
|
}));
|
|
191
201
|
}
|
|
@@ -261,7 +271,7 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
261
271
|
],
|
|
262
272
|
returnType: isJs ? null : returnTypeWithPromise,
|
|
263
273
|
doc: ts.doc({
|
|
264
|
-
description:
|
|
274
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
265
275
|
tags: isJs
|
|
266
276
|
? [
|
|
267
277
|
hasParams ? ts.docTag('param', paramsOptional ? '[params]' : 'params', { type: paramsType }) : null,
|
|
@@ -332,6 +342,14 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator
|
|
|
332
342
|
var _a;
|
|
333
343
|
return ((_a = endpoint.responses.find((x) => x.statusCode && x.statusCode >= 200 && x.statusCode < 300)) !== null && _a !== void 0 ? _a : endpoint.responses.find((x) => x.statusCode === undefined));
|
|
334
344
|
}
|
|
345
|
+
getDocDescription(ctx, component) {
|
|
346
|
+
var _a;
|
|
347
|
+
const docSegments = [(_a = component.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
348
|
+
if (ctx.config.includeSourceInDocs) {
|
|
349
|
+
docSegments.push(getSourceDocLine(component));
|
|
350
|
+
}
|
|
351
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
352
|
+
}
|
|
335
353
|
getSchemaType(ctx, schema, options) {
|
|
336
354
|
var _a;
|
|
337
355
|
const output = schema && ctx.input.typescript.models[schema.id];
|
package/esm/src/utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Nullable } from '@goast/core';
|
|
1
|
+
import type { ApiComponent, Nullable } from '@goast/core';
|
|
2
2
|
export type ImportModuleTransformer = 'omit-extension' | 'with-extension' | 'js-extension' | ((module: string) => string);
|
|
3
3
|
export declare function toTypeScriptStringLiteral(value: string, useSingleQuotes: boolean): string;
|
|
4
4
|
export declare function toTypeScriptPropertyName(value: string, useSingleQuotes: boolean): string;
|
|
5
5
|
export declare function getModulePathRelativeToFile(from: string, to: string, transformer: ImportModuleTransformer): string;
|
|
6
6
|
export declare function getModulePathRelativeToDirectory(from: string, to: string, transformer: ImportModuleTransformer): string;
|
|
7
7
|
export declare function modifyString<TArgs extends unknown[]>(value: string, modifier: Nullable<string | RegExp | ((value: string, ...args: TArgs) => string)>, ...args: TArgs): string;
|
|
8
|
+
export declare function getSourceDocLine<T>(component: ApiComponent<T>): string;
|
|
8
9
|
//# sourceMappingURL=utils.d.ts.map
|
package/esm/src/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,uBAAuB,GAC/B,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAMjC,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAEzF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAKxF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,uBAAuB,GAAG,MAAM,CAElH;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,uBAAuB,GACnC,MAAM,CAER;AAoBD,wBAAgB,YAAY,CAAC,KAAK,SAAS,OAAO,EAAE,EAClD,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,EACjF,GAAG,IAAI,EAAE,KAAK,GACb,MAAM,CAYR;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,CAItE"}
|
package/esm/src/utils.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { dirname, relative } from 'node:path';
|
|
1
|
+
import path, { dirname, relative } from 'node:path';
|
|
2
|
+
import process from 'node:process';
|
|
2
3
|
function doubleQuotedToSingleQuoted(value) {
|
|
3
4
|
return `'${value.slice(1, -1).replace(/'/g, "\\'")}'`;
|
|
4
5
|
}
|
|
@@ -49,3 +50,8 @@ export function modifyString(value, modifier, ...args) {
|
|
|
49
50
|
}
|
|
50
51
|
return value;
|
|
51
52
|
}
|
|
53
|
+
export function getSourceDocLine(component) {
|
|
54
|
+
const file = path.relative(process.cwd(), component.$src.file);
|
|
55
|
+
const { line, col } = component.$src.pos;
|
|
56
|
+
return `Source: ${file}:${line}:${col} (${component.$src.path})`;
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goast/typescript",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Provides gOAst generators for generating TypeScript code from OpenAPI specifications.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Marc Schmidt (MaSch0212)",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"tslib": "^2.6.2",
|
|
27
27
|
"fs-extra": "^11.3.3",
|
|
28
|
-
"@goast/core": "0.5.
|
|
28
|
+
"@goast/core": "0.5.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.9.0",
|
package/script/src/config.d.ts
CHANGED
|
@@ -56,6 +56,11 @@ export type TypeScriptGeneratorConfig = OpenApiGeneratorConfig & {
|
|
|
56
56
|
* @default true
|
|
57
57
|
*/
|
|
58
58
|
useSingleQuotes: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether to include the source OpenAPI document path in the generated documentation comments.
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
includeSourceInDocs: boolean;
|
|
59
64
|
};
|
|
60
65
|
export declare const defaultTypeScriptGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptGeneratorConfig>;
|
|
61
66
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEjH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,GAAG;IAC/D;;;OAGG;IACH,uBAAuB,EAAE,uBAAuB,CAAC;IAEjD;;;OAGG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;;OAGG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;;OAGG;IACH,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,mBAAmB,EAAE,oBAAoB,CAAC;IAE1C;;;OAGG;IACH,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,sBAAsB,EAAE,oBAAoB,CAAC;IAE7C;;;OAGG;IACH,eAAe,EAAE,oBAAoB,CAAC;IAEtC;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAEjH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,yBAAyB,GAAG,sBAAsB,GAAG;IAC/D;;;OAGG;IACH,uBAAuB,EAAE,uBAAuB,CAAC;IAEjD;;;OAGG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;;OAGG;IACH,cAAc,EAAE,oBAAoB,CAAC;IAErC;;;OAGG;IACH,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,mBAAmB,EAAE,oBAAoB,CAAC;IAE1C;;;OAGG;IACH,kBAAkB,EAAE,oBAAoB,CAAC;IAEzC;;;OAGG;IACH,sBAAsB,EAAE,oBAAoB,CAAC;IAE7C;;;OAGG;IACH,eAAe,EAAE,oBAAoB,CAAC;IAEtC;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,+BAA+B,CAAC,yBAAyB,CAiBvG,CAAC"}
|
package/script/src/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiSchema, type AppendValueGroup, type ArrayLikeApiSchema, type CombinedLikeApiSchema, type MaybePromise, type Nullable, type ObjectLikeApiSchema, type StringLikeApiSchema } from '@goast/core';
|
|
1
|
+
import { type ApiSchema, type AppendValueGroup, type ArrayLikeApiSchema, type BasicAppendValue, type CombinedLikeApiSchema, type MaybePromise, type Nullable, type ObjectLikeApiSchema, type StringLikeApiSchema } from '@goast/core';
|
|
2
2
|
import { ts } from '../../ast/index.js';
|
|
3
3
|
import type { TypeScriptComponentOutputKind } from '../../common-results.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
@@ -31,6 +31,7 @@ export declare class DefaultTypeScriptModelGenerator extends TypeScriptFileGener
|
|
|
31
31
|
protected getCombinedType(ctx: Context, schema: CombinedLikeApiSchema): ts.Type<Builder>;
|
|
32
32
|
protected getOneOfType(ctx: Context, schema: ApiSchema<'oneOf'>): ts.Type<Builder>;
|
|
33
33
|
protected getMultiType(ctx: Context, schema: ApiSchema<'multi-type'>): ts.Type<Builder>;
|
|
34
|
+
protected getSchemaDocDescription(ctx: Context, schema: ApiSchema): BasicAppendValue<Builder>;
|
|
34
35
|
protected shouldGenerateTypeDeclaration(ctx: Context, schema: ApiSchema): boolean;
|
|
35
36
|
protected resolveInterfaceSchema(ctx: Context): ApiSchema<'object'> | undefined;
|
|
36
37
|
protected getDeclarationTypeName(ctx: Context, schema: ApiSchema): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAI1B,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-generator.d.ts","sourceRoot":"","sources":["../../../../src/src/generators/models/model-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,gBAAgB,EAErB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAI1B,KAAK,YAAY,EAEjB,KAAK,QAAQ,EACb,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EAEzB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACxC,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,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CAAC,IAAI,CAAC,OAAO,CAAC;IA2BvF,SAAS,CAAC,uBAAuB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAU7F,SAAS,CAAC,6BAA6B,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,OAAO;IAyCjF,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS;IAU/E,SAAS,CAAC,sBAAsB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAIzE,SAAS,CAAC,gCAAgC,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAInF,SAAS,CAAC,wBAAwB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAI3E,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;IAIlE,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAC,kBAAkB,CAAC;IAM7F,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,GAAG,MAAM;CAO/D"}
|
|
@@ -5,6 +5,7 @@ const node_path_1 = require("node:path");
|
|
|
5
5
|
const core_1 = require("@goast/core");
|
|
6
6
|
const index_js_1 = require("../../ast/index.js");
|
|
7
7
|
const file_builder_js_1 = require("../../file-builder.js");
|
|
8
|
+
const utils_js_1 = require("../../utils.js");
|
|
8
9
|
const file_generator_js_1 = require("../file-generator.js");
|
|
9
10
|
class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFileGenerator {
|
|
10
11
|
generate(ctx) {
|
|
@@ -87,7 +88,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
87
88
|
var _a, _b;
|
|
88
89
|
return index_js_1.ts.enum(this.getDeclarationTypeName(ctx, ctx.schema), {
|
|
89
90
|
doc: index_js_1.ts.doc({
|
|
90
|
-
description: ctx.schema
|
|
91
|
+
description: this.getSchemaDocDescription(ctx, ctx.schema),
|
|
91
92
|
tags: [ctx.schema.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
92
93
|
}),
|
|
93
94
|
export: true,
|
|
@@ -98,7 +99,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
98
99
|
return index_js_1.ts.interface(this.getDeclarationTypeName(ctx, ctx.schema), {
|
|
99
100
|
export: true,
|
|
100
101
|
doc: index_js_1.ts.doc({
|
|
101
|
-
description:
|
|
102
|
+
description: this.getSchemaDocDescription(ctx, schema),
|
|
102
103
|
tags: [ctx.schema.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
103
104
|
}),
|
|
104
105
|
members: [...this.getProperties(ctx, schema), this.getIndexer(ctx, schema)],
|
|
@@ -110,7 +111,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
110
111
|
const result = index_js_1.ts.typeAlias(this.getDeclarationTypeName(ctx, schema), (_a = (hasDiscriminator ? this.getDiscriminatorType(ctx, schema) : this.getType(ctx, schema, { skipSchemas: true }))) !== null && _a !== void 0 ? _a : this.getAnyType(ctx), {
|
|
111
112
|
export: true,
|
|
112
113
|
doc: index_js_1.ts.doc({
|
|
113
|
-
description:
|
|
114
|
+
description: this.getSchemaDocDescription(ctx, schema),
|
|
114
115
|
tags: [ctx.schema.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
115
116
|
}),
|
|
116
117
|
});
|
|
@@ -167,7 +168,7 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
167
168
|
return Array.from(schema.properties.values()).map((property) => {
|
|
168
169
|
return index_js_1.ts.property(property.name, {
|
|
169
170
|
doc: index_js_1.ts.doc({
|
|
170
|
-
description: property.schema
|
|
171
|
+
description: this.getSchemaDocDescription(ctx, property.schema),
|
|
171
172
|
tags: [property.schema.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
172
173
|
}),
|
|
173
174
|
readonly: ctx.config.immutableTypes,
|
|
@@ -313,6 +314,14 @@ class DefaultTypeScriptModelGenerator extends file_generator_js_1.TypeScriptFile
|
|
|
313
314
|
}
|
|
314
315
|
}));
|
|
315
316
|
}
|
|
317
|
+
getSchemaDocDescription(ctx, schema) {
|
|
318
|
+
var _a;
|
|
319
|
+
const docSegments = [(_a = schema.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
320
|
+
if (ctx.config.includeSourceInDocs) {
|
|
321
|
+
docSegments.push((0, utils_js_1.getSourceDocLine)(schema));
|
|
322
|
+
}
|
|
323
|
+
return docSegments.filter(core_1.notNullish).join('\n\n');
|
|
324
|
+
}
|
|
316
325
|
shouldGenerateTypeDeclaration(ctx, schema) {
|
|
317
326
|
var _a;
|
|
318
327
|
// All named schemas should have its own type declaration
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type MaybePromise } from '@goast/core';
|
|
1
|
+
import { type ApiComponent, type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type BasicAppendValue, type MaybePromise } from '@goast/core';
|
|
2
2
|
import { ts } from '../../../ast/index.js';
|
|
3
3
|
import type { TypeScriptExportOutput } from '../../../common-results.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
@@ -22,6 +22,9 @@ export declare class DefaultTypeScriptAngularServiceGenerator extends TypeScript
|
|
|
22
22
|
protected getEndpointParamsType(ctx: Context, endpoint: ApiEndpoint): ts.TypeAlias<Builder>;
|
|
23
23
|
protected getClass(ctx: Context): ts.Class<Builder>;
|
|
24
24
|
protected getEndpointMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
25
|
+
protected getDocDescription<T>(ctx: Context, component: ApiComponent<T> & {
|
|
26
|
+
description?: string;
|
|
27
|
+
}): BasicAppendValue<Builder>;
|
|
25
28
|
protected getEndpointRequestContentType(ctx: Context, endpoint: ApiEndpoint): string;
|
|
26
29
|
protected getEndpointSuccessResponseType(ctx: Context, endpoint: ApiEndpoint): string;
|
|
27
30
|
protected getEndpointSuccessResponse(_ctx: Context, endpoint: ApiEndpoint): ApiResponse | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angular-service-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/angular-services/angular-service-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"angular-service-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/angular-services/angular-service-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAIlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,wCAAwC,EAAE,uCAAuC,EAAE,MAAM,aAAa,CAAC;AAErH,KAAK,OAAO,GAAG,wCAAwC,CAAC;AACxD,KAAK,MAAM,GAAG,uCAAuC,CAAC;AACtD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,iCAAiC,CAAC,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1 = require("node:path");
|
|
|
5
5
|
const core_1 = require("@goast/core");
|
|
6
6
|
const index_js_1 = require("../../../ast/index.js");
|
|
7
7
|
const file_builder_js_1 = require("../../../file-builder.js");
|
|
8
|
+
const utils_js_1 = require("../../../utils.js");
|
|
8
9
|
const file_generator_js_1 = require("../../file-generator.js");
|
|
9
10
|
class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeScriptFileGenerator {
|
|
10
11
|
generate(ctx) {
|
|
@@ -144,7 +145,7 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeS
|
|
|
144
145
|
const schema = parameter.schema;
|
|
145
146
|
type.members.push(index_js_1.ts.property((0, core_1.toCasing)(parameter.name, ctx.config.propertyNameCasing), {
|
|
146
147
|
doc: index_js_1.ts.doc({
|
|
147
|
-
description:
|
|
148
|
+
description: this.getDocDescription(ctx, parameter),
|
|
148
149
|
tags: [parameter.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
149
150
|
}),
|
|
150
151
|
type: schema ? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id]) : this.getAnyType(ctx),
|
|
@@ -155,7 +156,7 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeS
|
|
|
155
156
|
const body = endpoint.requestBody;
|
|
156
157
|
const schema = body.content[0].schema;
|
|
157
158
|
type.members.push(index_js_1.ts.property('body', {
|
|
158
|
-
doc: index_js_1.ts.doc({ description:
|
|
159
|
+
doc: index_js_1.ts.doc({ description: this.getDocDescription(ctx, body) }),
|
|
159
160
|
type: schema ? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id]) : this.getAnyType(ctx),
|
|
160
161
|
optional: !body.required,
|
|
161
162
|
}));
|
|
@@ -212,7 +213,7 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeS
|
|
|
212
213
|
index_js_1.ts.parameter('context', { optional: true, type: index_js_1.ts.refs.angular.httpContext() }),
|
|
213
214
|
],
|
|
214
215
|
doc: index_js_1.ts.doc({
|
|
215
|
-
description:
|
|
216
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
216
217
|
tags: [endpoint.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
217
218
|
}),
|
|
218
219
|
returnType,
|
|
@@ -258,6 +259,14 @@ class DefaultTypeScriptAngularServiceGenerator extends file_generator_js_1.TypeS
|
|
|
258
259
|
], '\n'),
|
|
259
260
|
});
|
|
260
261
|
}
|
|
262
|
+
getDocDescription(ctx, component) {
|
|
263
|
+
var _a;
|
|
264
|
+
const docSegments = [(_a = component.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
265
|
+
if (ctx.config.includeSourceInDocs) {
|
|
266
|
+
docSegments.push((0, utils_js_1.getSourceDocLine)(component));
|
|
267
|
+
}
|
|
268
|
+
return docSegments.filter(core_1.notNullish).join('\n\n');
|
|
269
|
+
}
|
|
261
270
|
getEndpointRequestContentType(ctx, endpoint) {
|
|
262
271
|
var _a, _b, _c;
|
|
263
272
|
return (_c = (_a = ctx.config.defaultRequestContentType) !== null && _a !== void 0 ? _a : (_b = endpoint === null || endpoint === void 0 ? void 0 : endpoint.requestBody) === null || _b === void 0 ? void 0 : _b.content[0].type) !== null && _c !== void 0 ? _c : 'application/json';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiEndpoint, type ApiSchema, type AppendValueGroup, type MaybePromise } from '@goast/core';
|
|
1
|
+
import { type ApiComponent, type ApiEndpoint, type ApiSchema, type AppendValueGroup, type BasicAppendValue, type MaybePromise } from '@goast/core';
|
|
2
2
|
import { ts } from '../../../ast/index.js';
|
|
3
3
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
4
4
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
@@ -18,6 +18,9 @@ export declare class DefaultTypeScriptFetchClientGenerator extends TypeScriptFil
|
|
|
18
18
|
protected getDefaultOptionsConstant(ctx: Context): ts.Variable<Builder>;
|
|
19
19
|
protected getClass(ctx: Context): ts.Class<Builder>;
|
|
20
20
|
protected getServiceMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
21
|
+
protected getDocDescription<T>(ctx: Context, component: ApiComponent<T> & {
|
|
22
|
+
description?: string;
|
|
23
|
+
}): BasicAppendValue<Builder>;
|
|
21
24
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder>;
|
|
22
25
|
protected shouldGenerateInterface(ctx: Context): boolean;
|
|
23
26
|
protected shouldGenerateClass(ctx: Context): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/fetch-clients/fetch-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"fetch-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/fetch-clients/fetch-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,qCAAqC,EAAE,oCAAoC,EAAE,MAAM,aAAa,CAAC;AAE/G,KAAK,OAAO,GAAG,qCAAqC,CAAC;AACrD,KAAK,MAAM,GAAG,oCAAoC,CAAC;AACnD,KAAK,OAAO,GAAG,qBAAqB,CAAC;AAErC,MAAM,WAAW,8BAA8B,CAAC,OAAO,SAAS,MAAM,GAAG,MAAM;IAC7E,QAAQ,CAAC,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,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;IAMnH,SAAS,CAAC,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAIxD,SAAS,CAAC,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO;IAIpD,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAIhD,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAI5C,SAAS,CAAC,6BAA6B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAI7D,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQpD,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IAQhD,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI7D,OAAO,CAAC,iBAAiB;CAK1B"}
|
|
@@ -5,6 +5,7 @@ const node_path_1 = require("node:path");
|
|
|
5
5
|
const core_1 = require("@goast/core");
|
|
6
6
|
const index_js_1 = require("../../../ast/index.js");
|
|
7
7
|
const file_builder_js_1 = require("../../../file-builder.js");
|
|
8
|
+
const utils_js_1 = require("../../../utils.js");
|
|
8
9
|
const file_generator_js_1 = require("../../file-generator.js");
|
|
9
10
|
class DefaultTypeScriptFetchClientGenerator extends file_generator_js_1.TypeScriptFileGenerator {
|
|
10
11
|
generate(ctx) {
|
|
@@ -62,7 +63,10 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_js_1.TypeScri
|
|
|
62
63
|
const bodySchema = (_b = (_a = endpoint.requestBody) === null || _a === void 0 ? void 0 : _a.content[0]) === null || _b === void 0 ? void 0 : _b.schema;
|
|
63
64
|
const responseSchema = this.getResponseSchema(ctx, endpoint);
|
|
64
65
|
return index_js_1.ts.method((0, core_1.toCasing)(endpoint.name, ctx.config.functionNameCasing), {
|
|
65
|
-
doc: index_js_1.ts.doc({
|
|
66
|
+
doc: index_js_1.ts.doc({
|
|
67
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
68
|
+
tags: [endpoint.deprecated ? index_js_1.ts.docTag('deprecated') : null],
|
|
69
|
+
}),
|
|
66
70
|
parameters: [
|
|
67
71
|
params.length > 0
|
|
68
72
|
? index_js_1.ts.parameter('params', {
|
|
@@ -168,6 +172,14 @@ class DefaultTypeScriptFetchClientGenerator extends file_generator_js_1.TypeScri
|
|
|
168
172
|
return method;
|
|
169
173
|
}
|
|
170
174
|
// #endregion
|
|
175
|
+
getDocDescription(ctx, component) {
|
|
176
|
+
var _a;
|
|
177
|
+
const docSegments = [(_a = component.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
178
|
+
if (ctx.config.includeSourceInDocs) {
|
|
179
|
+
docSegments.push((0, utils_js_1.getSourceDocLine)(component));
|
|
180
|
+
}
|
|
181
|
+
return docSegments.filter(core_1.notNullish).join('\n\n');
|
|
182
|
+
}
|
|
171
183
|
getSchemaType(ctx, schema, fallback) {
|
|
172
184
|
const output = schema && ctx.input.typescript.models[schema.id];
|
|
173
185
|
if (!output)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type MaybePromise } from '@goast/core';
|
|
1
|
+
import { type ApiComponent, type ApiEndpoint, type ApiResponse, type ApiSchema, type AppendValueGroup, type BasicAppendValue, type MaybePromise } from '@goast/core';
|
|
2
2
|
import { ts } from '../../../ast/index.js';
|
|
3
3
|
import type { TypeScriptExportOutput } from '../../../common-results.js';
|
|
4
4
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
@@ -24,6 +24,9 @@ export declare class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGe
|
|
|
24
24
|
protected getEndpointMethod(ctx: Context, endpoint: ApiEndpoint): ts.Method<Builder>;
|
|
25
25
|
protected getGetK6ParamsMethod(ctx: Context): ts.Method<Builder>;
|
|
26
26
|
protected getEndpointSuccessResponse(_ctx: Context, endpoint: ApiEndpoint): ApiResponse | undefined;
|
|
27
|
+
protected getDocDescription<T>(ctx: Context, component: ApiComponent<T> & {
|
|
28
|
+
description?: string;
|
|
29
|
+
}): BasicAppendValue<Builder>;
|
|
27
30
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, options?: TypeScriptImportOptions & {
|
|
28
31
|
fallback?: ts.Type<Builder>;
|
|
29
32
|
}): ts.Type<Builder>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,
|
|
1
|
+
{"version":3,"file":"k6-client-generator.d.ts","sourceRoot":"","sources":["../../../../../src/src/generators/services/k6-clients/k6-client-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EAErB,KAAK,gBAAgB,EAGrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,EAAE,EAAE,MAAM,uBAAuB,CAAC;AAC3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAE7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,kCAAkC,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEzG,KAAK,OAAO,GAAG,kCAAkC,CAAC;AAClD,KAAK,MAAM,GAAG,iCAAiC,CAAC;AAChD,KAAK,OAAO,GA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("node:path");
|
|
|
5
5
|
const core_1 = require("@goast/core");
|
|
6
6
|
const index_js_1 = require("../../../ast/index.js");
|
|
7
7
|
const file_builder_js_1 = require("../../../file-builder.js");
|
|
8
|
+
const utils_js_1 = require("../../../utils.js");
|
|
8
9
|
const file_generator_js_1 = require("../../file-generator.js");
|
|
9
10
|
class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptFileGenerator {
|
|
10
11
|
generate(ctx) {
|
|
@@ -151,6 +152,7 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
151
152
|
.map((parameter) => {
|
|
152
153
|
const schema = parameter.schema;
|
|
153
154
|
return {
|
|
155
|
+
schema,
|
|
154
156
|
name: (0, core_1.toCasing)(parameter.name, ctx.config.propertyNameCasing),
|
|
155
157
|
type: schema
|
|
156
158
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
@@ -163,6 +165,7 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
163
165
|
const body = endpoint.requestBody;
|
|
164
166
|
const schema = body.content[0].schema;
|
|
165
167
|
properties.push({
|
|
168
|
+
schema,
|
|
166
169
|
name: 'body',
|
|
167
170
|
type: schema
|
|
168
171
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
@@ -188,7 +191,14 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
188
191
|
members: properties.map((p) => index_js_1.ts.property(p.name, {
|
|
189
192
|
type: p.type,
|
|
190
193
|
optional: !p.required,
|
|
191
|
-
doc: p.description
|
|
194
|
+
doc: p.description
|
|
195
|
+
? index_js_1.ts.doc({
|
|
196
|
+
description: [
|
|
197
|
+
p.description,
|
|
198
|
+
p.schema ? (0, utils_js_1.getSourceDocLine)(p.schema) : null,
|
|
199
|
+
].filter(core_1.notNullish).join('\n\n'),
|
|
200
|
+
})
|
|
201
|
+
: undefined,
|
|
192
202
|
})),
|
|
193
203
|
}));
|
|
194
204
|
}
|
|
@@ -264,7 +274,7 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
264
274
|
],
|
|
265
275
|
returnType: isJs ? null : returnTypeWithPromise,
|
|
266
276
|
doc: index_js_1.ts.doc({
|
|
267
|
-
description:
|
|
277
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
268
278
|
tags: isJs
|
|
269
279
|
? [
|
|
270
280
|
hasParams ? index_js_1.ts.docTag('param', paramsOptional ? '[params]' : 'params', { type: paramsType }) : null,
|
|
@@ -335,6 +345,14 @@ class DefaultTypeScriptK6ClientGenerator extends file_generator_js_1.TypeScriptF
|
|
|
335
345
|
var _a;
|
|
336
346
|
return ((_a = endpoint.responses.find((x) => x.statusCode && x.statusCode >= 200 && x.statusCode < 300)) !== null && _a !== void 0 ? _a : endpoint.responses.find((x) => x.statusCode === undefined));
|
|
337
347
|
}
|
|
348
|
+
getDocDescription(ctx, component) {
|
|
349
|
+
var _a;
|
|
350
|
+
const docSegments = [(_a = component.description) === null || _a === void 0 ? void 0 : _a.trim()];
|
|
351
|
+
if (ctx.config.includeSourceInDocs) {
|
|
352
|
+
docSegments.push((0, utils_js_1.getSourceDocLine)(component));
|
|
353
|
+
}
|
|
354
|
+
return docSegments.filter(core_1.notNullish).join('\n\n');
|
|
355
|
+
}
|
|
338
356
|
getSchemaType(ctx, schema, options) {
|
|
339
357
|
var _a;
|
|
340
358
|
const output = schema && ctx.input.typescript.models[schema.id];
|
package/script/src/utils.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Nullable } from '@goast/core';
|
|
1
|
+
import type { ApiComponent, Nullable } from '@goast/core';
|
|
2
2
|
export type ImportModuleTransformer = 'omit-extension' | 'with-extension' | 'js-extension' | ((module: string) => string);
|
|
3
3
|
export declare function toTypeScriptStringLiteral(value: string, useSingleQuotes: boolean): string;
|
|
4
4
|
export declare function toTypeScriptPropertyName(value: string, useSingleQuotes: boolean): string;
|
|
5
5
|
export declare function getModulePathRelativeToFile(from: string, to: string, transformer: ImportModuleTransformer): string;
|
|
6
6
|
export declare function getModulePathRelativeToDirectory(from: string, to: string, transformer: ImportModuleTransformer): string;
|
|
7
7
|
export declare function modifyString<TArgs extends unknown[]>(value: string, modifier: Nullable<string | RegExp | ((value: string, ...args: TArgs) => string)>, ...args: TArgs): string;
|
|
8
|
+
export declare function getSourceDocLine<T>(component: ApiComponent<T>): string;
|
|
8
9
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,MAAM,uBAAuB,GAC/B,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;AAMjC,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAEzF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,GAAG,MAAM,CAKxF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,uBAAuB,GAAG,MAAM,CAElH;AAED,wBAAgB,gCAAgC,CAC9C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,uBAAuB,GACnC,MAAM,CAER;AAoBD,wBAAgB,YAAY,CAAC,KAAK,SAAS,OAAO,EAAE,EAClD,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,EACjF,GAAG,IAAI,EAAE,KAAK,GACb,MAAM,CAYR;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,MAAM,CAItE"}
|
package/script/src/utils.js
CHANGED
|
@@ -5,7 +5,10 @@ exports.toTypeScriptPropertyName = toTypeScriptPropertyName;
|
|
|
5
5
|
exports.getModulePathRelativeToFile = getModulePathRelativeToFile;
|
|
6
6
|
exports.getModulePathRelativeToDirectory = getModulePathRelativeToDirectory;
|
|
7
7
|
exports.modifyString = modifyString;
|
|
8
|
-
|
|
8
|
+
exports.getSourceDocLine = getSourceDocLine;
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const node_path_1 = tslib_1.__importStar(require("node:path"));
|
|
11
|
+
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
9
12
|
function doubleQuotedToSingleQuoted(value) {
|
|
10
13
|
return `'${value.slice(1, -1).replace(/'/g, "\\'")}'`;
|
|
11
14
|
}
|
|
@@ -56,3 +59,8 @@ function modifyString(value, modifier, ...args) {
|
|
|
56
59
|
}
|
|
57
60
|
return value;
|
|
58
61
|
}
|
|
62
|
+
function getSourceDocLine(component) {
|
|
63
|
+
const file = node_path_1.default.relative(node_process_1.default.cwd(), component.$src.file);
|
|
64
|
+
const { line, col } = component.$src.pos;
|
|
65
|
+
return `Source: ${file}:${line}:${col} (${component.$src.path})`;
|
|
66
|
+
}
|
package/src/src/config.ts
CHANGED
|
@@ -68,6 +68,12 @@ export type TypeScriptGeneratorConfig = OpenApiGeneratorConfig & {
|
|
|
68
68
|
* @default true
|
|
69
69
|
*/
|
|
70
70
|
useSingleQuotes: boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Whether to include the source OpenAPI document path in the generated documentation comments.
|
|
74
|
+
* @default false
|
|
75
|
+
*/
|
|
76
|
+
includeSourceInDocs: boolean;
|
|
71
77
|
};
|
|
72
78
|
|
|
73
79
|
export const defaultTypeScriptGeneratorConfig: DefaultGenerationProviderConfig<TypeScriptGeneratorConfig> = {
|
|
@@ -86,4 +92,5 @@ export const defaultTypeScriptGeneratorConfig: DefaultGenerationProviderConfig<T
|
|
|
86
92
|
|
|
87
93
|
preferUnknown: true,
|
|
88
94
|
useSingleQuotes: true,
|
|
95
|
+
includeSourceInDocs: false,
|
|
89
96
|
};
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type AppendValueGroup,
|
|
7
7
|
appendValueGroup,
|
|
8
8
|
type ArrayLikeApiSchema,
|
|
9
|
+
type BasicAppendValue,
|
|
9
10
|
type CombinedLikeApiSchema,
|
|
10
11
|
DEFAULT_IGNORED_SCHEMA_PROPERTIES,
|
|
11
12
|
getSchemaReference,
|
|
@@ -22,6 +23,7 @@ import {
|
|
|
22
23
|
import { ts } from '../../ast/index.js';
|
|
23
24
|
import type { TypeScriptComponentOutputKind } from '../../common-results.js';
|
|
24
25
|
import { TypeScriptFileBuilder } from '../../file-builder.js';
|
|
26
|
+
import { getSourceDocLine } from '../../utils.js';
|
|
25
27
|
import { TypeScriptFileGenerator } from '../file-generator.js';
|
|
26
28
|
import type { TypeScriptModelGeneratorContext, TypeScriptModelGeneratorOutput } from './models.js';
|
|
27
29
|
|
|
@@ -128,7 +130,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator<Con
|
|
|
128
130
|
protected getEnum(ctx: Context): ts.Enum<Builder> {
|
|
129
131
|
return ts.enum(this.getDeclarationTypeName(ctx, ctx.schema), {
|
|
130
132
|
doc: ts.doc({
|
|
131
|
-
description: ctx.schema
|
|
133
|
+
description: this.getSchemaDocDescription(ctx, ctx.schema),
|
|
132
134
|
tags: [ctx.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
133
135
|
}),
|
|
134
136
|
export: true,
|
|
@@ -142,7 +144,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator<Con
|
|
|
142
144
|
return ts.interface(this.getDeclarationTypeName(ctx, ctx.schema), {
|
|
143
145
|
export: true,
|
|
144
146
|
doc: ts.doc({
|
|
145
|
-
description:
|
|
147
|
+
description: this.getSchemaDocDescription(ctx, schema as ApiSchema),
|
|
146
148
|
tags: [ctx.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
147
149
|
}),
|
|
148
150
|
members: [...this.getProperties(ctx, schema), this.getIndexer(ctx, schema)],
|
|
@@ -158,7 +160,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator<Con
|
|
|
158
160
|
{
|
|
159
161
|
export: true,
|
|
160
162
|
doc: ts.doc({
|
|
161
|
-
description:
|
|
163
|
+
description: this.getSchemaDocDescription(ctx, schema),
|
|
162
164
|
tags: [ctx.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
163
165
|
}),
|
|
164
166
|
},
|
|
@@ -228,7 +230,7 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator<Con
|
|
|
228
230
|
return Array.from(schema.properties.values()).map((property) => {
|
|
229
231
|
return ts.property(property.name, {
|
|
230
232
|
doc: ts.doc({
|
|
231
|
-
description: property.schema
|
|
233
|
+
description: this.getSchemaDocDescription(ctx, property.schema),
|
|
232
234
|
tags: [property.schema.deprecated ? ts.docTag('deprecated') : null],
|
|
233
235
|
}),
|
|
234
236
|
readonly: ctx.config.immutableTypes,
|
|
@@ -398,6 +400,16 @@ export class DefaultTypeScriptModelGenerator extends TypeScriptFileGenerator<Con
|
|
|
398
400
|
);
|
|
399
401
|
}
|
|
400
402
|
|
|
403
|
+
protected getSchemaDocDescription(ctx: Context, schema: ApiSchema): BasicAppendValue<Builder> {
|
|
404
|
+
const docSegments = [schema.description?.trim()];
|
|
405
|
+
|
|
406
|
+
if (ctx.config.includeSourceInDocs) {
|
|
407
|
+
docSegments.push(getSourceDocLine(schema));
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
411
|
+
}
|
|
412
|
+
|
|
401
413
|
protected shouldGenerateTypeDeclaration(ctx: Context, schema: ApiSchema): boolean {
|
|
402
414
|
// All named schemas should have its own type declaration
|
|
403
415
|
if (!schema.isNameGenerated) {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type ApiComponent,
|
|
4
5
|
type ApiEndpoint,
|
|
5
6
|
type ApiResponse,
|
|
6
7
|
type ApiSchema,
|
|
7
8
|
type AppendValueGroup,
|
|
8
9
|
appendValueGroup,
|
|
10
|
+
type BasicAppendValue,
|
|
9
11
|
builderTemplate as s,
|
|
10
12
|
getSourceDisplayName,
|
|
11
13
|
type MaybePromise,
|
|
14
|
+
notNullish,
|
|
12
15
|
type Nullable,
|
|
13
16
|
toCasing,
|
|
14
17
|
} from '@goast/core';
|
|
@@ -16,6 +19,7 @@ import {
|
|
|
16
19
|
import { ts } from '../../../ast/index.js';
|
|
17
20
|
import type { TypeScriptExportOutput } from '../../../common-results.js';
|
|
18
21
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
22
|
+
import { getSourceDocLine } from '../../../utils.js';
|
|
19
23
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
20
24
|
import type { TypeScriptAngularServiceGeneratorContext, TypeScriptAngularServiceGeneratorOutput } from './models.js';
|
|
21
25
|
|
|
@@ -185,7 +189,7 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
185
189
|
type.members.push(
|
|
186
190
|
ts.property(toCasing(parameter.name, ctx.config.propertyNameCasing), {
|
|
187
191
|
doc: ts.doc({
|
|
188
|
-
description:
|
|
192
|
+
description: this.getDocDescription(ctx, parameter),
|
|
189
193
|
tags: [parameter.deprecated ? ts.docTag('deprecated') : null],
|
|
190
194
|
}),
|
|
191
195
|
type: schema ? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id]) : this.getAnyType(ctx),
|
|
@@ -199,7 +203,7 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
199
203
|
const schema = body.content[0].schema;
|
|
200
204
|
type.members.push(
|
|
201
205
|
ts.property('body', {
|
|
202
|
-
doc: ts.doc({ description:
|
|
206
|
+
doc: ts.doc({ description: this.getDocDescription(ctx, body) }),
|
|
203
207
|
type: schema ? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id]) : this.getAnyType(ctx),
|
|
204
208
|
optional: !body.required,
|
|
205
209
|
}),
|
|
@@ -268,7 +272,7 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
268
272
|
ts.parameter('context', { optional: true, type: ts.refs.angular.httpContext() }),
|
|
269
273
|
],
|
|
270
274
|
doc: ts.doc({
|
|
271
|
-
description:
|
|
275
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
272
276
|
tags: [endpoint.deprecated ? ts.docTag('deprecated') : null],
|
|
273
277
|
}),
|
|
274
278
|
returnType,
|
|
@@ -338,6 +342,19 @@ export class DefaultTypeScriptAngularServiceGenerator extends TypeScriptFileGene
|
|
|
338
342
|
});
|
|
339
343
|
}
|
|
340
344
|
|
|
345
|
+
protected getDocDescription<T>(
|
|
346
|
+
ctx: Context,
|
|
347
|
+
component: ApiComponent<T> & { description?: string },
|
|
348
|
+
): BasicAppendValue<Builder> {
|
|
349
|
+
const docSegments = [component.description?.trim()];
|
|
350
|
+
|
|
351
|
+
if (ctx.config.includeSourceInDocs) {
|
|
352
|
+
docSegments.push(getSourceDocLine(component));
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
356
|
+
}
|
|
357
|
+
|
|
341
358
|
protected getEndpointRequestContentType(ctx: Context, endpoint: ApiEndpoint): string {
|
|
342
359
|
return ctx.config.defaultRequestContentType ?? endpoint?.requestBody?.content[0].type ?? 'application/json';
|
|
343
360
|
}
|
|
@@ -213,7 +213,7 @@ export class TypeScriptAngularServicesGenerator extends OpenApiServicesGeneratio
|
|
|
213
213
|
returnType: ts.refs.angular.provider(),
|
|
214
214
|
body: appendValueGroup([
|
|
215
215
|
'return ',
|
|
216
|
-
ts.tuple([
|
|
216
|
+
ts.tuple<TypeScriptFileBuilder>([
|
|
217
217
|
(b) =>
|
|
218
218
|
b.append(
|
|
219
219
|
'config ? { provide: ',
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type ApiComponent,
|
|
4
5
|
type ApiEndpoint,
|
|
5
6
|
type ApiSchema,
|
|
6
7
|
type AppendValueGroup,
|
|
7
8
|
appendValueGroup,
|
|
9
|
+
type BasicAppendValue,
|
|
8
10
|
builderTemplate as s,
|
|
9
11
|
getSourceDisplayName,
|
|
10
12
|
type MaybePromise,
|
|
13
|
+
notNullish,
|
|
11
14
|
toCasing,
|
|
12
15
|
} from '@goast/core';
|
|
13
16
|
|
|
14
17
|
import { ts } from '../../../ast/index.js';
|
|
15
18
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
19
|
+
import { getSourceDocLine } from '../../../utils.js';
|
|
16
20
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
17
21
|
import type { TypeScriptFetchClientGeneratorContext, TypeScriptFetchClientGeneratorOutput } from './models.js';
|
|
18
22
|
|
|
@@ -96,7 +100,10 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
|
|
|
96
100
|
const bodySchema = endpoint.requestBody?.content[0]?.schema;
|
|
97
101
|
const responseSchema = this.getResponseSchema(ctx, endpoint);
|
|
98
102
|
return ts.method(toCasing(endpoint.name, ctx.config.functionNameCasing), {
|
|
99
|
-
doc: ts.doc({
|
|
103
|
+
doc: ts.doc({
|
|
104
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
105
|
+
tags: [endpoint.deprecated ? ts.docTag('deprecated') : null],
|
|
106
|
+
}),
|
|
100
107
|
parameters: [
|
|
101
108
|
params.length > 0
|
|
102
109
|
? ts.parameter('params', {
|
|
@@ -231,6 +238,19 @@ export class DefaultTypeScriptFetchClientGenerator extends TypeScriptFileGenerat
|
|
|
231
238
|
}
|
|
232
239
|
// #endregion
|
|
233
240
|
|
|
241
|
+
protected getDocDescription<T>(
|
|
242
|
+
ctx: Context,
|
|
243
|
+
component: ApiComponent<T> & { description?: string },
|
|
244
|
+
): BasicAppendValue<Builder> {
|
|
245
|
+
const docSegments = [component.description?.trim()];
|
|
246
|
+
|
|
247
|
+
if (ctx.config.includeSourceInDocs) {
|
|
248
|
+
docSegments.push(getSourceDocLine(component));
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
252
|
+
}
|
|
253
|
+
|
|
234
254
|
protected getSchemaType(ctx: Context, schema: ApiSchema | undefined, fallback?: ts.Type<Builder>): ts.Type<Builder> {
|
|
235
255
|
const output = schema && ctx.input.typescript.models[schema.id];
|
|
236
256
|
if (!output) return fallback ?? this.getAnyType(ctx);
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { resolve } from 'node:path';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
type ApiComponent,
|
|
4
5
|
type ApiEndpoint,
|
|
5
6
|
type ApiResponse,
|
|
6
7
|
type ApiSchema,
|
|
7
8
|
type AppendValueGroup,
|
|
8
9
|
appendValueGroup,
|
|
10
|
+
type BasicAppendValue,
|
|
9
11
|
builderTemplate as s,
|
|
10
12
|
getSourceDisplayName,
|
|
11
13
|
type MaybePromise,
|
|
14
|
+
notNullish,
|
|
12
15
|
toCasing,
|
|
13
16
|
} from '@goast/core';
|
|
14
17
|
|
|
@@ -16,6 +19,7 @@ import { ts } from '../../../ast/index.js';
|
|
|
16
19
|
import type { TypeScriptExportOutput } from '../../../common-results.js';
|
|
17
20
|
import { TypeScriptFileBuilder } from '../../../file-builder.js';
|
|
18
21
|
import type { TypeScriptImportOptions } from '../../../import-collection.js';
|
|
22
|
+
import { getSourceDocLine } from '../../../utils.js';
|
|
19
23
|
import { TypeScriptFileGenerator } from '../../file-generator.js';
|
|
20
24
|
import type { TypeScriptK6ClientGeneratorContext, TypeScriptK6ClientGeneratorOutput } from './models.js';
|
|
21
25
|
|
|
@@ -189,24 +193,31 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator<
|
|
|
189
193
|
const importOptions: TypeScriptImportOptions = ctx.config.language === 'javascript' ? { type: 'js-doc' } : {};
|
|
190
194
|
const description = `Parameters for operation ${this.getEndpointMethodName(ctx, endpoint)}`;
|
|
191
195
|
const typeName = this.getEndpointParamsTypeName(ctx, endpoint);
|
|
192
|
-
const properties: {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
196
|
+
const properties: {
|
|
197
|
+
schema?: ApiSchema;
|
|
198
|
+
name: string;
|
|
199
|
+
type: ts.Type<Builder>;
|
|
200
|
+
description: string | undefined;
|
|
201
|
+
required: boolean;
|
|
202
|
+
}[] = endpoint.parameters
|
|
203
|
+
.map((parameter) => {
|
|
204
|
+
const schema = parameter.schema;
|
|
205
|
+
return {
|
|
206
|
+
schema,
|
|
207
|
+
name: toCasing(parameter.name, ctx.config.propertyNameCasing),
|
|
208
|
+
type: schema
|
|
209
|
+
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
210
|
+
: this.getAnyType(ctx),
|
|
211
|
+
description: (parameter.deprecated ? 'Deprecated: ' : '') + parameter.description,
|
|
212
|
+
required: parameter.required,
|
|
213
|
+
};
|
|
214
|
+
});
|
|
205
215
|
|
|
206
216
|
if (endpoint.requestBody !== undefined) {
|
|
207
217
|
const body = endpoint.requestBody;
|
|
208
218
|
const schema = body.content[0].schema;
|
|
209
219
|
properties.push({
|
|
220
|
+
schema,
|
|
210
221
|
name: 'body',
|
|
211
222
|
type: schema
|
|
212
223
|
? (b) => b.appendModelUsage(ctx.input.typescript.models[schema.id], importOptions)
|
|
@@ -237,7 +248,14 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator<
|
|
|
237
248
|
ts.property(p.name, {
|
|
238
249
|
type: p.type,
|
|
239
250
|
optional: !p.required,
|
|
240
|
-
doc: p.description
|
|
251
|
+
doc: p.description
|
|
252
|
+
? ts.doc({
|
|
253
|
+
description: [
|
|
254
|
+
p.description,
|
|
255
|
+
p.schema ? getSourceDocLine(p.schema) : null,
|
|
256
|
+
].filter(notNullish).join('\n\n'),
|
|
257
|
+
})
|
|
258
|
+
: undefined,
|
|
241
259
|
})
|
|
242
260
|
),
|
|
243
261
|
}),
|
|
@@ -326,7 +344,7 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator<
|
|
|
326
344
|
],
|
|
327
345
|
returnType: isJs ? null : returnTypeWithPromise,
|
|
328
346
|
doc: ts.doc({
|
|
329
|
-
description:
|
|
347
|
+
description: this.getDocDescription(ctx, endpoint),
|
|
330
348
|
tags: isJs
|
|
331
349
|
? [
|
|
332
350
|
hasParams ? ts.docTag('param', paramsOptional ? '[params]' : 'params', { type: paramsType }) : null,
|
|
@@ -420,6 +438,19 @@ export class DefaultTypeScriptK6ClientGenerator extends TypeScriptFileGenerator<
|
|
|
420
438
|
);
|
|
421
439
|
}
|
|
422
440
|
|
|
441
|
+
protected getDocDescription<T>(
|
|
442
|
+
ctx: Context,
|
|
443
|
+
component: ApiComponent<T> & { description?: string },
|
|
444
|
+
): BasicAppendValue<Builder> {
|
|
445
|
+
const docSegments = [component.description?.trim()];
|
|
446
|
+
|
|
447
|
+
if (ctx.config.includeSourceInDocs) {
|
|
448
|
+
docSegments.push(getSourceDocLine(component));
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return docSegments.filter(notNullish).join('\n\n');
|
|
452
|
+
}
|
|
453
|
+
|
|
423
454
|
protected getSchemaType(
|
|
424
455
|
ctx: Context,
|
|
425
456
|
schema: ApiSchema | undefined,
|
package/src/src/utils.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { dirname, relative } from 'node:path';
|
|
1
|
+
import path, { dirname, relative } from 'node:path';
|
|
2
2
|
|
|
3
|
-
import type { Nullable } from '@goast/core';
|
|
3
|
+
import type { ApiComponent, Nullable } from '@goast/core';
|
|
4
|
+
import process from 'node:process';
|
|
4
5
|
|
|
5
6
|
export type ImportModuleTransformer =
|
|
6
7
|
| 'omit-extension'
|
|
@@ -70,3 +71,9 @@ export function modifyString<TArgs extends unknown[]>(
|
|
|
70
71
|
}
|
|
71
72
|
return value;
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
export function getSourceDocLine<T>(component: ApiComponent<T>): string {
|
|
76
|
+
const file = path.relative(process.cwd(), component.$src.file);
|
|
77
|
+
const { line, col } = component.$src.pos;
|
|
78
|
+
return `Source: ${file}:${line}:${col} (${component.$src.path})`;
|
|
79
|
+
}
|