@azure-tools/typespec-java 0.27.1 → 0.27.2
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 +0 -1
- package/dist/src/code-model-builder.d.ts.map +1 -1
- package/dist/src/code-model-builder.js +85 -41
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/common/client.d.ts +1 -4
- package/dist/src/common/client.d.ts.map +1 -1
- package/dist/src/common/operation.d.ts +1 -2
- package/dist/src/common/operation.d.ts.map +1 -1
- package/dist/src/common/operation.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +21 -9
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/external-schemas.d.ts.map +1 -1
- package/dist/src/external-schemas.js +3 -4
- package/dist/src/external-schemas.js.map +1 -1
- package/dist/src/utils.d.ts +7 -2
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +12 -7
- package/dist/src/utils.js.map +1 -1
- package/dist/src/validate.d.ts +1 -0
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +34 -9
- package/dist/src/validate.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generator/http-client-generator/target/emitter.jar +0 -0
- package/package.json +28 -28
- package/readme.md +1 -1
|
@@ -15,7 +15,6 @@ export declare class CodeModelBuilder {
|
|
|
15
15
|
private codeModel;
|
|
16
16
|
private emitterContext;
|
|
17
17
|
private serviceNamespace;
|
|
18
|
-
private loggingEnabled;
|
|
19
18
|
readonly schemaCache: ProcessingCache<SdkType, Schema>;
|
|
20
19
|
readonly typeUnionRefCache: Map<Type, Union | null | undefined>;
|
|
21
20
|
private apiVersion;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-model-builder.d.ts","sourceRoot":"","sources":["../../src/code-model-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIT,YAAY,EACZ,aAAa,EAeb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QnC;IAED,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,oBAAoB,CAAC,CAAY;IACzC,IAAI,mBAAmB,IAAI,SAAS,CAQnC;IAED,OAAO,CAAC,0BAA0B,CAAC,CAAY;IAC/C,IAAI,yBAAyB,IAAI,SAAS,CASzC;IAED,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,uBAAuB;IAwB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IA+E5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -7,7 +7,7 @@ import { getSegment } from "@typespec/rest";
|
|
|
7
7
|
import { getAddedOnVersions } from "@typespec/versioning";
|
|
8
8
|
import { fail } from "assert";
|
|
9
9
|
import pkg from "lodash";
|
|
10
|
-
import { Client as CodeModelClient
|
|
10
|
+
import { Client as CodeModelClient } from "./common/client.js";
|
|
11
11
|
import { CodeModel } from "./common/code-model.js";
|
|
12
12
|
import { LongRunningMetadata } from "./common/long-running-metadata.js";
|
|
13
13
|
import { Operation as CodeModelOperation, ConvenienceApi, Request } from "./common/operation.js";
|
|
@@ -24,16 +24,12 @@ import { getNamespace, logError, logWarning, pascalCase, removeClientSuffix, str
|
|
|
24
24
|
const { isEqual } = pkg;
|
|
25
25
|
export class CodeModelBuilder {
|
|
26
26
|
constructor(program1, context) {
|
|
27
|
-
var _a, _b
|
|
28
|
-
this.loggingEnabled = false;
|
|
27
|
+
var _a, _b;
|
|
29
28
|
this.schemaCache = new ProcessingCache((type, name) => this.processSchemaImpl(type, name));
|
|
30
29
|
this.typeUnionRefCache = new Map(); // Union means it ref a Union type, null means it does not ref any Union, undefined means type visited but not completed
|
|
31
30
|
this.options = context.options;
|
|
32
31
|
this.program = program1;
|
|
33
32
|
this.emitterContext = context;
|
|
34
|
-
if ((_a = this.options["dev-options"]) === null || _a === void 0 ? void 0 : _a.loglevel) {
|
|
35
|
-
this.loggingEnabled = true;
|
|
36
|
-
}
|
|
37
33
|
if (this.options["skip-special-headers"]) {
|
|
38
34
|
this.options["skip-special-headers"].forEach((it) => SPECIAL_HEADER_NAMES.add(it.toLowerCase()));
|
|
39
35
|
}
|
|
@@ -41,7 +37,7 @@ export class CodeModelBuilder {
|
|
|
41
37
|
if (!service) {
|
|
42
38
|
this.logWarning("TypeSpec for HTTP client should define a service.");
|
|
43
39
|
}
|
|
44
|
-
this.serviceNamespace = (
|
|
40
|
+
this.serviceNamespace = (_a = service === null || service === void 0 ? void 0 : service.type) !== null && _a !== void 0 ? _a : this.program.getGlobalNamespaceType();
|
|
45
41
|
this.namespace = getNamespaceFullName(this.serviceNamespace) || "Client";
|
|
46
42
|
const namespace1 = this.namespace;
|
|
47
43
|
this.typeNameOptions = {
|
|
@@ -52,7 +48,7 @@ export class CodeModelBuilder {
|
|
|
52
48
|
},
|
|
53
49
|
};
|
|
54
50
|
// init code model
|
|
55
|
-
const title = (
|
|
51
|
+
const title = (_b = this.options["service-name"]) !== null && _b !== void 0 ? _b : this.serviceNamespace.name;
|
|
56
52
|
const description = this.getDoc(this.serviceNamespace);
|
|
57
53
|
this.codeModel = new CodeModel(title, false, {
|
|
58
54
|
info: {
|
|
@@ -152,11 +148,22 @@ export class CodeModelBuilder {
|
|
|
152
148
|
switch (scheme.type) {
|
|
153
149
|
case "oauth2":
|
|
154
150
|
{
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
if (this.isBranded()) {
|
|
152
|
+
const oauth2Scheme = new OAuth2SecurityScheme({
|
|
153
|
+
scopes: [],
|
|
154
|
+
});
|
|
155
|
+
scheme.flows.forEach((it) => oauth2Scheme.scopes.push(...it.scopes.map((it) => it.value)));
|
|
156
|
+
securitySchemes.push(oauth2Scheme);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// there is no TokenCredential in clientcore, hence use Bearer Authentication directly
|
|
160
|
+
this.logWarning(`OAuth2 auth scheme is generated as KeyCredential.`);
|
|
161
|
+
const keyScheme = new KeySecurityScheme({
|
|
162
|
+
name: "authorization",
|
|
163
|
+
});
|
|
164
|
+
keyScheme.prefix = "Bearer";
|
|
165
|
+
securitySchemes.push(keyScheme);
|
|
166
|
+
}
|
|
160
167
|
}
|
|
161
168
|
break;
|
|
162
169
|
case "apiKey":
|
|
@@ -341,7 +348,7 @@ export class CodeModelBuilder {
|
|
|
341
348
|
// at present, use global security definition
|
|
342
349
|
security: this.codeModel.security,
|
|
343
350
|
});
|
|
344
|
-
codeModelClient.crossLanguageDefinitionId = client.crossLanguageDefinitionId;
|
|
351
|
+
codeModelClient.language.default.crossLanguageDefinitionId = client.crossLanguageDefinitionId;
|
|
345
352
|
// versioning
|
|
346
353
|
const versions = client.apiVersions;
|
|
347
354
|
if (versions && versions.length > 0) {
|
|
@@ -378,7 +385,7 @@ export class CodeModelBuilder {
|
|
|
378
385
|
}
|
|
379
386
|
}
|
|
380
387
|
else if (initializationProperty.type.variantTypes.length > 2) {
|
|
381
|
-
this.logError("Multiple server
|
|
388
|
+
this.logError("Multiple server URL defined for one client is not supported yet.");
|
|
382
389
|
}
|
|
383
390
|
}
|
|
384
391
|
else if (initializationProperty.type.kind === "endpoint") {
|
|
@@ -395,6 +402,7 @@ export class CodeModelBuilder {
|
|
|
395
402
|
// operations without operation group
|
|
396
403
|
const serviceMethodsWithoutSubClient = this.listServiceMethodsUnderClient(client);
|
|
397
404
|
let codeModelGroup = new OperationGroup("");
|
|
405
|
+
codeModelGroup.language.default.crossLanguageDefinitionId = client.crossLanguageDefinitionId;
|
|
398
406
|
for (const serviceMethod of serviceMethodsWithoutSubClient) {
|
|
399
407
|
if (!this.needToSkipProcessingOperation(serviceMethod.__raw, clientContext)) {
|
|
400
408
|
codeModelGroup.addOperation(this.processOperation(serviceMethod, clientContext, ""));
|
|
@@ -418,6 +426,8 @@ export class CodeModelBuilder {
|
|
|
418
426
|
// operation group with no operation is skipped
|
|
419
427
|
if (serviceMethods.length > 0) {
|
|
420
428
|
codeModelGroup = new OperationGroup(subClient.name);
|
|
429
|
+
codeModelGroup.language.default.crossLanguageDefinitionId =
|
|
430
|
+
subClient.crossLanguageDefinitionId;
|
|
421
431
|
for (const serviceMethod of serviceMethods) {
|
|
422
432
|
if (!this.needToSkipProcessingOperation(serviceMethod.__raw, clientContext)) {
|
|
423
433
|
codeModelGroup.addOperation(this.processOperation(serviceMethod, clientContext, subClient.name));
|
|
@@ -560,8 +570,8 @@ export class CodeModelBuilder {
|
|
|
560
570
|
"x-ms-examples": operationExamples,
|
|
561
571
|
},
|
|
562
572
|
});
|
|
563
|
-
codeModelOperation.crossLanguageDefinitionId =
|
|
564
|
-
sdkMethod.
|
|
573
|
+
codeModelOperation.language.default.crossLanguageDefinitionId =
|
|
574
|
+
sdkMethod.crossLanguageDefinitionId;
|
|
565
575
|
codeModelOperation.internalApi = sdkMethod.access === "internal";
|
|
566
576
|
const convenienceApiName = this.getConvenienceApiName(sdkMethod);
|
|
567
577
|
let generateConvenienceApi = sdkMethod.generateConvenient;
|
|
@@ -672,24 +682,45 @@ export class CodeModelBuilder {
|
|
|
672
682
|
for (const response of responses) {
|
|
673
683
|
const bodyType = response.type;
|
|
674
684
|
if (bodyType && bodyType.kind === "model") {
|
|
675
|
-
const
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
};
|
|
682
|
-
(_b = op.responses) === null || _b === void 0 ? void 0 : _b.forEach((r) => {
|
|
685
|
+
const itemClientName = sdkMethod.response.resultPath;
|
|
686
|
+
const nextLinkClientName = sdkMethod.nextLinkPath;
|
|
687
|
+
let itemSerializedName = undefined;
|
|
688
|
+
let nextLinkSerializedName = undefined;
|
|
689
|
+
(_a = op.responses) === null || _a === void 0 ? void 0 : _a.forEach((r) => {
|
|
690
|
+
var _a;
|
|
683
691
|
if (r instanceof SchemaResponse) {
|
|
684
692
|
this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] });
|
|
693
|
+
// find serializedName for items and nextLink
|
|
694
|
+
if (r.schema instanceof ObjectSchema) {
|
|
695
|
+
(_a = r.schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
696
|
+
if (itemClientName &&
|
|
697
|
+
!itemSerializedName &&
|
|
698
|
+
p.serializedName &&
|
|
699
|
+
p.language.default.name === itemClientName) {
|
|
700
|
+
itemSerializedName = p.serializedName;
|
|
701
|
+
}
|
|
702
|
+
if (nextLinkClientName &&
|
|
703
|
+
!nextLinkSerializedName &&
|
|
704
|
+
p.serializedName &&
|
|
705
|
+
p.language.default.name === nextLinkClientName) {
|
|
706
|
+
nextLinkSerializedName = p.serializedName;
|
|
707
|
+
}
|
|
708
|
+
});
|
|
709
|
+
}
|
|
685
710
|
}
|
|
686
711
|
});
|
|
712
|
+
op.extensions = (_b = op.extensions) !== null && _b !== void 0 ? _b : {};
|
|
713
|
+
op.extensions["x-ms-pageable"] = {
|
|
714
|
+
itemName: itemSerializedName,
|
|
715
|
+
nextLinkName: nextLinkSerializedName,
|
|
716
|
+
};
|
|
687
717
|
break;
|
|
688
718
|
}
|
|
689
719
|
}
|
|
690
720
|
}
|
|
691
721
|
}
|
|
692
722
|
processLroMetadata(op, sdkMethod) {
|
|
723
|
+
var _a;
|
|
693
724
|
const trackConvenienceApi = Boolean(op.convenienceApi);
|
|
694
725
|
const lroMetadata = sdkMethod.lroMetadata;
|
|
695
726
|
if (lroMetadata && lroMetadata.pollingStep) {
|
|
@@ -734,8 +765,19 @@ export class CodeModelBuilder {
|
|
|
734
765
|
lroMetadata.finalStep &&
|
|
735
766
|
lroMetadata.finalStep.kind === "pollingSuccessProperty" &&
|
|
736
767
|
lroMetadata.finalResponse.resultPath) {
|
|
737
|
-
|
|
738
|
-
|
|
768
|
+
const finalResultPropertyClientName = lroMetadata.finalResponse.resultPath;
|
|
769
|
+
// find serializedName for lro result
|
|
770
|
+
if (finalResultPropertyClientName) {
|
|
771
|
+
(_a = lroMetadata.finalResponse.envelopeResult.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
772
|
+
var _a;
|
|
773
|
+
// TODO: "p.__raw?.name" should be "p.name", after TCGC fix https://github.com/Azure/typespec-azure/issues/2072
|
|
774
|
+
if (p.kind === "property" &&
|
|
775
|
+
p.serializedName &&
|
|
776
|
+
((_a = p.__raw) === null || _a === void 0 ? void 0 : _a.name) === finalResultPropertyClientName) {
|
|
777
|
+
finalResultPropertySerializedName = p.serializedName;
|
|
778
|
+
}
|
|
779
|
+
});
|
|
780
|
+
}
|
|
739
781
|
}
|
|
740
782
|
}
|
|
741
783
|
// track usage
|
|
@@ -1499,7 +1541,7 @@ export class CodeModelBuilder {
|
|
|
1499
1541
|
},
|
|
1500
1542
|
},
|
|
1501
1543
|
});
|
|
1502
|
-
schema.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1544
|
+
schema.language.default.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1503
1545
|
return this.codeModel.schemas.add(schema);
|
|
1504
1546
|
}
|
|
1505
1547
|
processConstantSchema(type, name) {
|
|
@@ -1573,8 +1615,7 @@ export class CodeModelBuilder {
|
|
|
1573
1615
|
},
|
|
1574
1616
|
},
|
|
1575
1617
|
});
|
|
1576
|
-
objectSchema.crossLanguageDefinitionId =
|
|
1577
|
-
type.crossLanguageDefinitionId;
|
|
1618
|
+
objectSchema.language.default.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1578
1619
|
this.codeModel.schemas.add(objectSchema);
|
|
1579
1620
|
// cache this now before we accidentally recurse on this type.
|
|
1580
1621
|
if (!this.schemaCache.has(type)) {
|
|
@@ -1756,7 +1797,7 @@ export class CodeModelBuilder {
|
|
|
1756
1797
|
getUnionVariantName(type, option) {
|
|
1757
1798
|
var _a, _b;
|
|
1758
1799
|
if (type === undefined) {
|
|
1759
|
-
this.
|
|
1800
|
+
this.logWarning("Union variant type is undefined.");
|
|
1760
1801
|
return "UnionVariant";
|
|
1761
1802
|
}
|
|
1762
1803
|
switch (type.kind) {
|
|
@@ -1814,7 +1855,7 @@ export class CodeModelBuilder {
|
|
|
1814
1855
|
case "UnionVariant":
|
|
1815
1856
|
return (_b = (typeof type.name === "string" ? type.name : undefined)) !== null && _b !== void 0 ? _b : "UnionVariant";
|
|
1816
1857
|
default:
|
|
1817
|
-
this.
|
|
1858
|
+
this.logWarning(`Unrecognized type for union variable: '${type.kind}'.`);
|
|
1818
1859
|
return "UnionVariant";
|
|
1819
1860
|
}
|
|
1820
1861
|
}
|
|
@@ -1946,18 +1987,19 @@ export class CodeModelBuilder {
|
|
|
1946
1987
|
// clientNamespace from TCGC
|
|
1947
1988
|
const clientNamespace = type === null || type === void 0 ? void 0 : type.clientNamespace;
|
|
1948
1989
|
if (type) {
|
|
1990
|
+
const crossLanguageDefinitionId = type.crossLanguageDefinitionId;
|
|
1949
1991
|
if (this.isBranded()) {
|
|
1950
1992
|
// special handling for namespace of model that cannot be mapped to azure-core
|
|
1951
|
-
if (
|
|
1993
|
+
if (crossLanguageDefinitionId === "TypeSpec.Http.File") {
|
|
1952
1994
|
// TypeSpec.Http.File
|
|
1953
1995
|
return this.baseJavaNamespace;
|
|
1954
1996
|
}
|
|
1955
|
-
else if (
|
|
1997
|
+
else if (crossLanguageDefinitionId === "Azure.Core.Foundations.OperationState") {
|
|
1956
1998
|
// Azure.Core.OperationState
|
|
1957
1999
|
return this.baseJavaNamespace;
|
|
1958
2000
|
}
|
|
1959
|
-
else if (
|
|
1960
|
-
|
|
2001
|
+
else if (crossLanguageDefinitionId === "Azure.Core.ResourceOperationStatus" ||
|
|
2002
|
+
crossLanguageDefinitionId === "Azure.Core.Foundations.OperationStatus") {
|
|
1961
2003
|
// Azure.Core.ResourceOperationStatus<>
|
|
1962
2004
|
// Azure.Core.Foundations.OperationStatus<>
|
|
1963
2005
|
// usually this model will not be generated, but javadoc of protocol method requires it be in SDK namespace
|
|
@@ -1969,8 +2011,12 @@ export class CodeModelBuilder {
|
|
|
1969
2011
|
}
|
|
1970
2012
|
}
|
|
1971
2013
|
else {
|
|
1972
|
-
// special handling for namespace of model in TypeSpec
|
|
1973
|
-
if (
|
|
2014
|
+
// special handling for namespace of model in TypeSpec
|
|
2015
|
+
if (crossLanguageDefinitionId === "TypeSpec.Http.File") {
|
|
2016
|
+
// TypeSpec.Http.File
|
|
2017
|
+
return this.baseJavaNamespace;
|
|
2018
|
+
}
|
|
2019
|
+
else if (crossLanguageDefinitionId.startsWith("TypeSpec.Rest.Resource.")) {
|
|
1974
2020
|
// models in TypeSpec.Rest.Resource
|
|
1975
2021
|
return this.baseJavaNamespace;
|
|
1976
2022
|
}
|
|
@@ -1987,9 +2033,7 @@ export class CodeModelBuilder {
|
|
|
1987
2033
|
logError(this.program, msg);
|
|
1988
2034
|
}
|
|
1989
2035
|
logWarning(msg) {
|
|
1990
|
-
|
|
1991
|
-
logWarning(this.program, msg);
|
|
1992
|
-
}
|
|
2036
|
+
logWarning(this.program, msg);
|
|
1993
2037
|
}
|
|
1994
2038
|
trace(msg) {
|
|
1995
2039
|
trace(this.program, msg);
|