@azure-tools/typespec-java 0.8.10 → 0.8.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/dist/src/code-model-builder.d.ts +3 -0
- package/dist/src/code-model-builder.d.ts.map +1 -1
- package/dist/src/code-model-builder.js +131 -57
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/common/operation.d.ts +3 -1
- package/dist/src/common/operation.d.ts.map +1 -1
- package/dist/src/common/operation.js.map +1 -1
- package/dist/src/common/schemas/usage.d.ts +4 -2
- package/dist/src/common/schemas/usage.d.ts.map +1 -1
- package/dist/src/common/schemas/usage.js +4 -2
- package/dist/src/common/schemas/usage.js.map +1 -1
- package/dist/src/operation-utils.d.ts.map +1 -1
- package/dist/src/operation-utils.js +14 -6
- package/dist/src/operation-utils.js.map +1 -1
- package/dist/src/type-utils.d.ts +7 -2
- package/dist/src/type-utils.d.ts.map +1 -1
- package/dist/src/type-utils.js +93 -1
- package/dist/src/type-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/target/azure-typespec-extension-jar-with-dependencies.jar +0 -0
|
@@ -17,7 +17,10 @@ export declare class CodeModelBuilder {
|
|
|
17
17
|
build(): Promise<CodeModel>;
|
|
18
18
|
private processHost;
|
|
19
19
|
private processAuth;
|
|
20
|
+
private isInternal;
|
|
20
21
|
private processModels;
|
|
22
|
+
private processSchemaUsage;
|
|
23
|
+
private resolveSchemaUsage;
|
|
21
24
|
private processClients;
|
|
22
25
|
private needToSkipProcessingOperation;
|
|
23
26
|
private processOperation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-model-builder.d.ts","sourceRoot":"","sources":["../../src/code-model-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAoBL,OAAO,EAGP,IAAI,EAEJ,KAAK,EASL,WAAW,EAOZ,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file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IAIlB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAK/B;IAED,OAAO,CAAC,cAAc,CAAC,CAAe;IACtC,IAAI,aAAa,IAAI,YAAY,CAOhC;IAED,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,IAAI,aAAa,IAAI,aAAa,CAKjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,IAAI,SAAS,IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,iBAAiB,CAAC,CAAe;IACzC,IAAI,gBAAgB,IAAI,YAAY,CAKnC;IAED,OAAO,CAAC,yBAAyB;IA0BjC,OAAO,CAAC,oBAAoB,CAAC,CAAY;IACzC,IAAI,mBAAmB,IAAI,SAAS,CAKnC;IAED,OAAO,CAAC,0BAA0B,CAAC,CAAY;IAC/C,IAAI,yBAAyB,IAAI,SAAS,CAMzC;IAED,OAAO,CAAC,oBAAoB;IA+D5B,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,kBAAkB;CAiB3B"}
|
|
@@ -3,7 +3,7 @@ import { getResourceOperation, getSegment } from "@typespec/rest";
|
|
|
3
3
|
import { getAuthentication, getServers, getStatusCodeDescription, getHttpOperation, getQueryParamOptions, getHeaderFieldOptions, } from "@typespec/http";
|
|
4
4
|
import { getAddedOnVersions, getVersion } from "@typespec/versioning";
|
|
5
5
|
import { isPollingLocation, getPagedResult, isFixed, getLroMetadata } from "@azure-tools/typespec-azure-core";
|
|
6
|
-
import { listClients, listOperationGroups, listOperationsInOperationGroup, isApiVersion, shouldGenerateConvenient, createSdkContext, shouldGenerateProtocol, isInternal,
|
|
6
|
+
import { listClients, listOperationGroups, listOperationsInOperationGroup, isApiVersion, shouldGenerateConvenient, createSdkContext, shouldGenerateProtocol, isInternal, } from "@azure-tools/typespec-client-generator-core";
|
|
7
7
|
import { fail } from "assert";
|
|
8
8
|
import { AnySchema, ArraySchema, BinaryResponse, BinarySchema, BooleanSchema, ByteArraySchema, ChoiceValue, DateTimeSchema, DateSchema, DictionarySchema, Discriminator, HttpHeader, HttpParameter, ImplementationLocation, NumberSchema, ObjectSchema, Parameter, ParameterLocation, Property, Relations, Response, SchemaResponse, SchemaType, StringSchema, TimeSchema, Security, OAuth2SecurityScheme, KeySecurityScheme, OperationGroup, UriSchema, VirtualParameter, GroupSchema, GroupProperty, ApiVersion, SerializationStyle, Metadata, UnixTimeSchema, Language, } from "@autorest/codemodel";
|
|
9
9
|
import { CodeModel } from "./common/code-model.js";
|
|
@@ -19,7 +19,7 @@ import { PreNamer } from "./prenamer/prenamer.js";
|
|
|
19
19
|
import { createPollResultSchema } from "./external-schemas.js";
|
|
20
20
|
import { ClientContext } from "./models.js";
|
|
21
21
|
import { stringArrayContainsIgnoreCase, getJavaNamespace, getNamespace, pascalCase, logWarning, trace, } from "./utils.js";
|
|
22
|
-
import { ProcessingCache, isModelReferredInTemplate, pushDistinct, modelContainsDerivedModel, getNameForTemplate, getDurationFormat, hasScalarAsBase, isNullableType, isSameLiteralTypes, } from "./type-utils.js";
|
|
22
|
+
import { ProcessingCache, isModelReferredInTemplate, pushDistinct, modelContainsDerivedModel, getNameForTemplate, getDurationFormat, hasScalarAsBase, isNullableType, isSameLiteralTypes, getAccess, getUsage, unionReferredByType, getUnionName, modelIs, } from "./type-utils.js";
|
|
23
23
|
import { getClientApiVersions, getServiceVersion, operationIsJsonMergePatch, isPayloadProperty, originApiVersion, specialHeaderNames, loadExamples, isLroNewPollingStrategy, operationIsMultipleContentTypes, cloneOperationParameter, operationRefersUnion, } from "./operation-utils.js";
|
|
24
24
|
import pkg from "lodash";
|
|
25
25
|
const { isEqual } = pkg;
|
|
@@ -78,12 +78,10 @@ export class CodeModelBuilder {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
async build() {
|
|
81
|
-
var _a;
|
|
82
81
|
this.operationExamples = await loadExamples(this.program, this.options);
|
|
83
|
-
this.processClients();
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(_a = this.codeModel.schemas.objects) === null || _a === void 0 ? void 0 : _a.forEach((it) => this.propagateSchemaUsage(it));
|
|
82
|
+
const clients = this.processClients();
|
|
83
|
+
this.processModels(clients);
|
|
84
|
+
this.processSchemaUsage();
|
|
87
85
|
if (this.options.namer) {
|
|
88
86
|
this.codeModel = new PreNamer(this.codeModel).init().process();
|
|
89
87
|
}
|
|
@@ -100,7 +98,7 @@ export class CodeModelBuilder {
|
|
|
100
98
|
else {
|
|
101
99
|
const schema = this.processSchema(it.type, it.name);
|
|
102
100
|
this.trackSchemaUsage(schema, {
|
|
103
|
-
usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.
|
|
101
|
+
usage: [SchemaContext.Input, SchemaContext.Output /*SchemaContext.Public*/],
|
|
104
102
|
});
|
|
105
103
|
parameter = new Parameter(it.name, this.getDoc(it), schema, {
|
|
106
104
|
implementation: ImplementationLocation.Client,
|
|
@@ -190,20 +188,79 @@ export class CodeModelBuilder {
|
|
|
190
188
|
});
|
|
191
189
|
}
|
|
192
190
|
}
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
191
|
+
isInternal(context, operation) {
|
|
192
|
+
const access = getAccess(operation);
|
|
193
|
+
if (access) {
|
|
194
|
+
return access === "internal";
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
// fallback to "internal", it will be
|
|
198
|
+
return isInternal(context, operation);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
processModels(clients) {
|
|
202
|
+
const processedModels = new Set();
|
|
203
|
+
for (const client of clients) {
|
|
204
|
+
const models = Array.from(client.service.models.values());
|
|
205
|
+
Array.from(client.service.enums.values()).forEach((it) => models.push(it));
|
|
206
|
+
for (const model of models) {
|
|
207
|
+
if (!processedModels.has(model)) {
|
|
208
|
+
const access = getAccess(model);
|
|
209
|
+
if (access === "public") {
|
|
210
|
+
// check it does not contain Union
|
|
211
|
+
const union = unionReferredByType(this.program, model, this.typeUnionRefCache);
|
|
212
|
+
if (union) {
|
|
213
|
+
const errorMsg = `Model '${getTypeName(model, this.typeNameOptions)}' cannot be set as access=public, as it refers Union '${getUnionName(union, this.typeNameOptions)}'`;
|
|
214
|
+
throw new Error(errorMsg);
|
|
215
|
+
}
|
|
216
|
+
const schema = this.processSchema(model, model.name);
|
|
217
|
+
this.trackSchemaUsage(schema, {
|
|
218
|
+
usage: [SchemaContext.Public],
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else if (access === "internal") {
|
|
222
|
+
const schema = this.processSchema(model, model.name);
|
|
223
|
+
this.trackSchemaUsage(schema, {
|
|
224
|
+
usage: [SchemaContext.Internal],
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
const usage = getUsage(model);
|
|
228
|
+
if (usage) {
|
|
229
|
+
const schema = this.processSchema(model, model.name);
|
|
230
|
+
this.trackSchemaUsage(schema, {
|
|
231
|
+
usage: usage,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
processedModels.add(model);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
processSchemaUsage() {
|
|
240
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
241
|
+
(_a = this.codeModel.schemas.objects) === null || _a === void 0 ? void 0 : _a.forEach((it) => this.propagateSchemaUsage(it));
|
|
242
|
+
// post process for schema usage
|
|
243
|
+
(_b = this.codeModel.schemas.objects) === null || _b === void 0 ? void 0 : _b.forEach((it) => this.resolveSchemaUsage(it));
|
|
244
|
+
(_c = this.codeModel.schemas.groups) === null || _c === void 0 ? void 0 : _c.forEach((it) => this.resolveSchemaUsage(it));
|
|
245
|
+
(_d = this.codeModel.schemas.choices) === null || _d === void 0 ? void 0 : _d.forEach((it) => this.resolveSchemaUsage(it));
|
|
246
|
+
(_e = this.codeModel.schemas.sealedChoices) === null || _e === void 0 ? void 0 : _e.forEach((it) => this.resolveSchemaUsage(it));
|
|
247
|
+
(_f = this.codeModel.schemas.ors) === null || _f === void 0 ? void 0 : _f.forEach((it) => this.resolveSchemaUsage(it));
|
|
248
|
+
(_g = this.codeModel.schemas.constants) === null || _g === void 0 ? void 0 : _g.forEach((it) => this.resolveSchemaUsage(it));
|
|
249
|
+
}
|
|
250
|
+
resolveSchemaUsage(schema) {
|
|
251
|
+
if (schema instanceof ObjectSchema ||
|
|
252
|
+
schema instanceof GroupSchema ||
|
|
253
|
+
schema instanceof ChoiceSchema ||
|
|
254
|
+
schema instanceof SealedChoiceSchema ||
|
|
255
|
+
schema instanceof OrSchema ||
|
|
256
|
+
schema instanceof ConstantSchema) {
|
|
257
|
+
const schemaUsage = schema.usage;
|
|
258
|
+
// Public override Internal
|
|
259
|
+
if (schemaUsage === null || schemaUsage === void 0 ? void 0 : schemaUsage.includes(SchemaContext.Public)) {
|
|
260
|
+
const index = schemaUsage.indexOf(SchemaContext.Internal);
|
|
261
|
+
if (index >= 0) {
|
|
262
|
+
schemaUsage.splice(index, 1);
|
|
203
263
|
}
|
|
204
|
-
this.trackSchemaUsage(schema, {
|
|
205
|
-
usage: [SchemaContext.ConvenienceApi],
|
|
206
|
-
});
|
|
207
264
|
}
|
|
208
265
|
}
|
|
209
266
|
}
|
|
@@ -307,6 +364,7 @@ export class CodeModelBuilder {
|
|
|
307
364
|
}
|
|
308
365
|
}
|
|
309
366
|
}
|
|
367
|
+
return clients;
|
|
310
368
|
}
|
|
311
369
|
needToSkipProcessingOperation(operation, clientContext) {
|
|
312
370
|
// don't generate protocol and convenience method for overloaded operations
|
|
@@ -337,8 +395,11 @@ export class CodeModelBuilder {
|
|
|
337
395
|
: undefined,
|
|
338
396
|
},
|
|
339
397
|
});
|
|
398
|
+
// TODO (weidxu): temporary disable codeModelOperation.internalApi
|
|
399
|
+
// codeModelOperation.internalApi = this.isInternal(this.sdkContext, operation);
|
|
400
|
+
const internalApi = this.isInternal(this.sdkContext, operation);
|
|
340
401
|
const convenienceApiName = this.getConvenienceApiName(operation);
|
|
341
|
-
let generateConvenienceApi = !!convenienceApiName && !
|
|
402
|
+
let generateConvenienceApi = !!convenienceApiName && !internalApi; // at present, internalApi means not convenienceApi. this could change.
|
|
342
403
|
let apiComment = undefined;
|
|
343
404
|
if (generateConvenienceApi) {
|
|
344
405
|
// check if the convenience API need to be disabled for some special cases
|
|
@@ -359,19 +420,8 @@ export class CodeModelBuilder {
|
|
|
359
420
|
const union = operationRefersUnion(this.program, op, this.typeUnionRefCache);
|
|
360
421
|
if (union) {
|
|
361
422
|
// and Union
|
|
362
|
-
const getUnionName = (union) => {
|
|
363
|
-
let name = union.name;
|
|
364
|
-
if (!name) {
|
|
365
|
-
const names = [];
|
|
366
|
-
union.variants.forEach((it) => {
|
|
367
|
-
names.push(getTypeName(it.type, this.typeNameOptions));
|
|
368
|
-
});
|
|
369
|
-
name = names.join(" | ");
|
|
370
|
-
}
|
|
371
|
-
return name;
|
|
372
|
-
};
|
|
373
423
|
generateConvenienceApi = false;
|
|
374
|
-
apiComment = `Convenience API is not generated, as operation '${op.operation.name}' refers Union '${getUnionName(union)}'`;
|
|
424
|
+
apiComment = `Convenience API is not generated, as operation '${op.operation.name}' refers Union '${getUnionName(union, this.typeNameOptions)}'`;
|
|
375
425
|
this.logWarning(apiComment);
|
|
376
426
|
}
|
|
377
427
|
}
|
|
@@ -385,7 +435,7 @@ export class CodeModelBuilder {
|
|
|
385
435
|
}
|
|
386
436
|
// check for generating protocol api or not
|
|
387
437
|
codeModelOperation.generateProtocolApi =
|
|
388
|
-
shouldGenerateProtocol(this.sdkContext, operation) && !isInternal(this.sdkContext, operation);
|
|
438
|
+
shouldGenerateProtocol(this.sdkContext, operation) && !this.isInternal(this.sdkContext, operation);
|
|
389
439
|
codeModelOperation.addRequest(new Request({
|
|
390
440
|
protocol: {
|
|
391
441
|
http: {
|
|
@@ -492,29 +542,36 @@ export class CodeModelBuilder {
|
|
|
492
542
|
pollingSchema = this.pollResultSchema;
|
|
493
543
|
}
|
|
494
544
|
else {
|
|
495
|
-
if (lroMetadata.pollingInfo.responseModel
|
|
496
|
-
getNamespace(lroMetadata.pollingInfo.responseModel) === "Azure.Core.Foundations") {
|
|
545
|
+
if (modelIs(lroMetadata.pollingInfo.responseModel, "OperationStatus", "Azure.Core.Foundations")) {
|
|
497
546
|
pollingSchema = this.pollResultSchema;
|
|
498
547
|
}
|
|
499
548
|
else {
|
|
500
|
-
|
|
549
|
+
const pollType = this.findResponseBody(lroMetadata.pollingInfo.responseModel);
|
|
550
|
+
pollingSchema = this.processSchema(pollType, "pollResult");
|
|
501
551
|
}
|
|
502
552
|
}
|
|
503
553
|
// finalSchema
|
|
504
554
|
if (verb !== "delete" && lroMetadata.logicalResult) {
|
|
505
|
-
|
|
555
|
+
const finalType = this.findResponseBody(lroMetadata.logicalResult);
|
|
556
|
+
finalSchema = this.processSchema(finalType, "finalResult");
|
|
506
557
|
}
|
|
507
558
|
// track usage
|
|
508
559
|
if (pollingSchema) {
|
|
509
560
|
this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Output] });
|
|
510
|
-
if (op.
|
|
511
|
-
this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.
|
|
561
|
+
if (op.internalApi) {
|
|
562
|
+
this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Internal] });
|
|
563
|
+
}
|
|
564
|
+
else if (op.convenienceApi) {
|
|
565
|
+
this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Public] });
|
|
512
566
|
}
|
|
513
567
|
}
|
|
514
568
|
if (finalSchema) {
|
|
515
569
|
this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Output] });
|
|
516
|
-
if (op.
|
|
517
|
-
this.trackSchemaUsage(
|
|
570
|
+
if (op.internalApi) {
|
|
571
|
+
this.trackSchemaUsage(pollingSchema, { usage: [SchemaContext.Internal] });
|
|
572
|
+
}
|
|
573
|
+
else if (op.convenienceApi) {
|
|
574
|
+
this.trackSchemaUsage(finalSchema, { usage: [SchemaContext.Public] });
|
|
518
575
|
}
|
|
519
576
|
}
|
|
520
577
|
op.lroMetadata = new LongRunningMetadata(true, pollingSchema, finalSchema, pollingStrategy);
|
|
@@ -652,8 +709,11 @@ export class CodeModelBuilder {
|
|
|
652
709
|
});
|
|
653
710
|
op.addParameter(parameter);
|
|
654
711
|
this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] });
|
|
655
|
-
if (op.
|
|
656
|
-
this.trackSchemaUsage(schema, { usage: [SchemaContext.
|
|
712
|
+
if (op.internalApi) {
|
|
713
|
+
this.trackSchemaUsage(schema, { usage: [SchemaContext.Internal] });
|
|
714
|
+
}
|
|
715
|
+
else if (op.convenienceApi) {
|
|
716
|
+
this.trackSchemaUsage(schema, { usage: [SchemaContext.Public] });
|
|
657
717
|
}
|
|
658
718
|
if (param.name.toLowerCase() === "content-type") {
|
|
659
719
|
let mediaTypes = ["application/json"];
|
|
@@ -771,7 +831,13 @@ export class CodeModelBuilder {
|
|
|
771
831
|
required: false,
|
|
772
832
|
nullable: true,
|
|
773
833
|
});
|
|
774
|
-
this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Input
|
|
834
|
+
this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Input] });
|
|
835
|
+
if (op.internalApi) {
|
|
836
|
+
this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Internal] });
|
|
837
|
+
}
|
|
838
|
+
else if (op.convenienceApi) {
|
|
839
|
+
this.trackSchemaUsage(requestConditionsSchema, { usage: [SchemaContext.Public] });
|
|
840
|
+
}
|
|
775
841
|
// update group schema for properties
|
|
776
842
|
for (const parameter of request.parameters) {
|
|
777
843
|
if (parameter.language.default.serializedName &&
|
|
@@ -817,8 +883,11 @@ export class CodeModelBuilder {
|
|
|
817
883
|
});
|
|
818
884
|
op.addParameter(parameter);
|
|
819
885
|
this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] });
|
|
820
|
-
if (op.
|
|
821
|
-
this.trackSchemaUsage(schema, { usage: [SchemaContext.
|
|
886
|
+
if (op.internalApi) {
|
|
887
|
+
this.trackSchemaUsage(schema, { usage: [SchemaContext.Internal] });
|
|
888
|
+
}
|
|
889
|
+
else if (op.convenienceApi) {
|
|
890
|
+
this.trackSchemaUsage(schema, { usage: [SchemaContext.Public] });
|
|
822
891
|
}
|
|
823
892
|
if (!schema.language.default.name && schema instanceof ObjectSchema) {
|
|
824
893
|
// anonymous model
|
|
@@ -889,7 +958,7 @@ export class CodeModelBuilder {
|
|
|
889
958
|
serializedName: it.language.default.serializedName,
|
|
890
959
|
}));
|
|
891
960
|
});
|
|
892
|
-
this.trackSchemaUsage(optionBagSchema, { usage: [SchemaContext.Input, SchemaContext.
|
|
961
|
+
this.trackSchemaUsage(optionBagSchema, { usage: [SchemaContext.Input, SchemaContext.Public] });
|
|
893
962
|
// option bag parameter
|
|
894
963
|
const optionBagParameter = new Parameter("options", optionBagSchema.language.default.description, optionBagSchema, {
|
|
895
964
|
implementation: ImplementationLocation.Method,
|
|
@@ -916,7 +985,7 @@ export class CodeModelBuilder {
|
|
|
916
985
|
// headers
|
|
917
986
|
headers = [];
|
|
918
987
|
for (const [key, header] of Object.entries(resp.responses[0].headers)) {
|
|
919
|
-
const schema = this.processSchema(header
|
|
988
|
+
const schema = this.processSchema(header, key);
|
|
920
989
|
headers.push(new HttpHeader(key, schema, {
|
|
921
990
|
language: {
|
|
922
991
|
default: {
|
|
@@ -1042,8 +1111,11 @@ export class CodeModelBuilder {
|
|
|
1042
1111
|
op.addResponse(response);
|
|
1043
1112
|
if (response instanceof SchemaResponse) {
|
|
1044
1113
|
this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Output] });
|
|
1045
|
-
if (
|
|
1046
|
-
this.trackSchemaUsage(response.schema, { usage: [SchemaContext.
|
|
1114
|
+
if (op.internalApi) {
|
|
1115
|
+
this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Internal] });
|
|
1116
|
+
}
|
|
1117
|
+
else if (trackConvenienceApi) {
|
|
1118
|
+
this.trackSchemaUsage(response.schema, { usage: [SchemaContext.Public] });
|
|
1047
1119
|
}
|
|
1048
1120
|
}
|
|
1049
1121
|
}
|
|
@@ -1815,7 +1887,7 @@ export class CodeModelBuilder {
|
|
|
1815
1887
|
return;
|
|
1816
1888
|
}
|
|
1817
1889
|
processedSchemas.add(schema);
|
|
1818
|
-
if (schema instanceof ObjectSchema) {
|
|
1890
|
+
if (schema instanceof ObjectSchema || schema instanceof GroupSchema) {
|
|
1819
1891
|
if (schemaUsage.usage || schemaUsage.serializationFormats) {
|
|
1820
1892
|
(_a = schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
1821
1893
|
var _a;
|
|
@@ -1830,10 +1902,12 @@ export class CodeModelBuilder {
|
|
|
1830
1902
|
innerApplySchemaUsage(p.schema, schemaUsage);
|
|
1831
1903
|
}
|
|
1832
1904
|
});
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1905
|
+
if (schema instanceof ObjectSchema) {
|
|
1906
|
+
(_c = (_b = schema.parents) === null || _b === void 0 ? void 0 : _b.all) === null || _c === void 0 ? void 0 : _c.forEach((p) => innerApplySchemaUsage(p, schemaUsage));
|
|
1907
|
+
(_e = (_d = schema.parents) === null || _d === void 0 ? void 0 : _d.immediate) === null || _e === void 0 ? void 0 : _e.forEach((p) => innerApplySchemaUsage(p, schemaUsage));
|
|
1908
|
+
(_g = (_f = schema.children) === null || _f === void 0 ? void 0 : _f.all) === null || _g === void 0 ? void 0 : _g.forEach((c) => innerApplySchemaUsage(c, schemaUsage));
|
|
1909
|
+
(_j = (_h = schema.children) === null || _h === void 0 ? void 0 : _h.immediate) === null || _j === void 0 ? void 0 : _j.forEach((c) => innerApplySchemaUsage(c, schemaUsage));
|
|
1910
|
+
}
|
|
1837
1911
|
// Object.values(schema.discriminator?.all ?? {}).forEach((d) => {
|
|
1838
1912
|
// innerApplySchemaUsage(d, schemaUsage);
|
|
1839
1913
|
// });
|