@azure-tools/typespec-java 0.12.2 → 0.13.0
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 +7 -1
- package/dist/src/code-model-builder.d.ts.map +1 -1
- package/dist/src/code-model-builder.js +133 -35
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/emitter.d.ts +3 -1
- package/dist/src/emitter.d.ts.map +1 -1
- package/dist/src/emitter.js +6 -2
- package/dist/src/emitter.js.map +1 -1
- package/dist/src/type-utils.d.ts +8 -0
- package/dist/src/type-utils.d.ts.map +1 -1
- package/dist/src/type-utils.js +15 -1
- package/dist/src/type-utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/readme.md +2 -2
- package/target/emitter.jar +0 -0
|
@@ -28,6 +28,7 @@ export declare class CodeModelBuilder {
|
|
|
28
28
|
private processRouteForPaged;
|
|
29
29
|
private processLroMetadata;
|
|
30
30
|
private processRouteForLongRunning;
|
|
31
|
+
private _armApiVersionParameter?;
|
|
31
32
|
private processParameter;
|
|
32
33
|
private addAcceptHeaderParameter;
|
|
33
34
|
private processEtagHeaderParameters;
|
|
@@ -60,6 +61,8 @@ export declare class CodeModelBuilder {
|
|
|
60
61
|
private processUrlSchema;
|
|
61
62
|
private processObjectSchema;
|
|
62
63
|
private getEffectiveSchemaType;
|
|
64
|
+
private dummyResourceSchema;
|
|
65
|
+
private dummyObjectSchema;
|
|
63
66
|
private applyModelPropertyDecorators;
|
|
64
67
|
private processModelProperty;
|
|
65
68
|
private processFormatString;
|
|
@@ -93,9 +96,12 @@ export declare class CodeModelBuilder {
|
|
|
93
96
|
get apiVersionParameter(): Parameter;
|
|
94
97
|
private _apiVersionParameterInPath?;
|
|
95
98
|
get apiVersionParameterInPath(): Parameter;
|
|
99
|
+
private isSubscriptionId;
|
|
100
|
+
private subscriptionIdParameter;
|
|
101
|
+
private _subscriptionParameter?;
|
|
96
102
|
private propagateSchemaUsage;
|
|
97
103
|
private trackSchemaUsage;
|
|
98
|
-
private
|
|
104
|
+
private isArm;
|
|
99
105
|
private isSchemaUsageEmpty;
|
|
100
106
|
}
|
|
101
107
|
//# sourceMappingURL=code-model-builder.d.ts.map
|
|
@@ -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,
|
|
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,EAQZ,MAAM,oBAAoB,CAAC;AAmC5B,OAAO,EACL,SAAS,EAIT,aAAa,EAUb,YAAY,EACZ,YAAY,EACZ,SAAS,EAKT,MAAM,EAIN,YAAY,EAeb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAUnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAW9C,OAAO,EACL,eAAe,EAehB,MAAM,iBAAiB,CAAC;AAoBzB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAa;IAE/B,OAAO,CAAC,OAAO,CAAiB;IAEhC,OAAO,CAAC,SAAS,CAAY;IAE7B,QAAQ,CAAC,WAAW,gCAAyF;IAC7G,QAAQ,CAAC,iBAAiB,sCAA6C;IAEvE,OAAO,CAAC,iBAAiB,CAAkD;gBAExD,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC;IAyD7D,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;IAkBxC,O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O,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IAiE5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,kBAAkB;CAiB3B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { getDoc, getEffectiveModelType, getFormat, getFriendlyName, getKnownValues, getSummary, getVisibility, ignoreDiagnostics, isArrayModelType, isRecordModelType, isUnknownType, getDiscriminator, isNeverType, listServices, getNamespaceFullName, isNullType, getTypeName, getProjectedName, getEncode, getOverloadedOperation, isErrorModel, } from "@typespec/compiler";
|
|
1
|
+
import { getDoc, getEffectiveModelType, getFormat, getFriendlyName, getKnownValues, getSummary, getVisibility, ignoreDiagnostics, isArrayModelType, isRecordModelType, isUnknownType, getDiscriminator, isNeverType, listServices, getNamespaceFullName, isNullType, getTypeName, getProjectedName, getEncode, getOverloadedOperation, isErrorModel, walkPropertiesInherited, getService, } from "@typespec/compiler";
|
|
2
2
|
import { getResourceOperation, getSegment } from "@typespec/rest";
|
|
3
|
-
import { getAuthentication, getServers, getStatusCodeDescription, getHttpOperation, getQueryParamOptions, getHeaderFieldOptions, } from "@typespec/http";
|
|
3
|
+
import { getAuthentication, getServers, getStatusCodeDescription, getHttpOperation, getQueryParamOptions, getHeaderFieldOptions, isPathParam, } 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, getCrossLanguageDefinitionId, } from "@azure-tools/typespec-client-generator-core";
|
|
6
|
+
import { listClients, listOperationGroups, listOperationsInOperationGroup, isApiVersion, shouldGenerateConvenient, createSdkContext, shouldGenerateProtocol, isInternal, getCrossLanguageDefinitionId, getClientNameOverride, shouldFlattenProperty, } 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 { KnownMediaType } from "@azure-tools/codegen";
|
|
@@ -22,8 +22,8 @@ import { ClientContext } from "./models.js";
|
|
|
22
22
|
import { stringArrayContainsIgnoreCase, getJavaNamespace, getNamespace, pascalCase, logWarning, trace, } from "./utils.js";
|
|
23
23
|
import { ProcessingCache, isModelReferredInTemplate, pushDistinct, modelContainsDerivedModel, getNameForTemplate, getDurationFormat, hasScalarAsBase, isNullableType, isSameLiteralTypes, getAccess, getUsage, getUnionDescription, modelIs, getModelNameForProperty, isAllValueInteger, } from "./type-utils.js";
|
|
24
24
|
import { getClientApiVersions, getServiceVersion, operationIsJsonMergePatch, isPayloadProperty, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, loadExamples, isLroNewPollingStrategy, operationIsMultipleContentTypes, cloneOperationParameter, operationIsMultipart, isKnownContentType, CONTENT_TYPE_KEY, } from "./operation-utils.js";
|
|
25
|
+
import { isArmCommonType } from "./type-utils.js";
|
|
25
26
|
import pkg from "lodash";
|
|
26
|
-
import { getExtensions } from "@typespec/openapi";
|
|
27
27
|
const { isEqual } = pkg;
|
|
28
28
|
export class CodeModelBuilder {
|
|
29
29
|
constructor(program1, context) {
|
|
@@ -267,10 +267,14 @@ export class CodeModelBuilder {
|
|
|
267
267
|
// deduplicate model name
|
|
268
268
|
const nameCount = new Map();
|
|
269
269
|
const deduplicateName = (schema) => {
|
|
270
|
-
var _a, _b;
|
|
270
|
+
var _a, _b, _c, _d;
|
|
271
|
+
// skip models under "Azure.ResourceManager"
|
|
272
|
+
if (this.isArm() && ((_b = (_a = schema.language.default) === null || _a === void 0 ? void 0 : _a.namespace) === null || _b === void 0 ? void 0 : _b.startsWith("Azure.ResourceManager"))) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
271
275
|
const name = schema.language.default.name;
|
|
272
276
|
// skip models under "com.azure.core."
|
|
273
|
-
if (name && !((
|
|
277
|
+
if (name && !((_d = (_c = schema.language.java) === null || _c === void 0 ? void 0 : _c.namespace) === null || _d === void 0 ? void 0 : _d.startsWith("com.azure.core."))) {
|
|
274
278
|
if (!nameCount.has(name)) {
|
|
275
279
|
nameCount.set(name, 1);
|
|
276
280
|
}
|
|
@@ -329,18 +333,16 @@ export class CodeModelBuilder {
|
|
|
329
333
|
codeModelClient.apiVersions.push(apiVersion);
|
|
330
334
|
}
|
|
331
335
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
// }
|
|
343
|
-
// }
|
|
336
|
+
else {
|
|
337
|
+
// fallback to @service.version
|
|
338
|
+
const service = getService(this.program, client.service);
|
|
339
|
+
if (service === null || service === void 0 ? void 0 : service.version) {
|
|
340
|
+
codeModelClient.apiVersions = [];
|
|
341
|
+
const apiVersion = new ApiVersion();
|
|
342
|
+
apiVersion.version = service.version;
|
|
343
|
+
codeModelClient.apiVersions.push(apiVersion);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
344
346
|
// server
|
|
345
347
|
let baseUri = "{endpoint}";
|
|
346
348
|
const servers = getServers(this.program, client.service);
|
|
@@ -645,7 +647,7 @@ export class CodeModelBuilder {
|
|
|
645
647
|
return new LongRunningMetadata(false);
|
|
646
648
|
}
|
|
647
649
|
processRouteForLongRunning(op, operation, responses, lroMetadata) {
|
|
648
|
-
var _a, _b
|
|
650
|
+
var _a, _b;
|
|
649
651
|
if (lroMetadata.longRunning) {
|
|
650
652
|
op.extensions = (_a = op.extensions) !== null && _a !== void 0 ? _a : {};
|
|
651
653
|
op.extensions["x-ms-long-running-operation"] = true;
|
|
@@ -662,16 +664,29 @@ export class CodeModelBuilder {
|
|
|
662
664
|
}
|
|
663
665
|
}
|
|
664
666
|
}
|
|
665
|
-
if (this.isArmLongRunningOperation(this.program, operation)) {
|
|
666
|
-
op.extensions = (_c = op.extensions) !== null && _c !== void 0 ? _c : {};
|
|
667
|
-
op.extensions["x-ms-long-running-operation"] = true;
|
|
668
|
-
}
|
|
669
667
|
}
|
|
670
668
|
processParameter(op, param, clientContext) {
|
|
671
669
|
var _a;
|
|
672
670
|
if (clientContext.apiVersions && isApiVersion(this.sdkContext, param)) {
|
|
673
671
|
// pre-condition for "isApiVersion": the client supports ApiVersions
|
|
674
|
-
|
|
672
|
+
if (this.isArm()) {
|
|
673
|
+
// Currently we assume ARM tsp only have one client and one api-version.
|
|
674
|
+
// TODO: How will service define mixed api-versions(like those in Compute RP)?
|
|
675
|
+
const apiVersion = clientContext.apiVersions[0];
|
|
676
|
+
if (!this._armApiVersionParameter) {
|
|
677
|
+
this._armApiVersionParameter = this.createApiVersionParameter("api-version", param.type === "query" ? ParameterLocation.Query : ParameterLocation.Path, apiVersion);
|
|
678
|
+
clientContext.addGlobalParameter(this._armApiVersionParameter);
|
|
679
|
+
}
|
|
680
|
+
op.addParameter(this._armApiVersionParameter);
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
const parameter = param.type === "query" ? this.apiVersionParameter : this.apiVersionParameterInPath;
|
|
684
|
+
op.addParameter(parameter);
|
|
685
|
+
clientContext.addGlobalParameter(parameter);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
else if (this.isSubscriptionId(param)) {
|
|
689
|
+
const parameter = this.subscriptionIdParameter(param);
|
|
675
690
|
op.addParameter(parameter);
|
|
676
691
|
clientContext.addGlobalParameter(parameter);
|
|
677
692
|
}
|
|
@@ -1264,7 +1279,9 @@ export class CodeModelBuilder {
|
|
|
1264
1279
|
schema = this.processChoiceSchema(knownValues, this.getName(knownValues), false);
|
|
1265
1280
|
}
|
|
1266
1281
|
else {
|
|
1267
|
-
const schemaNameHint =
|
|
1282
|
+
const schemaNameHint = type.type.kind === "Scalar" && this.program.checker.isStdType(type.type)
|
|
1283
|
+
? nameHint // std scalar won't need a nameHint
|
|
1284
|
+
: pascalCase(getModelNameForProperty(type)) + pascalCase(nameHint);
|
|
1268
1285
|
schema = this.processSchema(type.type, schemaNameHint);
|
|
1269
1286
|
}
|
|
1270
1287
|
return this.applyModelPropertyDecorators(type, nameHint, schema);
|
|
@@ -1291,6 +1308,7 @@ export class CodeModelBuilder {
|
|
|
1291
1308
|
processScalar(type, formatFromDerived, nameHint) {
|
|
1292
1309
|
const scalarName = type.name;
|
|
1293
1310
|
if (this.program.checker.isStdType(type)) {
|
|
1311
|
+
nameHint = scalarName;
|
|
1294
1312
|
switch (scalarName) {
|
|
1295
1313
|
case "string": {
|
|
1296
1314
|
const format = formatFromDerived !== null && formatFromDerived !== void 0 ? formatFromDerived : getFormat(this.program, type);
|
|
@@ -1551,6 +1569,18 @@ export class CodeModelBuilder {
|
|
|
1551
1569
|
processObjectSchema(type, name) {
|
|
1552
1570
|
var _a, _b;
|
|
1553
1571
|
const namespace = getNamespace(type);
|
|
1572
|
+
if ((this.isArm() &&
|
|
1573
|
+
(namespace === null || namespace === void 0 ? void 0 : namespace.startsWith("Azure.ResourceManager")) &&
|
|
1574
|
+
// there's ResourceListResult under Azure.ResourceManager namespace,
|
|
1575
|
+
// which shouldn't be considered Resource schema parent
|
|
1576
|
+
((name === null || name === void 0 ? void 0 : name.startsWith("TrackedResource")) ||
|
|
1577
|
+
(name === null || name === void 0 ? void 0 : name.startsWith("ExtensionResource")) ||
|
|
1578
|
+
(name === null || name === void 0 ? void 0 : name.startsWith("ProxyResource")))) ||
|
|
1579
|
+
name === "ArmResource") {
|
|
1580
|
+
const objectSchema = this.dummyResourceSchema(type, name, namespace);
|
|
1581
|
+
this.codeModel.schemas.add(objectSchema);
|
|
1582
|
+
return objectSchema;
|
|
1583
|
+
}
|
|
1554
1584
|
const objectSchema = new ObjectScheme(name, this.getDoc(type), {
|
|
1555
1585
|
summary: this.getSummary(type),
|
|
1556
1586
|
language: {
|
|
@@ -1626,7 +1656,14 @@ export class CodeModelBuilder {
|
|
|
1626
1656
|
else if (isRecordModelType(this.program, type)) {
|
|
1627
1657
|
// "pure" Record processed elsewhere
|
|
1628
1658
|
// "mixed" Record that have properties, treat the model as "additionalProperties"
|
|
1629
|
-
|
|
1659
|
+
/* type should have sourceModel, as
|
|
1660
|
+
model Type is Record<> {
|
|
1661
|
+
prop1: string
|
|
1662
|
+
}
|
|
1663
|
+
*/
|
|
1664
|
+
const parentSchema = type.sourceModel
|
|
1665
|
+
? this.processSchema(type.sourceModel, this.getName(type.sourceModel))
|
|
1666
|
+
: this.processDictionarySchema(type, this.getName(type));
|
|
1630
1667
|
objectSchema.parents = new Relations();
|
|
1631
1668
|
objectSchema.parents.immediate.push(parentSchema);
|
|
1632
1669
|
pushDistinct(objectSchema.parents.all, parentSchema);
|
|
@@ -1669,18 +1706,47 @@ export class CodeModelBuilder {
|
|
|
1669
1706
|
return objectSchema;
|
|
1670
1707
|
}
|
|
1671
1708
|
getEffectiveSchemaType(type) {
|
|
1709
|
+
var _a;
|
|
1672
1710
|
const program = this.program;
|
|
1673
1711
|
function isSchemaProperty(property) {
|
|
1674
1712
|
return isPayloadProperty(program, property);
|
|
1675
1713
|
}
|
|
1676
1714
|
if (type.kind === "Model") {
|
|
1677
1715
|
const effective = getEffectiveModelType(program, type, isSchemaProperty);
|
|
1678
|
-
if (effective.
|
|
1716
|
+
if (this.isArm() && ((_a = getNamespace(effective)) === null || _a === void 0 ? void 0 : _a.startsWith("Azure.ResourceManager"))) {
|
|
1717
|
+
// Catalog is TrackedResource<CatalogProperties>
|
|
1718
|
+
return type;
|
|
1719
|
+
}
|
|
1720
|
+
else if (effective.name) {
|
|
1679
1721
|
return effective;
|
|
1680
1722
|
}
|
|
1681
1723
|
}
|
|
1682
1724
|
return type;
|
|
1683
1725
|
}
|
|
1726
|
+
dummyResourceSchema(type, name, namespace) {
|
|
1727
|
+
const resourceModelName = (name === null || name === void 0 ? void 0 : name.startsWith("TrackedResource")) ? "Resource" : "ProxyResource";
|
|
1728
|
+
const resource = this.dummyObjectSchema(type, resourceModelName, namespace);
|
|
1729
|
+
const declaredProperties = walkPropertiesInherited(type);
|
|
1730
|
+
for (const prop of declaredProperties) {
|
|
1731
|
+
resource.addProperty(this.processModelProperty(prop));
|
|
1732
|
+
}
|
|
1733
|
+
return resource;
|
|
1734
|
+
}
|
|
1735
|
+
dummyObjectSchema(type, name, namespace) {
|
|
1736
|
+
return new ObjectScheme(name, this.getDoc(type), {
|
|
1737
|
+
summary: this.getSummary(type),
|
|
1738
|
+
language: {
|
|
1739
|
+
default: {
|
|
1740
|
+
name: name,
|
|
1741
|
+
namespace: namespace,
|
|
1742
|
+
},
|
|
1743
|
+
java: {
|
|
1744
|
+
name: name,
|
|
1745
|
+
namespace: getJavaNamespace(namespace),
|
|
1746
|
+
},
|
|
1747
|
+
},
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1684
1750
|
applyModelPropertyDecorators(prop, nameHint, schema) {
|
|
1685
1751
|
// if (schema instanceof StringSchema) {
|
|
1686
1752
|
// const decorators = {
|
|
@@ -1749,12 +1815,15 @@ export class CodeModelBuilder {
|
|
|
1749
1815
|
let nullable = isNullableType(prop.type);
|
|
1750
1816
|
let extensions = undefined;
|
|
1751
1817
|
if (this.isSecret(prop)) {
|
|
1752
|
-
extensions = {
|
|
1753
|
-
|
|
1754
|
-
};
|
|
1818
|
+
extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
1819
|
+
extensions["x-ms-secret"] = true;
|
|
1755
1820
|
// if the property does not return in response, it had to be nullable
|
|
1756
1821
|
nullable = true;
|
|
1757
1822
|
}
|
|
1823
|
+
if (shouldFlattenProperty(this.sdkContext, prop)) {
|
|
1824
|
+
extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
1825
|
+
extensions["x-ms-client-flatten"] = true;
|
|
1826
|
+
}
|
|
1758
1827
|
return new Property(this.getName(prop), this.getDoc(prop), schema, {
|
|
1759
1828
|
summary: this.getSummary(prop),
|
|
1760
1829
|
required: !prop.optional,
|
|
@@ -1911,6 +1980,10 @@ export class CodeModelBuilder {
|
|
|
1911
1980
|
}
|
|
1912
1981
|
getName(target, nameHint = undefined) {
|
|
1913
1982
|
// TODO: once getLibraryName API in typespec-client-generator-core can get projected name from language and client, as well as can handle template case, use getLibraryName API
|
|
1983
|
+
const emitterClientName = getClientNameOverride(this.sdkContext, target);
|
|
1984
|
+
if (emitterClientName) {
|
|
1985
|
+
return emitterClientName;
|
|
1986
|
+
}
|
|
1914
1987
|
const languageProjectedName = getProjectedName(this.program, target, "java");
|
|
1915
1988
|
if (languageProjectedName) {
|
|
1916
1989
|
return languageProjectedName;
|
|
@@ -2016,10 +2089,10 @@ export class CodeModelBuilder {
|
|
|
2016
2089
|
var _a;
|
|
2017
2090
|
return ((_a = this._pollResultSchema) !== null && _a !== void 0 ? _a : (this._pollResultSchema = createPollOperationDetailsSchema(this.codeModel.schemas, this.stringSchema)));
|
|
2018
2091
|
}
|
|
2019
|
-
createApiVersionParameter(serializedName, parameterLocation) {
|
|
2092
|
+
createApiVersionParameter(serializedName, parameterLocation, value = "") {
|
|
2020
2093
|
return new Parameter(serializedName, "Version parameter", this.codeModel.schemas.add(new ConstantSchema(serializedName, "API Version", {
|
|
2021
2094
|
valueType: this.stringSchema,
|
|
2022
|
-
value: new ConstantValue(
|
|
2095
|
+
value: new ConstantValue(value),
|
|
2023
2096
|
})), {
|
|
2024
2097
|
implementation: ImplementationLocation.Client,
|
|
2025
2098
|
origin: ORIGIN_API_VERSION,
|
|
@@ -2043,6 +2116,32 @@ export class CodeModelBuilder {
|
|
|
2043
2116
|
// TODO: hardcode as "apiVersion", as it is what we get from compiler
|
|
2044
2117
|
(this._apiVersionParameterInPath = this.createApiVersionParameter("apiVersion", ParameterLocation.Path)));
|
|
2045
2118
|
}
|
|
2119
|
+
isSubscriptionId(param) {
|
|
2120
|
+
var _a;
|
|
2121
|
+
return ("subscriptionId".toLocaleLowerCase() === ((_a = param === null || param === void 0 ? void 0 : param.name) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase()) &&
|
|
2122
|
+
param.param &&
|
|
2123
|
+
isArmCommonType(param.param) &&
|
|
2124
|
+
isPathParam(this.program, param.param));
|
|
2125
|
+
}
|
|
2126
|
+
subscriptionIdParameter(parameter) {
|
|
2127
|
+
if (!this._subscriptionParameter) {
|
|
2128
|
+
const param = parameter.param;
|
|
2129
|
+
const description = getDoc(this.program, param);
|
|
2130
|
+
this._subscriptionParameter = new Parameter("subscriptionId", description ? description : "The ID of the target subscription.", this.stringSchema, {
|
|
2131
|
+
implementation: ImplementationLocation.Client,
|
|
2132
|
+
required: true,
|
|
2133
|
+
protocol: {
|
|
2134
|
+
http: new HttpParameter(ParameterLocation.Path),
|
|
2135
|
+
},
|
|
2136
|
+
language: {
|
|
2137
|
+
default: {
|
|
2138
|
+
serializedName: "subscriptionId",
|
|
2139
|
+
},
|
|
2140
|
+
},
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
return this._subscriptionParameter;
|
|
2144
|
+
}
|
|
2046
2145
|
propagateSchemaUsage(schema) {
|
|
2047
2146
|
var _a, _b;
|
|
2048
2147
|
const processedSchemas = new Set();
|
|
@@ -2124,9 +2223,8 @@ export class CodeModelBuilder {
|
|
|
2124
2223
|
this.trackSchemaUsage(schema.elementType, schemaUsage);
|
|
2125
2224
|
}
|
|
2126
2225
|
}
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
return this.codeModel.arm && Boolean((_a = getExtensions(program, op)) === null || _a === void 0 ? void 0 : _a.get("x-ms-long-running-operation"));
|
|
2226
|
+
isArm() {
|
|
2227
|
+
return this.codeModel.arm;
|
|
2130
2228
|
}
|
|
2131
2229
|
isSchemaUsageEmpty(schema) {
|
|
2132
2230
|
if (schema instanceof ObjectSchema ||
|