@azure-tools/typespec-java 0.18.2 → 0.18.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/dist/src/code-model-builder.d.ts +3 -1
- package/dist/src/code-model-builder.d.ts.map +1 -1
- package/dist/src/code-model-builder.js +98 -60
- package/dist/src/code-model-builder.js.map +1 -1
- package/dist/src/common/client.d.ts +3 -5
- package/dist/src/common/client.d.ts.map +1 -1
- package/dist/src/common/client.js +1 -6
- package/dist/src/common/client.js.map +1 -1
- package/dist/src/common/operation.d.ts +2 -2
- package/dist/src/common/operation.d.ts.map +1 -1
- package/dist/src/common/operation.js.map +1 -1
- package/dist/src/external-schemas.d.ts +3 -2
- package/dist/src/external-schemas.d.ts.map +1 -1
- package/dist/src/external-schemas.js +126 -35
- package/dist/src/external-schemas.js.map +1 -1
- package/dist/src/operation-utils.d.ts +1 -12
- package/dist/src/operation-utils.d.ts.map +1 -1
- package/dist/src/operation-utils.js +2 -108
- package/dist/src/operation-utils.js.map +1 -1
- package/dist/src/utils.d.ts +0 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +0 -3
- package/dist/src/utils.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/readme.md +2 -2
- package/target/emitter.jar +0 -0
|
@@ -11,10 +11,11 @@ export declare class CodeModelBuilder {
|
|
|
11
11
|
private sdkContext;
|
|
12
12
|
private options;
|
|
13
13
|
private codeModel;
|
|
14
|
+
private emitterContext;
|
|
15
|
+
private serviceNamespace;
|
|
14
16
|
private loggingEnabled;
|
|
15
17
|
readonly schemaCache: ProcessingCache<SdkType, Schema>;
|
|
16
18
|
readonly typeUnionRefCache: Map<Type, Union | null | undefined>;
|
|
17
|
-
private operationExamples;
|
|
18
19
|
private apiVersion;
|
|
19
20
|
constructor(program1: Program, context: EmitContext<EmitterOptions>);
|
|
20
21
|
build(): Promise<CodeModel>;
|
|
@@ -100,6 +101,7 @@ export declare class CodeModelBuilder {
|
|
|
100
101
|
private isSecret;
|
|
101
102
|
private getMutability;
|
|
102
103
|
private getConvenienceApiName;
|
|
104
|
+
private getJavaNamespace;
|
|
103
105
|
private logWarning;
|
|
104
106
|
private trace;
|
|
105
107
|
private _stringSchema?;
|
|
@@ -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,EAEZ,SAAS,EAKT,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,
|
|
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,EAEZ,SAAS,EAKT,MAAM,EAMN,YAAY,EAKb,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAcL,OAAO,EAoBR,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACL,WAAW,EAMX,OAAO,EAEP,IAAI,EAEJ,KAAK,EAeN,MAAM,oBAAoB,CAAC;AA4B5B,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAQnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAgB9C,OAAO,EACL,eAAe,EAahB,MAAM,iBAAiB,CAAC;AAKzB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,gBAAgB,CAAoC;IAE5D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IAAI,SAAS,CAEzB;IAED,OAAO,CAAC,aAAa,CAAC,CAAe;IACrC,IAAI,YAAY,IAAI,YAAY,CAE/B;IAED,OAAO,CAAC,iBAAiB,CAAC,CAAe;IACzC,IAAI,gBAAgB,IAAI,YAAY,CAKnC;IAED,OAAO,CAAC,yBAAyB;IA8BjC,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,gBAAgB;IASxB,OAAO,CAAC,uBAAuB;IAyB/B,OAAO,CAAC,sBAAsB,CAAC,CAAY;IAE3C,OAAO,CAAC,oBAAoB;IAoE5B,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,KAAK;CAGd"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AnySchema, ApiVersion, ArraySchema, BinaryResponse, BinarySchema, BooleanSchema, ByteArraySchema, ChoiceValue, DateSchema, DateTimeSchema, DictionarySchema, Discriminator, GroupProperty, GroupSchema, HttpHeader, HttpParameter, ImplementationLocation, KeySecurityScheme, Language, Metadata, NumberSchema, OAuth2SecurityScheme, ObjectSchema, OperationGroup, Parameter, ParameterLocation, Property, Relations, Response, SchemaResponse, SchemaType, Security, SerializationStyle, StringSchema, TimeSchema, UnixTimeSchema, UriSchema, VirtualParameter, } from "@autorest/codemodel";
|
|
2
2
|
import { KnownMediaType } from "@azure-tools/codegen";
|
|
3
3
|
import { getLroMetadata, getPagedResult, isPollingLocation } from "@azure-tools/typespec-azure-core";
|
|
4
|
-
import { createSdkContext, getAllModels, getClientNameOverride, getClientType, getCrossLanguageDefinitionId, getDefaultApiVersion, getHttpOperationWithCache, getWireName, isApiVersion, isInternal, isSdkBuiltInKind, isSdkIntKind, listClients, listOperationGroups, listOperationsInOperationGroup, shouldGenerateConvenient, shouldGenerateProtocol, } from "@azure-tools/typespec-client-generator-core";
|
|
4
|
+
import { createSdkContext, getAllModels, getClientNameOverride, getClientType, getCrossLanguageDefinitionId, getDefaultApiVersion, getHttpOperationWithCache, getWireName, isApiVersion, isInternal, isSdkBuiltInKind, isSdkIntKind, listClients, listOperationGroups, listOperationsInOperationGroup, shouldGenerateConvenient, shouldGenerateProtocol, getHttpOperationExamples, } from "@azure-tools/typespec-client-generator-core";
|
|
5
5
|
import { getDoc, getEffectiveModelType, getEncode, getFriendlyName, getNamespaceFullName, getOverloadedOperation, getProjectedName, getSummary, getVisibility, isArrayModelType, isErrorModel, isRecordModelType, isVoidType, listServices, } from "@typespec/compiler";
|
|
6
6
|
import { Visibility, getAuthentication, getHeaderFieldName, getHeaderFieldOptions, getPathParamName, getQueryParamName, getQueryParamOptions, getServers, getStatusCodeDescription, isHeader, isPathParam, isQueryParam, } from "@typespec/http";
|
|
7
7
|
import { getResourceOperation, getSegment } from "@typespec/rest";
|
|
8
8
|
import { getAddedOnVersions, getVersion } from "@typespec/versioning";
|
|
9
9
|
import { fail } from "assert";
|
|
10
10
|
import pkg from "lodash";
|
|
11
|
-
import { Client as CodeModelClient
|
|
11
|
+
import { Client as CodeModelClient } from "./common/client.js";
|
|
12
12
|
import { CodeModel } from "./common/code-model.js";
|
|
13
13
|
import { LongRunningMetadata } from "./common/long-running-metadata.js";
|
|
14
14
|
import { Operation as CodeModelOperation, ConvenienceApi, Request } from "./common/operation.js";
|
|
@@ -19,10 +19,11 @@ import { DurationSchema } from "./common/schemas/time.js";
|
|
|
19
19
|
import { SchemaContext } from "./common/schemas/usage.js";
|
|
20
20
|
import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./external-schemas.js";
|
|
21
21
|
import { ClientContext } from "./models.js";
|
|
22
|
-
import { ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, isPayloadProperty,
|
|
22
|
+
import { ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, isPayloadProperty, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
|
|
23
23
|
import { PreNamer } from "./prenamer/prenamer.js";
|
|
24
24
|
import { ProcessingCache, getAccess, getDurationFormatFromSdkType, getNonNullSdkType, getUnionDescription, getUsage, hasScalarAsBase, isArmCommonType, isModelReferredInTemplate, isNullableType, isStable, modelIs, pushDistinct, } from "./type-utils.js";
|
|
25
|
-
import {
|
|
25
|
+
import { getNamespace, logWarning, pascalCase, stringArrayContainsIgnoreCase, trace } from "./utils.js";
|
|
26
|
+
import { pathToFileURL } from "url";
|
|
26
27
|
const { isEqual } = pkg;
|
|
27
28
|
export class CodeModelBuilder {
|
|
28
29
|
constructor(program1, context) {
|
|
@@ -30,30 +31,30 @@ export class CodeModelBuilder {
|
|
|
30
31
|
this.loggingEnabled = false;
|
|
31
32
|
this.schemaCache = new ProcessingCache((type, name) => this.processSchemaFromSdkTypeImpl(type, name));
|
|
32
33
|
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
|
|
33
|
-
this.operationExamples = new Map();
|
|
34
34
|
this.options = context.options;
|
|
35
35
|
this.program = program1;
|
|
36
|
+
this.emitterContext = context;
|
|
36
37
|
if ((_a = this.options["dev-options"]) === null || _a === void 0 ? void 0 : _a.loglevel) {
|
|
37
38
|
this.loggingEnabled = true;
|
|
38
39
|
}
|
|
39
40
|
if (this.options["skip-special-headers"]) {
|
|
40
41
|
this.options["skip-special-headers"].forEach((it) => SPECIAL_HEADER_NAMES.add(it.toLowerCase()));
|
|
41
42
|
}
|
|
42
|
-
this.sdkContext = createSdkContext(context, "@azure-tools/typespec-java");
|
|
43
43
|
const service = listServices(this.program)[0];
|
|
44
44
|
const serviceNamespace = service.type;
|
|
45
45
|
if (serviceNamespace === undefined) {
|
|
46
46
|
throw Error("Cannot emit yaml for a namespace that doesn't exist.");
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
this.serviceNamespace = serviceNamespace;
|
|
49
49
|
this.namespace = getNamespaceFullName(serviceNamespace) || "Azure.Client";
|
|
50
|
-
|
|
50
|
+
// java namespace
|
|
51
|
+
const javaNamespace = this.getJavaNamespace(this.namespace);
|
|
51
52
|
const namespace1 = this.namespace;
|
|
52
53
|
this.typeNameOptions = {
|
|
53
54
|
// shorten type names by removing TypeSpec and service namespace
|
|
54
55
|
namespaceFilter(ns) {
|
|
55
56
|
const name = getNamespaceFullName(ns);
|
|
56
|
-
return name !== "
|
|
57
|
+
return name !== "TypeSpec" && name !== namespace1;
|
|
57
58
|
},
|
|
58
59
|
};
|
|
59
60
|
// init code model
|
|
@@ -75,15 +76,15 @@ export class CodeModelBuilder {
|
|
|
75
76
|
},
|
|
76
77
|
},
|
|
77
78
|
});
|
|
79
|
+
}
|
|
80
|
+
async build() {
|
|
81
|
+
this.sdkContext = await createSdkContext(this.emitterContext, "@azure-tools/typespec-java");
|
|
78
82
|
// auth
|
|
79
83
|
// TODO: it is not very likely, but different client could have different auth
|
|
80
|
-
const auth = getAuthentication(this.program, serviceNamespace);
|
|
84
|
+
const auth = getAuthentication(this.program, this.serviceNamespace);
|
|
81
85
|
if (auth) {
|
|
82
86
|
this.processAuth(auth);
|
|
83
87
|
}
|
|
84
|
-
}
|
|
85
|
-
async build() {
|
|
86
|
-
this.operationExamples = await loadExamples(this.program, this.options, this.sdkContext);
|
|
87
88
|
if (this.sdkContext.arm) {
|
|
88
89
|
// ARM
|
|
89
90
|
this.codeModel.arm = true;
|
|
@@ -321,8 +322,24 @@ export class CodeModelBuilder {
|
|
|
321
322
|
// preprocess group-etag-headers
|
|
322
323
|
this.options["group-etag-headers"] = (_a = this.options["group-etag-headers"]) !== null && _a !== void 0 ? _a : true;
|
|
323
324
|
for (const client of clients) {
|
|
324
|
-
|
|
325
|
+
let clientName = client.name;
|
|
326
|
+
let javaNamespace = this.getJavaNamespace(this.namespace);
|
|
327
|
+
const clientFullName = client.name;
|
|
328
|
+
const clientNameSegments = clientFullName.split(".");
|
|
329
|
+
if (clientNameSegments.length > 1) {
|
|
330
|
+
clientName = clientNameSegments.at(-1);
|
|
331
|
+
javaNamespace = this.getJavaNamespace(this.namespace + "." + clientNameSegments.slice(0, -1).join("."));
|
|
332
|
+
}
|
|
333
|
+
const codeModelClient = new CodeModelClient(clientName, this.getDoc(client.type), {
|
|
325
334
|
summary: this.getSummary(client.type),
|
|
335
|
+
language: {
|
|
336
|
+
default: {
|
|
337
|
+
namespace: this.namespace,
|
|
338
|
+
},
|
|
339
|
+
java: {
|
|
340
|
+
namespace: javaNamespace,
|
|
341
|
+
},
|
|
342
|
+
},
|
|
326
343
|
// at present, use global security definition
|
|
327
344
|
security: this.codeModel.security,
|
|
328
345
|
});
|
|
@@ -473,36 +490,33 @@ export class CodeModelBuilder {
|
|
|
473
490
|
}
|
|
474
491
|
getOperationExample(operation) {
|
|
475
492
|
var _a, _b;
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
operation = operation.sourceOperation;
|
|
485
|
-
if (((_b = operation.projectionSource) === null || _b === void 0 ? void 0 : _b.kind) === "Operation") {
|
|
486
|
-
operation = operation.projectionSource;
|
|
493
|
+
const httpOperationExamples = getHttpOperationExamples(this.sdkContext, operation);
|
|
494
|
+
if (httpOperationExamples && httpOperationExamples.length > 0) {
|
|
495
|
+
const operationExamples = {};
|
|
496
|
+
for (const example of httpOperationExamples) {
|
|
497
|
+
const operationExample = example.rawExample;
|
|
498
|
+
operationExample["x-ms-original-file"] = pathToFileURL(example.filePath).toString();
|
|
499
|
+
operationExamples[(_b = (_a = operationExample.title) !== null && _a !== void 0 ? _a : operationExample.operationId) !== null && _b !== void 0 ? _b : operation.operation.name] =
|
|
500
|
+
operationExample;
|
|
487
501
|
}
|
|
488
|
-
|
|
502
|
+
return operationExamples;
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
return undefined;
|
|
489
506
|
}
|
|
490
|
-
return operationExample;
|
|
491
507
|
}
|
|
492
508
|
processOperation(groupName, operation, clientContext) {
|
|
493
|
-
var _a
|
|
509
|
+
var _a;
|
|
494
510
|
const op = getHttpOperationWithCache(this.sdkContext, operation);
|
|
495
511
|
const operationGroup = this.codeModel.getOperationGroup(groupName);
|
|
496
512
|
const operationName = this.getName(operation);
|
|
497
513
|
const opId = groupName ? `${groupName}_${operationName}` : `${operationName}`;
|
|
498
|
-
const
|
|
514
|
+
const operationExamples = this.getOperationExample(op);
|
|
499
515
|
const codeModelOperation = new CodeModelOperation(operationName, this.getDoc(operation), {
|
|
500
516
|
operationId: opId,
|
|
501
517
|
summary: this.getSummary(operation),
|
|
502
518
|
extensions: {
|
|
503
|
-
"x-ms-examples":
|
|
504
|
-
? { [(_b = (_a = operationExample.title) !== null && _a !== void 0 ? _a : operationExample.operationId) !== null && _b !== void 0 ? _b : operation.name]: operationExample }
|
|
505
|
-
: undefined,
|
|
519
|
+
"x-ms-examples": operationExamples,
|
|
506
520
|
},
|
|
507
521
|
});
|
|
508
522
|
codeModelOperation.crossLanguageDefinitionId = getCrossLanguageDefinitionId(this.sdkContext, operation);
|
|
@@ -579,7 +593,7 @@ export class CodeModelBuilder {
|
|
|
579
593
|
let bodyType = op.parameters.body.type;
|
|
580
594
|
if (bodyType.kind === "Model") {
|
|
581
595
|
// try use resource type as round-trip model
|
|
582
|
-
const resourceType = (
|
|
596
|
+
const resourceType = (_a = getResourceOperation(this.program, operation)) === null || _a === void 0 ? void 0 : _a.resourceType;
|
|
583
597
|
if (resourceType && op.responses && op.responses.length > 0) {
|
|
584
598
|
const resp = op.responses[0];
|
|
585
599
|
if (resp.responses && resp.responses.length > 0 && resp.responses[0].body) {
|
|
@@ -653,7 +667,7 @@ export class CodeModelBuilder {
|
|
|
653
667
|
language: {
|
|
654
668
|
java: {
|
|
655
669
|
name: "OperationLocationPollingStrategy",
|
|
656
|
-
namespace: getJavaNamespace(this.namespace) + ".implementation",
|
|
670
|
+
namespace: this.getJavaNamespace(this.namespace) + ".implementation",
|
|
657
671
|
},
|
|
658
672
|
},
|
|
659
673
|
});
|
|
@@ -1108,7 +1122,7 @@ export class CodeModelBuilder {
|
|
|
1108
1122
|
namespace: namespace,
|
|
1109
1123
|
},
|
|
1110
1124
|
java: {
|
|
1111
|
-
namespace: getJavaNamespace(namespace),
|
|
1125
|
+
namespace: this.getJavaNamespace(namespace),
|
|
1112
1126
|
},
|
|
1113
1127
|
},
|
|
1114
1128
|
}));
|
|
@@ -1331,16 +1345,7 @@ export class CodeModelBuilder {
|
|
|
1331
1345
|
case "any":
|
|
1332
1346
|
return this.processAnySchemaFromSdkType();
|
|
1333
1347
|
case "string":
|
|
1334
|
-
|
|
1335
|
-
case "guid":
|
|
1336
|
-
case "ipAddress":
|
|
1337
|
-
case "uuid":
|
|
1338
|
-
case "ipV4Address":
|
|
1339
|
-
case "ipV6Address":
|
|
1340
|
-
case "eTag":
|
|
1341
|
-
case "armId":
|
|
1342
|
-
case "azureLocation":
|
|
1343
|
-
return this.processStringSchemaFromSdkType(type, type.kind);
|
|
1348
|
+
return this.processStringSchemaFromSdkType(type, nameHint);
|
|
1344
1349
|
case "float":
|
|
1345
1350
|
case "float32":
|
|
1346
1351
|
case "float64":
|
|
@@ -1357,7 +1362,6 @@ export class CodeModelBuilder {
|
|
|
1357
1362
|
case "plainDate":
|
|
1358
1363
|
return this.processDateSchemaFromSdkType(type, nameHint);
|
|
1359
1364
|
case "url":
|
|
1360
|
-
case "uri":
|
|
1361
1365
|
return this.processUrlSchemaFromSdkType(type, nameHint);
|
|
1362
1366
|
}
|
|
1363
1367
|
}
|
|
@@ -1455,7 +1459,7 @@ export class CodeModelBuilder {
|
|
|
1455
1459
|
namespace: namespace,
|
|
1456
1460
|
},
|
|
1457
1461
|
java: {
|
|
1458
|
-
namespace: getJavaNamespace(namespace),
|
|
1462
|
+
namespace: this.getJavaNamespace(namespace),
|
|
1459
1463
|
},
|
|
1460
1464
|
},
|
|
1461
1465
|
});
|
|
@@ -1522,14 +1526,14 @@ export class CodeModelBuilder {
|
|
|
1522
1526
|
var _a, _b;
|
|
1523
1527
|
const rawModelType = type.__raw;
|
|
1524
1528
|
const namespace = getNamespace(rawModelType);
|
|
1525
|
-
const objectSchema = new
|
|
1529
|
+
const objectSchema = new ObjectSchema(name, (_a = type.details) !== null && _a !== void 0 ? _a : "", {
|
|
1526
1530
|
summary: type.description,
|
|
1527
1531
|
language: {
|
|
1528
1532
|
default: {
|
|
1529
1533
|
namespace: namespace,
|
|
1530
1534
|
},
|
|
1531
1535
|
java: {
|
|
1532
|
-
namespace: getJavaNamespace(namespace),
|
|
1536
|
+
namespace: this.getJavaNamespace(namespace),
|
|
1533
1537
|
},
|
|
1534
1538
|
},
|
|
1535
1539
|
});
|
|
@@ -1576,6 +1580,8 @@ export class CodeModelBuilder {
|
|
|
1576
1580
|
kind: "string",
|
|
1577
1581
|
encode: "string",
|
|
1578
1582
|
decorators: [],
|
|
1583
|
+
name: "string",
|
|
1584
|
+
crossLanguageDefinitionId: type.crossLanguageDefinitionId,
|
|
1579
1585
|
},
|
|
1580
1586
|
description: type.description,
|
|
1581
1587
|
valueType: type.additionalProperties,
|
|
@@ -1621,7 +1627,7 @@ export class CodeModelBuilder {
|
|
|
1621
1627
|
nullable = true;
|
|
1622
1628
|
nonNullType = nonNullType.type;
|
|
1623
1629
|
}
|
|
1624
|
-
let schema
|
|
1630
|
+
let schema;
|
|
1625
1631
|
let extensions = undefined;
|
|
1626
1632
|
if (this.isSecret(prop)) {
|
|
1627
1633
|
extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
@@ -1638,8 +1644,17 @@ export class CodeModelBuilder {
|
|
|
1638
1644
|
extensions = extensions !== null && extensions !== void 0 ? extensions : {};
|
|
1639
1645
|
extensions["x-ms-mutability"] = mutability;
|
|
1640
1646
|
}
|
|
1641
|
-
if (prop.kind === "property" && prop.
|
|
1642
|
-
|
|
1647
|
+
if (prop.kind === "property" && prop.multipartOptions) {
|
|
1648
|
+
// TODO: handle MultipartOptions.isMulti
|
|
1649
|
+
if (prop.multipartOptions.isFilePart) {
|
|
1650
|
+
schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop);
|
|
1651
|
+
}
|
|
1652
|
+
else {
|
|
1653
|
+
schema = this.processSchemaFromSdkType(nonNullType, "");
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
else {
|
|
1657
|
+
schema = this.processSchemaFromSdkType(nonNullType, "");
|
|
1643
1658
|
}
|
|
1644
1659
|
return new Property(prop.name, (_a = prop.details) !== null && _a !== void 0 ? _a : "", schema, {
|
|
1645
1660
|
summary: prop.description,
|
|
@@ -1676,7 +1691,7 @@ export class CodeModelBuilder {
|
|
|
1676
1691
|
namespace: namespace,
|
|
1677
1692
|
},
|
|
1678
1693
|
java: {
|
|
1679
|
-
namespace: getJavaNamespace(namespace),
|
|
1694
|
+
namespace: this.getJavaNamespace(namespace),
|
|
1680
1695
|
},
|
|
1681
1696
|
},
|
|
1682
1697
|
});
|
|
@@ -1754,15 +1769,25 @@ export class CodeModelBuilder {
|
|
|
1754
1769
|
throw new Error(`Unrecognized type for union variable: '${type.kind}'.`);
|
|
1755
1770
|
}
|
|
1756
1771
|
}
|
|
1757
|
-
processMultipartFormDataFilePropertySchemaFromSdkType(property
|
|
1758
|
-
var _a;
|
|
1759
|
-
|
|
1760
|
-
|
|
1772
|
+
processMultipartFormDataFilePropertySchemaFromSdkType(property) {
|
|
1773
|
+
var _a, _b, _c, _d;
|
|
1774
|
+
const processSchemaFunc = (type) => this.processSchemaFromSdkType(type, "");
|
|
1775
|
+
if (property.type.kind === "bytes" || property.type.kind === "model") {
|
|
1776
|
+
const namespace = property.type.kind === "model" ? ((_a = getNamespace(property.type.__raw)) !== null && _a !== void 0 ? _a : this.namespace) : this.namespace;
|
|
1777
|
+
return getFileDetailsSchema(property, (_b = getNamespace(property.type.__raw)) !== null && _b !== void 0 ? _b : this.namespace, namespace, this.codeModel.schemas, this.binarySchema, this.stringSchema, processSchemaFunc);
|
|
1778
|
+
}
|
|
1779
|
+
else if (property.type.kind === "array" &&
|
|
1780
|
+
(property.type.valueType.kind === "bytes" || property.type.valueType.kind === "model")) {
|
|
1781
|
+
const namespace = property.type.valueType.kind === "model"
|
|
1782
|
+
? ((_c = getNamespace(property.type.valueType.__raw)) !== null && _c !== void 0 ? _c : this.namespace)
|
|
1783
|
+
: this.namespace;
|
|
1784
|
+
return new ArraySchema(property.name, (_d = property.details) !== null && _d !== void 0 ? _d : "", getFileDetailsSchema(property, namespace, this.getJavaNamespace(namespace), this.codeModel.schemas, this.binarySchema, this.stringSchema, processSchemaFunc), {
|
|
1785
|
+
summary: property.description,
|
|
1786
|
+
});
|
|
1761
1787
|
}
|
|
1762
|
-
else
|
|
1763
|
-
|
|
1788
|
+
else {
|
|
1789
|
+
throw new Error(`Invalid type for multipart form data: '${property.type.kind}'.`);
|
|
1764
1790
|
}
|
|
1765
|
-
throw new Error(`Invalid type for multipart form data: '${property.type.kind}'.`);
|
|
1766
1791
|
}
|
|
1767
1792
|
getDoc(target) {
|
|
1768
1793
|
return target ? getDoc(this.program, target) || "" : "";
|
|
@@ -1869,6 +1894,19 @@ export class CodeModelBuilder {
|
|
|
1869
1894
|
return undefined;
|
|
1870
1895
|
}
|
|
1871
1896
|
}
|
|
1897
|
+
getJavaNamespace(namespace) {
|
|
1898
|
+
const tspNamespace = this.namespace;
|
|
1899
|
+
const baseJavaNamespace = this.emitterContext.options.namespace;
|
|
1900
|
+
if (!namespace) {
|
|
1901
|
+
return undefined;
|
|
1902
|
+
}
|
|
1903
|
+
else if (baseJavaNamespace && (namespace === tspNamespace || namespace.startsWith(tspNamespace + "."))) {
|
|
1904
|
+
return baseJavaNamespace + namespace.slice(tspNamespace.length).toLowerCase();
|
|
1905
|
+
}
|
|
1906
|
+
else {
|
|
1907
|
+
return "com." + namespace.toLowerCase();
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1872
1910
|
logWarning(msg) {
|
|
1873
1911
|
if (this.loggingEnabled) {
|
|
1874
1912
|
logWarning(this.program, msg);
|