@azure-tools/typespec-java 0.20.1 → 0.21.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.
Files changed (68) hide show
  1. package/dist/src/code-model-builder.d.ts.map +1 -1
  2. package/dist/src/code-model-builder.js +89 -47
  3. package/dist/src/code-model-builder.js.map +1 -1
  4. package/dist/src/common/client.d.ts +1 -1
  5. package/dist/src/common/client.d.ts.map +1 -1
  6. package/dist/src/common/client.js +1 -0
  7. package/dist/src/common/client.js.map +1 -1
  8. package/dist/src/common/code-model.d.ts +1 -1
  9. package/dist/src/common/code-model.d.ts.map +1 -1
  10. package/dist/src/common/code-model.js +2 -1
  11. package/dist/src/common/code-model.js.map +1 -1
  12. package/dist/src/common/operation.d.ts +2 -2
  13. package/dist/src/common/operation.d.ts.map +1 -1
  14. package/dist/src/common/operation.js +2 -1
  15. package/dist/src/common/operation.js.map +1 -1
  16. package/dist/src/common/schemas/choice.d.ts.map +1 -1
  17. package/dist/src/common/schemas/choice.js +2 -1
  18. package/dist/src/common/schemas/choice.js.map +1 -1
  19. package/dist/src/common/schemas/constant.d.ts +1 -1
  20. package/dist/src/common/schemas/constant.d.ts.map +1 -1
  21. package/dist/src/common/schemas/constant.js +1 -0
  22. package/dist/src/common/schemas/constant.js.map +1 -1
  23. package/dist/src/common/schemas/relationship.d.ts +2 -3
  24. package/dist/src/common/schemas/relationship.d.ts.map +1 -1
  25. package/dist/src/common/schemas/relationship.js +2 -2
  26. package/dist/src/common/schemas/relationship.js.map +1 -1
  27. package/dist/src/common/schemas/time.d.ts +1 -1
  28. package/dist/src/common/schemas/time.d.ts.map +1 -1
  29. package/dist/src/common/schemas/time.js +1 -0
  30. package/dist/src/common/schemas/time.js.map +1 -1
  31. package/dist/src/emitter.d.ts +5 -6
  32. package/dist/src/emitter.d.ts.map +1 -1
  33. package/dist/src/emitter.js +12 -14
  34. package/dist/src/emitter.js.map +1 -1
  35. package/dist/src/external-schemas.d.ts.map +1 -1
  36. package/dist/src/external-schemas.js +3 -2
  37. package/dist/src/external-schemas.js.map +1 -1
  38. package/dist/src/models.d.ts +1 -3
  39. package/dist/src/models.d.ts.map +1 -1
  40. package/dist/src/models.js +2 -29
  41. package/dist/src/models.js.map +1 -1
  42. package/dist/src/operation-utils.d.ts +3 -3
  43. package/dist/src/operation-utils.d.ts.map +1 -1
  44. package/dist/src/operation-utils.js +2 -2
  45. package/dist/src/operation-utils.js.map +1 -1
  46. package/dist/src/type-utils.d.ts +5 -5
  47. package/dist/src/type-utils.d.ts.map +1 -1
  48. package/dist/src/type-utils.js +51 -14
  49. package/dist/src/type-utils.js.map +1 -1
  50. package/dist/src/utils.d.ts.map +1 -1
  51. package/dist/src/utils.js +10 -4
  52. package/dist/src/utils.js.map +1 -1
  53. package/dist/tsconfig.tsbuildinfo +1 -1
  54. package/{target → generator/http-client-generator/target}/emitter.jar +0 -0
  55. package/package.json +28 -28
  56. package/readme.md +2 -2
  57. package/dist/src/prenamer/formatter.d.ts +0 -11
  58. package/dist/src/prenamer/formatter.d.ts.map +0 -1
  59. package/dist/src/prenamer/formatter.js +0 -124
  60. package/dist/src/prenamer/formatter.js.map +0 -1
  61. package/dist/src/prenamer/naming-utils.d.ts +0 -67
  62. package/dist/src/prenamer/naming-utils.d.ts.map +0 -1
  63. package/dist/src/prenamer/naming-utils.js +0 -147
  64. package/dist/src/prenamer/naming-utils.js.map +0 -1
  65. package/dist/src/prenamer/prenamer.d.ts +0 -36
  66. package/dist/src/prenamer/prenamer.d.ts.map +0 -1
  67. package/dist/src/prenamer/prenamer.js +0 -333
  68. package/dist/src/prenamer/prenamer.js.map +0 -1
@@ -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,MA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CAAC,iBAAiB;IAazB,OAAO,CAAC,UAAU;IAoBlB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,aAAa;IAuBrB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,gBAAgB;IAexB,OAAO,CAAC,UAAU;IAMlB,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,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 } from "./common/client.js";
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";
@@ -19,7 +19,6 @@ import { SchemaContext } from "./common/schemas/usage.js";
19
19
  import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./external-schemas.js";
20
20
  import { ClientContext } from "./models.js";
21
21
  import { CONTENT_TYPE_KEY, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, isPayloadProperty, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
22
- import { PreNamer } from "./prenamer/prenamer.js";
23
22
  import { ProcessingCache, getAccess, getDurationFormatFromSdkType, getNonNullSdkType, getUnionDescription, getUsage, isStable, modelIs, pushDistinct, } from "./type-utils.js";
24
23
  import { getNamespace, logWarning, pascalCase, removeClientSuffix, stringArrayContainsIgnoreCase, trace, } from "./utils.js";
25
24
  const { isEqual } = pkg;
@@ -39,12 +38,11 @@ export class CodeModelBuilder {
39
38
  this.options["skip-special-headers"].forEach((it) => SPECIAL_HEADER_NAMES.add(it.toLowerCase()));
40
39
  }
41
40
  const service = listServices(this.program)[0];
42
- const serviceNamespace = service.type;
43
- if (serviceNamespace === undefined) {
44
- throw Error("Cannot emit yaml for a namespace that doesn't exist.");
41
+ if (!service) {
42
+ throw Error("TypeSpec for HTTP must define a service.");
45
43
  }
46
- this.serviceNamespace = serviceNamespace;
47
- this.namespace = getNamespaceFullName(serviceNamespace) || "Azure.Client";
44
+ this.serviceNamespace = service.type;
45
+ this.namespace = getNamespaceFullName(this.serviceNamespace) || "Azure.Client";
48
46
  // java namespace
49
47
  const javaNamespace = this.getJavaNamespace(this.namespace);
50
48
  const namespace1 = this.namespace;
@@ -56,8 +54,8 @@ export class CodeModelBuilder {
56
54
  },
57
55
  };
58
56
  // init code model
59
- const title = (_b = this.options["service-name"]) !== null && _b !== void 0 ? _b : serviceNamespace.name;
60
- const description = this.getDoc(serviceNamespace);
57
+ const title = (_b = this.options["service-name"]) !== null && _b !== void 0 ? _b : this.serviceNamespace.name;
58
+ const description = this.getDoc(this.serviceNamespace);
61
59
  this.codeModel = new CodeModel(title, false, {
62
60
  info: {
63
61
  description: description,
@@ -66,7 +64,7 @@ export class CodeModelBuilder {
66
64
  default: {
67
65
  name: title,
68
66
  description: description,
69
- summary: this.getSummary(serviceNamespace),
67
+ summary: this.getSummary(this.serviceNamespace),
70
68
  namespace: this.namespace,
71
69
  },
72
70
  java: {
@@ -93,9 +91,6 @@ export class CodeModelBuilder {
93
91
  this.processClients();
94
92
  this.processModels();
95
93
  this.processSchemaUsage();
96
- if (this.options.namer) {
97
- this.codeModel = new PreNamer(this.codeModel).init().process();
98
- }
99
94
  this.deduplicateSchemaName();
100
95
  return this.codeModel;
101
96
  }
@@ -121,7 +116,7 @@ export class CodeModelBuilder {
121
116
  },
122
117
  language: {
123
118
  default: {
124
- serializedName: arg.name,
119
+ serializedName: arg.serializedName,
125
120
  },
126
121
  },
127
122
  // TODO: deprecate this logic of string/url for x-ms-skip-url-encoding
@@ -190,20 +185,21 @@ export class CodeModelBuilder {
190
185
  }
191
186
  processModels() {
192
187
  const processedSdkModels = new Set();
193
- // lambda to mark model as public
194
- const modelAsPublic = (model) => {
195
- const schema = this.processSchemaFromSdkType(model, "");
196
- this.trackSchemaUsage(schema, {
197
- usage: [SchemaContext.Public],
198
- });
199
- };
188
+ // cache resolved value of access/usage for the namespace
189
+ // the value can be set as undefined
190
+ // it resolves the value from that namespace and its parent namespaces
191
+ const accessCache = new Map();
192
+ const usageCache = new Map();
200
193
  const sdkModels = getAllModels(this.sdkContext);
201
194
  // process sdk models
202
195
  for (const model of sdkModels) {
203
196
  if (!processedSdkModels.has(model)) {
204
- const access = getAccess(model.__raw);
197
+ const access = getAccess(model.__raw, accessCache);
205
198
  if (access === "public") {
206
- modelAsPublic(model);
199
+ const schema = this.processSchemaFromSdkType(model, "");
200
+ this.trackSchemaUsage(schema, {
201
+ usage: [SchemaContext.Public],
202
+ });
207
203
  }
208
204
  else if (access === "internal") {
209
205
  const schema = this.processSchemaFromSdkType(model, model.name);
@@ -211,7 +207,7 @@ export class CodeModelBuilder {
211
207
  usage: [SchemaContext.Internal],
212
208
  });
213
209
  }
214
- const usage = getUsage(model.__raw);
210
+ const usage = getUsage(model.__raw, usageCache);
215
211
  if (usage) {
216
212
  const schema = this.processSchemaFromSdkType(model, "");
217
213
  this.trackSchemaUsage(schema, {
@@ -436,7 +432,8 @@ export class CodeModelBuilder {
436
432
  const subClient = method.response;
437
433
  if (!isRootClient) {
438
434
  // if it is not root client, append the parent client's name
439
- subClient.name = removeClientSuffix(client.name) + removeClientSuffix(pascalCase(subClient.name));
435
+ subClient.name =
436
+ removeClientSuffix(client.name) + removeClientSuffix(pascalCase(subClient.name));
440
437
  }
441
438
  operationGroups.push(subClient);
442
439
  if (includeNestedOperationGroups) {
@@ -523,7 +520,8 @@ export class CodeModelBuilder {
523
520
  "x-ms-examples": operationExamples,
524
521
  },
525
522
  });
526
- codeModelOperation.crossLanguageDefinitionId = sdkMethod.crossLanguageDefintionId;
523
+ codeModelOperation.crossLanguageDefinitionId =
524
+ sdkMethod.crossLanguageDefintionId;
527
525
  codeModelOperation.internalApi = sdkMethod.access === "internal";
528
526
  const convenienceApiName = this.getConvenienceApiName(sdkMethod);
529
527
  let generateConvenienceApi = sdkMethod.generateConvenient;
@@ -544,7 +542,8 @@ export class CodeModelBuilder {
544
542
  apiComment = `Convenience API is not generated, as operation '${operationName}' is multiple content-type`;
545
543
  this.logWarning(apiComment);
546
544
  }
547
- else if (operationIsJsonMergePatch(httpOperation) && this.options["stream-style-serialization"] === false) {
545
+ else if (operationIsJsonMergePatch(httpOperation) &&
546
+ this.options["stream-style-serialization"] === false) {
548
547
  // do not generate convenient method for json merge patch operation if stream-style-serialization is not enabled
549
548
  generateConvenienceApi = false;
550
549
  apiComment = `Convenience API is not generated, as operation '${operationName}' is 'application/merge-patch+json' and stream-style-serialization is not enabled`;
@@ -680,7 +679,9 @@ export class CodeModelBuilder {
680
679
  lroMetadata.finalEnvelopeResult &&
681
680
  lroMetadata.finalResult !== "void" &&
682
681
  lroMetadata.finalEnvelopeResult !== "void") {
683
- const finalResult = useNewPollStrategy ? lroMetadata.finalResult : lroMetadata.finalEnvelopeResult;
682
+ const finalResult = useNewPollStrategy
683
+ ? lroMetadata.finalResult
684
+ : lroMetadata.finalEnvelopeResult;
684
685
  const finalType = this.findResponseBody(finalResult);
685
686
  const sdkType = getClientType(this.sdkContext, finalType);
686
687
  finalSchema = this.processSchemaFromSdkType(sdkType, "finalResult");
@@ -747,7 +748,8 @@ export class CodeModelBuilder {
747
748
  op.addParameter(parameter);
748
749
  clientContext.addGlobalParameter(parameter);
749
750
  }
750
- else if (param.kind === "header" && SPECIAL_HEADER_NAMES.has(param.serializedName.toLowerCase())) {
751
+ else if (param.kind === "header" &&
752
+ SPECIAL_HEADER_NAMES.has(param.serializedName.toLowerCase())) {
751
753
  // special headers
752
754
  op.specialHeaders = (_a = op.specialHeaders) !== null && _a !== void 0 ? _a : [];
753
755
  if (!stringArrayContainsIgnoreCase(op.specialHeaders, param.serializedName)) {
@@ -806,6 +808,10 @@ export class CodeModelBuilder {
806
808
  explode = true;
807
809
  break;
808
810
  }
811
+ if (param.explode && !param.collectionFormat) {
812
+ style = SerializationStyle.Form;
813
+ explode = true;
814
+ }
809
815
  }
810
816
  else if (param.kind === "header") {
811
817
  const format = param.collectionFormat;
@@ -821,10 +827,17 @@ export class CodeModelBuilder {
821
827
  }
822
828
  }
823
829
  }
830
+ // TODO: use param.onClient after TCGC fix
831
+ const parameterOnClient = !isApiVersion(this.sdkContext, param) &&
832
+ param.correspondingMethodParams &&
833
+ param.correspondingMethodParams.length > 0 &&
834
+ param.correspondingMethodParams[0].onClient;
824
835
  const nullable = param.type.kind === "nullable";
825
836
  const parameter = new Parameter(param.name, (_b = param.details) !== null && _b !== void 0 ? _b : "", schema, {
826
837
  summary: param.description,
827
- implementation: ImplementationLocation.Method,
838
+ implementation: parameterOnClient
839
+ ? ImplementationLocation.Client
840
+ : ImplementationLocation.Method,
828
841
  required: !param.optional,
829
842
  nullable: nullable,
830
843
  protocol: {
@@ -841,9 +854,14 @@ export class CodeModelBuilder {
841
854
  extensions: extensions,
842
855
  });
843
856
  op.addParameter(parameter);
857
+ if (parameterOnClient) {
858
+ clientContext.addGlobalParameter(parameter);
859
+ }
844
860
  this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] });
845
861
  if (op.convenienceApi) {
846
- this.trackSchemaUsage(schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public] });
862
+ this.trackSchemaUsage(schema, {
863
+ usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public],
864
+ });
847
865
  }
848
866
  }
849
867
  }
@@ -873,7 +891,8 @@ export class CodeModelBuilder {
873
891
  }
874
892
  else if (etagHeaders.length === 2) {
875
893
  const etagHeadersLowerCase = etagHeaders.map((it) => it.toLowerCase());
876
- if (etagHeadersLowerCase.includes("if-match") && etagHeadersLowerCase.includes("if-none-match")) {
894
+ if (etagHeadersLowerCase.includes("if-match") &&
895
+ etagHeadersLowerCase.includes("if-none-match")) {
877
896
  // only 2 headers available, use MatchConditions
878
897
  groupToMatchConditions = true;
879
898
  }
@@ -975,11 +994,14 @@ export class CodeModelBuilder {
975
994
  });
976
995
  op.addParameter(parameter);
977
996
  const jsonMergePatch = operationIsJsonMergePatch(sdkHttpOperation);
978
- const schemaIsPublicBeforeProcess = schema instanceof ObjectSchema && ((_b = schema.usage) === null || _b === void 0 ? void 0 : _b.includes(SchemaContext.Public));
997
+ const schemaIsPublicBeforeProcess = schema instanceof ObjectSchema &&
998
+ ((_b = schema.usage) === null || _b === void 0 ? void 0 : _b.includes(SchemaContext.Public));
979
999
  this.trackSchemaUsage(schema, { usage: [SchemaContext.Input] });
980
1000
  if (op.convenienceApi) {
981
1001
  // model/schema does not need to be Public or Internal, if it is not to be used in convenience API
982
- this.trackSchemaUsage(schema, { usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public] });
1002
+ this.trackSchemaUsage(schema, {
1003
+ usage: [op.internalApi ? SchemaContext.Internal : SchemaContext.Public],
1004
+ });
983
1005
  }
984
1006
  if (jsonMergePatch) {
985
1007
  this.trackSchemaUsage(schema, { usage: [SchemaContext.JsonMergePatch] });
@@ -988,7 +1010,7 @@ export class CodeModelBuilder {
988
1010
  this.trackSchemaUsage(schema, { serializationFormats: [KnownMediaType.Multipart] });
989
1011
  }
990
1012
  if (op.convenienceApi) {
991
- // Explicit body parameter @body or @bodyRoot would result to the existance of rawHttpOperation.parameters.body.property
1013
+ // Explicit body parameter @body or @bodyRoot would result to the existence of rawHttpOperation.parameters.body.property
992
1014
  // Implicit body parameter would result to rawHttpOperation.parameters.body.property be undefined
993
1015
  // see https://typespec.io/docs/libraries/http/cheat-sheet#data-types
994
1016
  const bodyParameterFlatten = schema instanceof ObjectSchema &&
@@ -1091,7 +1113,11 @@ export class CodeModelBuilder {
1091
1113
  if (opParameter.kind !== "property") {
1092
1114
  // not body property
1093
1115
  // header/query/path, same location and same serializedName
1094
- existParameter = (_a = op.parameters) === null || _a === void 0 ? void 0 : _a.find((it) => { var _a; return ((_a = it.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === opParameter.kind && it.language.default.serializedName === serializedName; });
1116
+ existParameter = (_a = op.parameters) === null || _a === void 0 ? void 0 : _a.find((it) => {
1117
+ var _a;
1118
+ return ((_a = it.protocol.http) === null || _a === void 0 ? void 0 : _a.in) === opParameter.kind &&
1119
+ it.language.default.serializedName === serializedName;
1120
+ });
1095
1121
  }
1096
1122
  request.parameters = (_b = request.parameters) !== null && _b !== void 0 ? _b : [];
1097
1123
  if (existParameter) {
@@ -1105,7 +1131,9 @@ export class CodeModelBuilder {
1105
1131
  else {
1106
1132
  // property from anonymous model
1107
1133
  const existBodyProperty = (_e = schema.properties) === null || _e === void 0 ? void 0 : _e.find((it) => it.serializedName === serializedName);
1108
- if (existBodyProperty && !existBodyProperty.readOnly && !(existBodyProperty.schema instanceof ConstantSchema)) {
1134
+ if (existBodyProperty &&
1135
+ !existBodyProperty.readOnly &&
1136
+ !(existBodyProperty.schema instanceof ConstantSchema)) {
1109
1137
  request.parameters.push(new VirtualParameter(existBodyProperty.language.default.name, existBodyProperty.language.default.description, existBodyProperty.schema, {
1110
1138
  originalParameter: originalParameter,
1111
1139
  targetProperty: existBodyProperty,
@@ -1149,7 +1177,9 @@ export class CodeModelBuilder {
1149
1177
  }
1150
1178
  const bodyType = sdkResponse.type;
1151
1179
  let trackConvenienceApi = Boolean(op.convenienceApi);
1152
- const unknownResponseBody = sdkResponse.contentTypes && sdkResponse.contentTypes.length > 0 && !isKnownContentType(sdkResponse.contentTypes);
1180
+ const unknownResponseBody = sdkResponse.contentTypes &&
1181
+ sdkResponse.contentTypes.length > 0 &&
1182
+ !isKnownContentType(sdkResponse.contentTypes);
1153
1183
  let response;
1154
1184
  if (unknownResponseBody && bodyType && bodyType.kind === "bytes") {
1155
1185
  // binary
@@ -1491,7 +1521,8 @@ export class CodeModelBuilder {
1491
1521
  },
1492
1522
  },
1493
1523
  });
1494
- objectSchema.crossLanguageDefinitionId = type.crossLanguageDefinitionId;
1524
+ objectSchema.crossLanguageDefinitionId =
1525
+ type.crossLanguageDefinitionId;
1495
1526
  this.codeModel.schemas.add(objectSchema);
1496
1527
  // cache this now before we accidentally recurse on this type.
1497
1528
  if (!this.schemaCache.has(type)) {
@@ -1603,6 +1634,11 @@ export class CodeModelBuilder {
1603
1634
  if (prop.multipartOptions.isFilePart) {
1604
1635
  schema = this.processMultipartFormDataFilePropertySchemaFromSdkType(prop);
1605
1636
  }
1637
+ else if (prop.type.kind === "model" &&
1638
+ prop.type.properties.some((it) => it.kind === "body")) {
1639
+ // TODO: this is HttpPart of non-File. TCGC should help handle this.
1640
+ schema = this.processSchemaFromSdkType(prop.type.properties.find((it) => it.kind === "body").type, "");
1641
+ }
1606
1642
  else {
1607
1643
  schema = this.processSchemaFromSdkType(nonNullType, "");
1608
1644
  }
@@ -1674,7 +1710,9 @@ export class CodeModelBuilder {
1674
1710
  case "Scalar": {
1675
1711
  const scalarName = type.name;
1676
1712
  let name = type.name;
1677
- if (scalarName.startsWith("int") || scalarName.startsWith("uint") || scalarName === "safeint") {
1713
+ if (scalarName.startsWith("int") ||
1714
+ scalarName.startsWith("uint") ||
1715
+ scalarName === "safeint") {
1678
1716
  name = scalarName === "safeint" || scalarName.includes("int64") ? "Long" : "Integer";
1679
1717
  }
1680
1718
  else if (scalarName.startsWith("float")) {
@@ -1693,7 +1731,7 @@ export class CodeModelBuilder {
1693
1731
  case "Model":
1694
1732
  if (isArrayModelType(this.program, type)) {
1695
1733
  ++option.depth;
1696
- if (option.depth == 1) {
1734
+ if (option.depth === 1) {
1697
1735
  return this.getUnionVariantName(type.indexer.value, option) + "List";
1698
1736
  }
1699
1737
  else {
@@ -1702,7 +1740,7 @@ export class CodeModelBuilder {
1702
1740
  }
1703
1741
  else if (isRecordModelType(this.program, type)) {
1704
1742
  ++option.depth;
1705
- if (option.depth == 1) {
1743
+ if (option.depth === 1) {
1706
1744
  return this.getUnionVariantName(type.indexer.value, option) + "Map";
1707
1745
  }
1708
1746
  else {
@@ -1728,7 +1766,9 @@ export class CodeModelBuilder {
1728
1766
  var _a, _b, _c, _d;
1729
1767
  const processSchemaFunc = (type) => this.processSchemaFromSdkType(type, "");
1730
1768
  if (property.type.kind === "bytes" || property.type.kind === "model") {
1731
- const namespace = property.type.kind === "model" ? ((_a = getNamespace(property.type.__raw)) !== null && _a !== void 0 ? _a : this.namespace) : this.namespace;
1769
+ const namespace = property.type.kind === "model"
1770
+ ? ((_a = getNamespace(property.type.__raw)) !== null && _a !== void 0 ? _a : this.namespace)
1771
+ : this.namespace;
1732
1772
  return getFileDetailsSchema(property, (_b = getNamespace(property.type.__raw)) !== null && _b !== void 0 ? _b : this.namespace, namespace, this.codeModel.schemas, this.binarySchema, this.stringSchema, processSchemaFunc);
1733
1773
  }
1734
1774
  else if (property.type.kind === "array" &&
@@ -1831,7 +1871,8 @@ export class CodeModelBuilder {
1831
1871
  if (!namespace) {
1832
1872
  return undefined;
1833
1873
  }
1834
- else if (baseJavaNamespace && (namespace === tspNamespace || namespace.startsWith(tspNamespace + "."))) {
1874
+ else if (baseJavaNamespace &&
1875
+ (namespace === tspNamespace || namespace.startsWith(tspNamespace + "."))) {
1835
1876
  return baseJavaNamespace + namespace.slice(tspNamespace.length).toLowerCase();
1836
1877
  }
1837
1878
  else {
@@ -1864,10 +1905,11 @@ export class CodeModelBuilder {
1864
1905
  }
1865
1906
  get anySchema() {
1866
1907
  var _a;
1867
- return (_a = this._anySchema) !== null && _a !== void 0 ? _a : (this._anySchema = this.codeModel.schemas.add(new AnySchema("Anything")));
1908
+ return ((_a = this._anySchema) !== null && _a !== void 0 ? _a : (this._anySchema = this.codeModel.schemas.add(new AnySchema("Anything"))));
1868
1909
  }
1869
1910
  get binarySchema() {
1870
- return this._binarySchema || (this._binarySchema = this.codeModel.schemas.add(new BinarySchema("simple binary")));
1911
+ return (this._binarySchema ||
1912
+ (this._binarySchema = this.codeModel.schemas.add(new BinarySchema("simple binary"))));
1871
1913
  }
1872
1914
  get pollResultSchema() {
1873
1915
  var _a;
@@ -1940,7 +1982,7 @@ export class CodeModelBuilder {
1940
1982
  var _a;
1941
1983
  if (p.readOnly && ((_a = schemaUsage.usage) === null || _a === void 0 ? void 0 : _a.includes(SchemaContext.Input))) {
1942
1984
  const schemaUsageWithoutInput = {
1943
- usage: schemaUsage.usage.filter((it) => it != SchemaContext.Input),
1985
+ usage: schemaUsage.usage.filter((it) => it !== SchemaContext.Input),
1944
1986
  serializationFormats: schemaUsage.serializationFormats,
1945
1987
  };
1946
1988
  innerApplySchemaUsage(p.schema, schemaUsageWithoutInput);