@azure-tools/typespec-java 0.27.4 → 0.27.6
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.map +1 -1
- package/dist/src/code-model-builder.js +93 -52
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +6 -3
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/lib.js +1 -1
- package/dist/src/lib.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/generator/http-client-generator/target/emitter.jar +0 -0
- package/package.json +11 -11
|
@@ -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,YAAY,EAEZ,YAAY,EAOZ,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAyBL,OAAO,EAOR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EAKX,OAAO,EACP,IAAI,EAEJ,KAAK,EAQN,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AASnD,OAAO,EAAE,cAAc,EAAgD,MAAM,UAAU,CAAC;AAcxF,OAAO,EACL,eAAe,EAShB,MAAM,iBAAiB,CAAC;
|
|
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,YAAY,EAEZ,YAAY,EAOZ,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAyBL,OAAO,EAOR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EAKX,OAAO,EACP,IAAI,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CAAC,aAAa;IAuBrB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,oBAAoB;IAkB5B,OAAO,CAAC,gBAAgB;IAwDxB,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,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAO/B;IAED,OAAO,CAAC,cAAc,CAAC,CAAgB;IACvC,IAAI,aAAa,IAAI,aAAa,CAOjC;IAED,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,IAAI,SAAS,IAAI,SAAS,CAIzB;IAED,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAK/B;IAED,OAAO,CAAC,iBAAiB,CAAC,CAAe;IACzC,IAAI,gBAAgB,IAAI,YAAY,CAQnC;IAED,OAAO,CAAC,yBAAyB;IA8BjC,OAAO,CAAC,oBAAoB,CAAC,CAAY;IACzC,OAAO,CAAC,0BAA0B,CAAC,CAAY;IAC/C,OAAO,CAAC,4BAA4B,CAAC,CAAY;IACjD,OAAO,CAAC,uBAAuB,CAAC,CAAY;IAE5C,OAAO,CAAC,sBAAsB;IAiC9B,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,uBAAuB;IAwB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IA4F5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -23,6 +23,7 @@ import { CONTENT_TYPE_KEY, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperat
|
|
|
23
23
|
import { ProcessingCache, getAccess, getDurationFormat, getNonNullSdkType, getPropertySerializedName, getUnionDescription, getUsage, modelIs, pushDistinct, } from "./type-utils.js";
|
|
24
24
|
import { DiagnosticError, getNamespace, isStableApiVersion, pascalCase, removeClientSuffix, stringArrayContainsIgnoreCase, trace, } from "./utils.js";
|
|
25
25
|
const { isEqual } = pkg;
|
|
26
|
+
const AZURE_CORE_FOUNDATIONS_ERROR_ID = "Azure.Core.Foundations.Error";
|
|
26
27
|
export class CodeModelBuilder {
|
|
27
28
|
constructor(program1, context) {
|
|
28
29
|
var _a, _b;
|
|
@@ -158,6 +159,7 @@ export class CodeModelBuilder {
|
|
|
158
159
|
scopes: [],
|
|
159
160
|
});
|
|
160
161
|
scheme.flows.forEach((it) => oauth2Scheme.scopes.push(...it.scopes.map((it) => it.value)));
|
|
162
|
+
oauth2Scheme.flows = scheme.flows;
|
|
161
163
|
securitySchemes.push(oauth2Scheme);
|
|
162
164
|
}
|
|
163
165
|
else {
|
|
@@ -718,31 +720,27 @@ export class CodeModelBuilder {
|
|
|
718
720
|
for (const response of responses) {
|
|
719
721
|
const bodyType = response.type;
|
|
720
722
|
if (bodyType && bodyType.kind === "model") {
|
|
721
|
-
const itemClientName = sdkMethod.response.resultPath;
|
|
722
|
-
const nextLinkClientName = sdkMethod.nextLinkPath;
|
|
723
723
|
let itemSerializedName = undefined;
|
|
724
724
|
let nextLinkSerializedName = undefined;
|
|
725
|
+
const itemSegments = sdkMethod.response.resultSegments;
|
|
726
|
+
const nextLinkSegments = sdkMethod.pagingMetadata.nextLinkSegments;
|
|
727
|
+
// TODO: in future the property could be nested, so that the "itemSegments" or "nextLinkSegments" would contain more than 1 element
|
|
728
|
+
if (itemSegments) {
|
|
729
|
+
// "itemsSegments" should exist for "paging"/"lropaging"
|
|
730
|
+
const lastSegment = itemSegments[itemSegments.length - 1];
|
|
731
|
+
if (lastSegment.kind === "property") {
|
|
732
|
+
itemSerializedName = getPropertySerializedName(lastSegment);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
if (nextLinkSegments) {
|
|
736
|
+
const lastSegment = nextLinkSegments[nextLinkSegments.length - 1];
|
|
737
|
+
if (lastSegment.kind === "property") {
|
|
738
|
+
nextLinkSerializedName = getPropertySerializedName(lastSegment);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
725
741
|
(_a = op.responses) === null || _a === void 0 ? void 0 : _a.forEach((r) => {
|
|
726
|
-
var _a;
|
|
727
742
|
if (r instanceof SchemaResponse) {
|
|
728
743
|
this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] });
|
|
729
|
-
// find serializedName for items and nextLink
|
|
730
|
-
if (r.schema instanceof ObjectSchema) {
|
|
731
|
-
(_a = r.schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
732
|
-
if (itemClientName &&
|
|
733
|
-
!itemSerializedName &&
|
|
734
|
-
p.serializedName &&
|
|
735
|
-
p.language.default.name === itemClientName) {
|
|
736
|
-
itemSerializedName = p.serializedName;
|
|
737
|
-
}
|
|
738
|
-
if (nextLinkClientName &&
|
|
739
|
-
!nextLinkSerializedName &&
|
|
740
|
-
p.serializedName &&
|
|
741
|
-
p.language.default.name === nextLinkClientName) {
|
|
742
|
-
nextLinkSerializedName = p.serializedName;
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
}
|
|
746
744
|
}
|
|
747
745
|
});
|
|
748
746
|
op.extensions = (_b = op.extensions) !== null && _b !== void 0 ? _b : {};
|
|
@@ -799,9 +797,12 @@ export class CodeModelBuilder {
|
|
|
799
797
|
if (useNewPollStrategy &&
|
|
800
798
|
lroMetadata.finalStep &&
|
|
801
799
|
lroMetadata.finalStep.kind === "pollingSuccessProperty" &&
|
|
802
|
-
lroMetadata.finalResponse.resultSegments
|
|
803
|
-
|
|
804
|
-
|
|
800
|
+
lroMetadata.finalResponse.resultSegments) {
|
|
801
|
+
// TODO: in future the property could be nested, so that the "resultSegments" would contain more than 1 element
|
|
802
|
+
const lastSegment = lroMetadata.finalResponse.resultSegments[lroMetadata.finalResponse.resultSegments.length - 1];
|
|
803
|
+
if (lastSegment.kind === "property") {
|
|
804
|
+
finalResultPropertySerializedName = getPropertySerializedName(lastSegment);
|
|
805
|
+
}
|
|
805
806
|
}
|
|
806
807
|
}
|
|
807
808
|
// track usage
|
|
@@ -1771,7 +1772,7 @@ export class CodeModelBuilder {
|
|
|
1771
1772
|
}));
|
|
1772
1773
|
}
|
|
1773
1774
|
processObjectSchema(type, name) {
|
|
1774
|
-
var _a, _b;
|
|
1775
|
+
var _a, _b, _c;
|
|
1775
1776
|
const rawModelType = type.__raw;
|
|
1776
1777
|
const namespace = getNamespace(rawModelType);
|
|
1777
1778
|
const objectSchema = new ObjectSchema(name, (_a = type.doc) !== null && _a !== void 0 ? _a : "", {
|
|
@@ -1801,24 +1802,49 @@ export class CodeModelBuilder {
|
|
|
1801
1802
|
}
|
|
1802
1803
|
// type is a subtype
|
|
1803
1804
|
if (type.baseModel) {
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1805
|
+
if (this.isBranded() &&
|
|
1806
|
+
type.baseModel.crossLanguageDefinitionId === AZURE_CORE_FOUNDATIONS_ERROR_ID) {
|
|
1807
|
+
// com.azure.core.models.ResponseError class is final, we cannot extend it
|
|
1808
|
+
// therefore, copy all properties from "Error" to this class
|
|
1809
|
+
const parentSchema = this.processSchema(type.baseModel, type.baseModel.name);
|
|
1810
|
+
if (parentSchema instanceof ObjectSchema) {
|
|
1811
|
+
(_b = parentSchema.properties) === null || _b === void 0 ? void 0 : _b.forEach((p) => {
|
|
1812
|
+
var _a;
|
|
1813
|
+
objectSchema.addProperty(p);
|
|
1814
|
+
// improve the casing for Java
|
|
1815
|
+
if (p.serializedName === "innererror") {
|
|
1816
|
+
p.language.default.name = "innerError";
|
|
1817
|
+
if (p.schema instanceof ObjectSchema) {
|
|
1818
|
+
(_a = p.schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((innerErrorProperty) => {
|
|
1819
|
+
if (innerErrorProperty.serializedName === "innererror") {
|
|
1820
|
+
innerErrorProperty.language.default.name = "innerError";
|
|
1821
|
+
}
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1817
1824
|
}
|
|
1818
1825
|
});
|
|
1819
1826
|
}
|
|
1820
1827
|
}
|
|
1821
|
-
|
|
1828
|
+
else {
|
|
1829
|
+
const parentSchema = this.processSchema(type.baseModel, type.baseModel.name);
|
|
1830
|
+
objectSchema.parents = new Relations();
|
|
1831
|
+
objectSchema.parents.immediate.push(parentSchema);
|
|
1832
|
+
if (parentSchema instanceof ObjectSchema) {
|
|
1833
|
+
pushDistinct(objectSchema.parents.all, parentSchema);
|
|
1834
|
+
parentSchema.children = parentSchema.children || new Relations();
|
|
1835
|
+
pushDistinct(parentSchema.children.immediate, objectSchema);
|
|
1836
|
+
pushDistinct(parentSchema.children.all, objectSchema);
|
|
1837
|
+
if (parentSchema.parents) {
|
|
1838
|
+
pushDistinct(objectSchema.parents.all, ...parentSchema.parents.all);
|
|
1839
|
+
parentSchema.parents.all.forEach((it) => {
|
|
1840
|
+
if (it instanceof ObjectSchema && it.children) {
|
|
1841
|
+
pushDistinct(it.children.all, objectSchema);
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
objectSchema.discriminatorValue = type.discriminatorValue;
|
|
1847
|
+
}
|
|
1822
1848
|
}
|
|
1823
1849
|
if (type.additionalProperties) {
|
|
1824
1850
|
// model has additional property
|
|
@@ -1836,7 +1862,7 @@ export class CodeModelBuilder {
|
|
|
1836
1862
|
decorators: [],
|
|
1837
1863
|
};
|
|
1838
1864
|
const parentSchema = this.processSchema(sdkDictType, "Record");
|
|
1839
|
-
objectSchema.parents = (
|
|
1865
|
+
objectSchema.parents = (_c = objectSchema.parents) !== null && _c !== void 0 ? _c : new Relations();
|
|
1840
1866
|
objectSchema.parents.immediate.push(parentSchema);
|
|
1841
1867
|
pushDistinct(objectSchema.parents.all, parentSchema);
|
|
1842
1868
|
objectSchema.discriminatorValue = type.discriminatorValue;
|
|
@@ -2151,6 +2177,11 @@ export class CodeModelBuilder {
|
|
|
2151
2177
|
// usually this model will not be generated, but javadoc of protocol method requires it be in SDK namespace
|
|
2152
2178
|
return this.baseJavaNamespace;
|
|
2153
2179
|
}
|
|
2180
|
+
else if (crossLanguageDefinitionId === "Azure.Core.Foundations.InnerError") {
|
|
2181
|
+
// Azure.Core.Foundations.InnerError
|
|
2182
|
+
// this model could be generated, if a model extends Error
|
|
2183
|
+
return this.baseJavaNamespace;
|
|
2184
|
+
}
|
|
2154
2185
|
else if (type.crossLanguageDefinitionId.startsWith("Azure.ResourceManager.")) {
|
|
2155
2186
|
// models in Azure.ResourceManager
|
|
2156
2187
|
return this.baseJavaNamespace;
|
|
@@ -2276,20 +2307,30 @@ export class CodeModelBuilder {
|
|
|
2276
2307
|
}
|
|
2277
2308
|
processedSchemas.add(schema);
|
|
2278
2309
|
if (schema instanceof ObjectSchema || schema instanceof GroupSchema) {
|
|
2310
|
+
let skipPropergateProperties = false;
|
|
2311
|
+
if (this.isBranded() &&
|
|
2312
|
+
schema.language.default.crossLanguageDefinitionId === AZURE_CORE_FOUNDATIONS_ERROR_ID) {
|
|
2313
|
+
// a temporary hack to avoid propergate usage for Azure.Core.Foundations.Error
|
|
2314
|
+
// the reason is that the InnerError within cannot be mapped to azure-core ResponseInnerError, as that class is not public
|
|
2315
|
+
// so generator had to generate the class, if used outside of Azure.Core.Foundations.Error (e.g., when a model extends Error)
|
|
2316
|
+
skipPropergateProperties = true;
|
|
2317
|
+
}
|
|
2279
2318
|
if (schemaUsage.usage || schemaUsage.serializationFormats) {
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2319
|
+
if (!skipPropergateProperties) {
|
|
2320
|
+
(_a = schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
|
|
2321
|
+
var _a;
|
|
2322
|
+
if (p.readOnly && ((_a = schemaUsage.usage) === null || _a === void 0 ? void 0 : _a.includes(SchemaContext.Input))) {
|
|
2323
|
+
const schemaUsageWithoutInput = {
|
|
2324
|
+
usage: schemaUsage.usage.filter((it) => it !== SchemaContext.Input),
|
|
2325
|
+
serializationFormats: schemaUsage.serializationFormats,
|
|
2326
|
+
};
|
|
2327
|
+
innerApplySchemaUsage(p.schema, schemaUsageWithoutInput);
|
|
2328
|
+
}
|
|
2329
|
+
else {
|
|
2330
|
+
innerApplySchemaUsage(p.schema, schemaUsage);
|
|
2331
|
+
}
|
|
2332
|
+
});
|
|
2333
|
+
}
|
|
2293
2334
|
if (schema instanceof ObjectSchema) {
|
|
2294
2335
|
(_c = (_b = schema.parents) === null || _b === void 0 ? void 0 : _b.all) === null || _c === void 0 ? void 0 : _c.forEach((p) => innerApplySchemaUsage(p, schemaUsage));
|
|
2295
2336
|
(_e = (_d = schema.parents) === null || _d === void 0 ? void 0 : _d.immediate) === null || _e === void 0 ? void 0 : _e.forEach((p) => innerApplySchemaUsage(p, schemaUsage));
|