@azure-tools/typespec-java 0.27.5 → 0.27.7

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.
@@ -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;AAczB,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,iBAAiB,CAAU;IACnC,OAAO,CAAC,mBAAmB,CAAW;IACtC,OAAO,CAAC,UAAU,CAAc;IAChC,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,gBAAgB,CAAY;IAEpC,QAAQ,CAAC,WAAW,mCAElB;IACF,QAAQ,CAAC,iBAAiB,sCAA6C;IAGvE,OAAO,CAAC,UAAU,CAAqB;gBAEpB,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,CAAC,cAAc,CAAC;IAmD7D,KAAK,IAAI,OAAO,CAAC,SAAS,CAAC;IAoDxC,OAAO,CAAC,qBAAqB;IAoC7B,OAAO,CAAC,WAAW;IAs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C,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"}
@@ -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, PageableContinuationToken, } 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";
@@ -20,9 +20,10 @@ import { createPollOperationDetailsSchema, getFileDetailsSchema } from "./extern
20
20
  import { LIB_NAME, createDiagnostic, reportDiagnostic } from "./lib.js";
21
21
  import { ClientContext } from "./models.js";
22
22
  import { CONTENT_TYPE_KEY, ORIGIN_API_VERSION, SPECIAL_HEADER_NAMES, cloneOperationParameter, getServiceVersion, isKnownContentType, isLroNewPollingStrategy, operationIsJsonMergePatch, operationIsMultipart, operationIsMultipleContentTypes, } from "./operation-utils.js";
23
- import { ProcessingCache, getAccess, getDurationFormat, getNonNullSdkType, getPropertySerializedName, getUnionDescription, getUsage, modelIs, pushDistinct, } from "./type-utils.js";
23
+ import { BYTES_KNOWN_ENCODING, DATETIME_KNOWN_ENCODING, DURATION_KNOWN_ENCODING, 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;
@@ -707,50 +708,132 @@ export class CodeModelBuilder {
707
708
  this.processResponse(codeModelOperation, response.statusCodes, response, lroMetadata.longRunning, true);
708
709
  }
709
710
  // check for paged
710
- this.processRouteForPaged(codeModelOperation, sdkMethod.operation.responses, sdkMethod);
711
+ this.processRouteForPaged(codeModelOperation, sdkMethod);
711
712
  // check for long-running operation
712
713
  this.processRouteForLongRunning(codeModelOperation, lroMetadata);
713
714
  operationGroup.addOperation(codeModelOperation);
714
715
  return codeModelOperation;
715
716
  }
716
- processRouteForPaged(op, responses, sdkMethod) {
717
- var _a, _b;
718
- if (sdkMethod.kind === "paging" || sdkMethod.kind === "lropaging") {
719
- for (const response of responses) {
720
- const bodyType = response.type;
721
- if (bodyType && bodyType.kind === "model") {
722
- let itemSerializedName = undefined;
723
- let nextLinkSerializedName = undefined;
724
- const itemSegments = sdkMethod.response.resultSegments;
725
- const nextLinkSegments = sdkMethod.pagingMetadata.nextLinkSegments;
726
- // TODO: in future the property could be nested, so that the "itemSegments" or "nextLinkSegments" would contain more than 1 element
727
- if (itemSegments) {
728
- // "itemsSegments" should exist for "paging"/"lropaging"
729
- const lastSegment = itemSegments[itemSegments.length - 1];
730
- if (lastSegment.kind === "property") {
731
- itemSerializedName = getPropertySerializedName(lastSegment);
717
+ processRouteForPaged(op, sdkMethod) {
718
+ var _a, _b, _c;
719
+ if (sdkMethod.kind !== "paging" && sdkMethod.kind !== "lropaging") {
720
+ return;
721
+ }
722
+ // TCGC should already verified that there is 1 response, and response body is a model
723
+ const responses = sdkMethod.operation.responses;
724
+ if (responses.length === 0) {
725
+ return;
726
+ }
727
+ const response = responses[0];
728
+ const bodyType = response.type;
729
+ if (!bodyType || bodyType.kind !== "model") {
730
+ return;
731
+ }
732
+ (_a = op.responses) === null || _a === void 0 ? void 0 : _a.forEach((r) => {
733
+ if (r instanceof SchemaResponse) {
734
+ this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] });
735
+ }
736
+ });
737
+ function getLastPropertySegment(segments) {
738
+ if (segments) {
739
+ const lastSegment = segments[segments.length - 1];
740
+ if (lastSegment.kind === "property") {
741
+ return lastSegment;
742
+ }
743
+ }
744
+ return undefined;
745
+ }
746
+ function getLastSegment(segments) {
747
+ if (segments) {
748
+ return segments[segments.length - 1];
749
+ }
750
+ return undefined;
751
+ }
752
+ function getLastSegmentSerializedName(segments) {
753
+ const lastSegment = getLastPropertySegment(segments);
754
+ return lastSegment ? getPropertySerializedName(lastSegment) : undefined;
755
+ }
756
+ // TODO: in future the property could be nested, so that the "itemSegments" or "nextLinkSegments" would contain more than 1 element
757
+ // item/result
758
+ // "itemsSegments" should exist for "paging"/"lropaging"
759
+ const itemSerializedName = getLastSegmentSerializedName(sdkMethod.response.resultSegments);
760
+ // nextLink
761
+ const nextLinkSerializedName = getLastSegmentSerializedName(sdkMethod.pagingMetadata.nextLinkSegments);
762
+ // continuationToken
763
+ let continuationTokenParameter;
764
+ let continuationTokenResponseProperty;
765
+ let continuationTokenResponseHeader;
766
+ if (!this.isBranded()) {
767
+ const continuationTokenParameterSegment = getLastSegment(sdkMethod.pagingMetadata.continuationTokenParameterSegments);
768
+ const continuationTokenResponseSegment = getLastSegment(sdkMethod.pagingMetadata.continuationTokenResponseSegments);
769
+ if (continuationTokenParameterSegment && op.parameters) {
770
+ // for now, continuationToken is either request query or header parameter
771
+ const parameter = getHttpOperationParameter(sdkMethod, continuationTokenParameterSegment);
772
+ if (parameter) {
773
+ for (const param of op.parameters) {
774
+ if (((_b = param.protocol.http) === null || _b === void 0 ? void 0 : _b.in) === parameter.kind) {
775
+ if (parameter.kind === "header" &&
776
+ param.language.default.serializedName.toLowerCase() ===
777
+ parameter.serializedName.toLowerCase()) {
778
+ continuationTokenParameter = param;
779
+ break;
780
+ }
781
+ else if (param.language.default.serializedName === parameter.serializedName) {
782
+ continuationTokenParameter = param;
783
+ break;
784
+ }
732
785
  }
733
786
  }
734
- if (nextLinkSegments) {
735
- const lastSegment = nextLinkSegments[nextLinkSegments.length - 1];
736
- if (lastSegment.kind === "property") {
737
- nextLinkSerializedName = getPropertySerializedName(lastSegment);
787
+ }
788
+ }
789
+ if (continuationTokenResponseSegment && op.responses) {
790
+ if ((continuationTokenResponseSegment === null || continuationTokenResponseSegment === void 0 ? void 0 : continuationTokenResponseSegment.kind) === "responseheader") {
791
+ // continuationToken is response header
792
+ for (const response of op.responses) {
793
+ if (response instanceof SchemaResponse && response.protocol.http) {
794
+ for (const header of response.protocol.http.headers) {
795
+ if (header.header.toLowerCase() ===
796
+ continuationTokenResponseSegment.serializedName.toLowerCase()) {
797
+ continuationTokenResponseHeader = header;
798
+ break;
799
+ }
800
+ }
801
+ }
802
+ if (continuationTokenResponseHeader) {
803
+ break;
738
804
  }
739
805
  }
740
- (_a = op.responses) === null || _a === void 0 ? void 0 : _a.forEach((r) => {
741
- if (r instanceof SchemaResponse) {
742
- this.trackSchemaUsage(r.schema, { usage: [SchemaContext.Paged] });
806
+ }
807
+ else if ((continuationTokenResponseSegment === null || continuationTokenResponseSegment === void 0 ? void 0 : continuationTokenResponseSegment.kind) === "property") {
808
+ // continuationToken is response body property
809
+ // TODO: the property could be nested
810
+ for (const response of op.responses) {
811
+ if (response instanceof SchemaResponse &&
812
+ response.schema instanceof ObjectSchema &&
813
+ response.schema.properties) {
814
+ for (const property of response.schema.properties) {
815
+ if (property.serializedName ===
816
+ getPropertySerializedName(continuationTokenResponseSegment)) {
817
+ continuationTokenResponseProperty = [property];
818
+ break;
819
+ }
820
+ }
743
821
  }
744
- });
745
- op.extensions = (_b = op.extensions) !== null && _b !== void 0 ? _b : {};
746
- op.extensions["x-ms-pageable"] = {
747
- itemName: itemSerializedName,
748
- nextLinkName: nextLinkSerializedName,
749
- };
750
- break;
822
+ if (continuationTokenResponseProperty) {
823
+ break;
824
+ }
825
+ }
751
826
  }
752
827
  }
753
828
  }
829
+ op.extensions = (_c = op.extensions) !== null && _c !== void 0 ? _c : {};
830
+ op.extensions["x-ms-pageable"] = {
831
+ itemName: itemSerializedName,
832
+ nextLinkName: nextLinkSerializedName,
833
+ continuationToken: continuationTokenParameter
834
+ ? new PageableContinuationToken(continuationTokenParameter, continuationTokenResponseProperty, continuationTokenResponseHeader)
835
+ : undefined,
836
+ };
754
837
  }
755
838
  processLroMetadata(op, sdkMethod) {
756
839
  const trackConvenienceApi = Boolean(op.convenienceApi);
@@ -1539,7 +1622,7 @@ export class CodeModelBuilder {
1539
1622
  return this.schemaCache.process(type, nameHint) || fail("Unable to process schema.");
1540
1623
  }
1541
1624
  processSchemaImpl(type, nameHint) {
1542
- var _a;
1625
+ var _a, _b, _c;
1543
1626
  if (isSdkBuiltInKind(type.kind)) {
1544
1627
  return this.processBuiltInType(type, nameHint);
1545
1628
  }
@@ -1558,27 +1641,48 @@ export class CodeModelBuilder {
1558
1641
  case "array":
1559
1642
  return this.processArraySchema(type, nameHint);
1560
1643
  case "duration":
1561
- return this.processDurationSchema(type, nameHint, getDurationFormat(type));
1644
+ if (DURATION_KNOWN_ENCODING.includes(type.encode)) {
1645
+ return this.processDurationSchema(type, nameHint, getDurationFormat(type));
1646
+ }
1647
+ else {
1648
+ reportDiagnostic(this.program, {
1649
+ code: "unknown-encode",
1650
+ format: { encode: type.encode },
1651
+ target: (_a = type.__raw) !== null && _a !== void 0 ? _a : NoTarget,
1652
+ });
1653
+ return this.processBuiltInType(type.wireType, nameHint);
1654
+ }
1562
1655
  case "constant":
1563
1656
  return this.processConstantSchema(type, nameHint);
1564
1657
  case "utcDateTime":
1565
1658
  case "offsetDateTime":
1566
- if (type.encode === "unixTimestamp") {
1567
- return this.processUnixTimeSchema(type, nameHint);
1659
+ if (DATETIME_KNOWN_ENCODING.includes(type.encode)) {
1660
+ if (type.encode === "unixTimestamp") {
1661
+ return this.processUnixTimeSchema(type, nameHint);
1662
+ }
1663
+ else {
1664
+ return this.processDateTimeSchema(type, nameHint, type.encode === "rfc7231");
1665
+ }
1568
1666
  }
1569
1667
  else {
1570
- return this.processDateTimeSchema(type, nameHint, type.encode === "rfc7231");
1668
+ reportDiagnostic(this.program, {
1669
+ code: "unknown-encode",
1670
+ format: { encode: type.encode },
1671
+ target: (_b = type.__raw) !== null && _b !== void 0 ? _b : NoTarget,
1672
+ });
1673
+ return this.processBuiltInType(type.wireType, nameHint);
1571
1674
  }
1572
1675
  }
1573
1676
  }
1574
1677
  const diagnostic = createDiagnostic({
1575
1678
  code: "unrecognized-type",
1576
1679
  format: { typeKind: type.kind },
1577
- target: (_a = type.__raw) !== null && _a !== void 0 ? _a : NoTarget,
1680
+ target: (_c = type.__raw) !== null && _c !== void 0 ? _c : NoTarget,
1578
1681
  });
1579
1682
  throw new DiagnosticError(diagnostic);
1580
1683
  }
1581
1684
  processBuiltInType(type, nameHint) {
1685
+ var _a;
1582
1686
  nameHint = nameHint || type.kind;
1583
1687
  if (isSdkIntKind(type.kind)) {
1584
1688
  const integerSize = type.kind === "safeint" || type.kind.includes("int64") ? 64 : 32;
@@ -1598,7 +1702,17 @@ export class CodeModelBuilder {
1598
1702
  case "decimal128":
1599
1703
  return this.processDecimalSchema(type, nameHint);
1600
1704
  case "bytes":
1601
- return this.processByteArraySchema(type, nameHint);
1705
+ if (!type.encode || BYTES_KNOWN_ENCODING.includes(type.encode)) {
1706
+ return this.processByteArraySchema(type, nameHint);
1707
+ }
1708
+ else {
1709
+ reportDiagnostic(this.program, {
1710
+ code: "unknown-encode",
1711
+ format: { encode: type.encode },
1712
+ target: (_a = type.__raw) !== null && _a !== void 0 ? _a : NoTarget,
1713
+ });
1714
+ return this.processStringSchema(type, nameHint);
1715
+ }
1602
1716
  case "boolean":
1603
1717
  return this.processBooleanSchema(type, nameHint);
1604
1718
  case "plainTime":
@@ -1771,7 +1885,7 @@ export class CodeModelBuilder {
1771
1885
  }));
1772
1886
  }
1773
1887
  processObjectSchema(type, name) {
1774
- var _a, _b;
1888
+ var _a, _b, _c;
1775
1889
  const rawModelType = type.__raw;
1776
1890
  const namespace = getNamespace(rawModelType);
1777
1891
  const objectSchema = new ObjectSchema(name, (_a = type.doc) !== null && _a !== void 0 ? _a : "", {
@@ -1801,24 +1915,49 @@ export class CodeModelBuilder {
1801
1915
  }
1802
1916
  // type is a subtype
1803
1917
  if (type.baseModel) {
1804
- const parentSchema = this.processSchema(type.baseModel, type.baseModel.name);
1805
- objectSchema.parents = new Relations();
1806
- objectSchema.parents.immediate.push(parentSchema);
1807
- if (parentSchema instanceof ObjectSchema) {
1808
- pushDistinct(objectSchema.parents.all, parentSchema);
1809
- parentSchema.children = parentSchema.children || new Relations();
1810
- pushDistinct(parentSchema.children.immediate, objectSchema);
1811
- pushDistinct(parentSchema.children.all, objectSchema);
1812
- if (parentSchema.parents) {
1813
- pushDistinct(objectSchema.parents.all, ...parentSchema.parents.all);
1814
- parentSchema.parents.all.forEach((it) => {
1815
- if (it instanceof ObjectSchema && it.children) {
1816
- pushDistinct(it.children.all, objectSchema);
1918
+ if (this.isBranded() &&
1919
+ type.baseModel.crossLanguageDefinitionId === AZURE_CORE_FOUNDATIONS_ERROR_ID) {
1920
+ // com.azure.core.models.ResponseError class is final, we cannot extend it
1921
+ // therefore, copy all properties from "Error" to this class
1922
+ const parentSchema = this.processSchema(type.baseModel, type.baseModel.name);
1923
+ if (parentSchema instanceof ObjectSchema) {
1924
+ (_b = parentSchema.properties) === null || _b === void 0 ? void 0 : _b.forEach((p) => {
1925
+ var _a;
1926
+ objectSchema.addProperty(p);
1927
+ // improve the casing for Java
1928
+ if (p.serializedName === "innererror") {
1929
+ p.language.default.name = "innerError";
1930
+ if (p.schema instanceof ObjectSchema) {
1931
+ (_a = p.schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((innerErrorProperty) => {
1932
+ if (innerErrorProperty.serializedName === "innererror") {
1933
+ innerErrorProperty.language.default.name = "innerError";
1934
+ }
1935
+ });
1936
+ }
1817
1937
  }
1818
1938
  });
1819
1939
  }
1820
1940
  }
1821
- objectSchema.discriminatorValue = type.discriminatorValue;
1941
+ else {
1942
+ const parentSchema = this.processSchema(type.baseModel, type.baseModel.name);
1943
+ objectSchema.parents = new Relations();
1944
+ objectSchema.parents.immediate.push(parentSchema);
1945
+ if (parentSchema instanceof ObjectSchema) {
1946
+ pushDistinct(objectSchema.parents.all, parentSchema);
1947
+ parentSchema.children = parentSchema.children || new Relations();
1948
+ pushDistinct(parentSchema.children.immediate, objectSchema);
1949
+ pushDistinct(parentSchema.children.all, objectSchema);
1950
+ if (parentSchema.parents) {
1951
+ pushDistinct(objectSchema.parents.all, ...parentSchema.parents.all);
1952
+ parentSchema.parents.all.forEach((it) => {
1953
+ if (it instanceof ObjectSchema && it.children) {
1954
+ pushDistinct(it.children.all, objectSchema);
1955
+ }
1956
+ });
1957
+ }
1958
+ }
1959
+ objectSchema.discriminatorValue = type.discriminatorValue;
1960
+ }
1822
1961
  }
1823
1962
  if (type.additionalProperties) {
1824
1963
  // model has additional property
@@ -1836,7 +1975,7 @@ export class CodeModelBuilder {
1836
1975
  decorators: [],
1837
1976
  };
1838
1977
  const parentSchema = this.processSchema(sdkDictType, "Record");
1839
- objectSchema.parents = (_b = objectSchema.parents) !== null && _b !== void 0 ? _b : new Relations();
1978
+ objectSchema.parents = (_c = objectSchema.parents) !== null && _c !== void 0 ? _c : new Relations();
1840
1979
  objectSchema.parents.immediate.push(parentSchema);
1841
1980
  pushDistinct(objectSchema.parents.all, parentSchema);
1842
1981
  objectSchema.discriminatorValue = type.discriminatorValue;
@@ -2117,7 +2256,7 @@ export class CodeModelBuilder {
2117
2256
  // hopefully it is the root namespace of the SDK
2118
2257
  let baseJavaNamespace = undefined;
2119
2258
  this.sdkContext.sdkPackage.clients
2120
- .map((it) => it.clientNamespace)
2259
+ .map((it) => it.namespace)
2121
2260
  .forEach((it) => {
2122
2261
  if (baseJavaNamespace === undefined || baseJavaNamespace.length > it.length) {
2123
2262
  baseJavaNamespace = it;
@@ -2131,7 +2270,7 @@ export class CodeModelBuilder {
2131
2270
  }
2132
2271
  getJavaNamespace(type = undefined) {
2133
2272
  // clientNamespace from TCGC
2134
- const clientNamespace = type === null || type === void 0 ? void 0 : type.clientNamespace;
2273
+ const clientNamespace = type === null || type === void 0 ? void 0 : type.namespace;
2135
2274
  if (type) {
2136
2275
  const crossLanguageDefinitionId = type.crossLanguageDefinitionId;
2137
2276
  if (this.isBranded()) {
@@ -2151,6 +2290,11 @@ export class CodeModelBuilder {
2151
2290
  // usually this model will not be generated, but javadoc of protocol method requires it be in SDK namespace
2152
2291
  return this.baseJavaNamespace;
2153
2292
  }
2293
+ else if (crossLanguageDefinitionId === "Azure.Core.Foundations.InnerError") {
2294
+ // Azure.Core.Foundations.InnerError
2295
+ // this model could be generated, if a model extends Error
2296
+ return this.baseJavaNamespace;
2297
+ }
2154
2298
  else if (type.crossLanguageDefinitionId.startsWith("Azure.ResourceManager.")) {
2155
2299
  // models in Azure.ResourceManager
2156
2300
  return this.baseJavaNamespace;
@@ -2276,20 +2420,30 @@ export class CodeModelBuilder {
2276
2420
  }
2277
2421
  processedSchemas.add(schema);
2278
2422
  if (schema instanceof ObjectSchema || schema instanceof GroupSchema) {
2423
+ let skipPropergateProperties = false;
2424
+ if (this.isBranded() &&
2425
+ schema.language.default.crossLanguageDefinitionId === AZURE_CORE_FOUNDATIONS_ERROR_ID) {
2426
+ // a temporary hack to avoid propergate usage for Azure.Core.Foundations.Error
2427
+ // the reason is that the InnerError within cannot be mapped to azure-core ResponseInnerError, as that class is not public
2428
+ // so generator had to generate the class, if used outside of Azure.Core.Foundations.Error (e.g., when a model extends Error)
2429
+ skipPropergateProperties = true;
2430
+ }
2279
2431
  if (schemaUsage.usage || schemaUsage.serializationFormats) {
2280
- (_a = schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
2281
- var _a;
2282
- if (p.readOnly && ((_a = schemaUsage.usage) === null || _a === void 0 ? void 0 : _a.includes(SchemaContext.Input))) {
2283
- const schemaUsageWithoutInput = {
2284
- usage: schemaUsage.usage.filter((it) => it !== SchemaContext.Input),
2285
- serializationFormats: schemaUsage.serializationFormats,
2286
- };
2287
- innerApplySchemaUsage(p.schema, schemaUsageWithoutInput);
2288
- }
2289
- else {
2290
- innerApplySchemaUsage(p.schema, schemaUsage);
2291
- }
2292
- });
2432
+ if (!skipPropergateProperties) {
2433
+ (_a = schema.properties) === null || _a === void 0 ? void 0 : _a.forEach((p) => {
2434
+ var _a;
2435
+ if (p.readOnly && ((_a = schemaUsage.usage) === null || _a === void 0 ? void 0 : _a.includes(SchemaContext.Input))) {
2436
+ const schemaUsageWithoutInput = {
2437
+ usage: schemaUsage.usage.filter((it) => it !== SchemaContext.Input),
2438
+ serializationFormats: schemaUsage.serializationFormats,
2439
+ };
2440
+ innerApplySchemaUsage(p.schema, schemaUsageWithoutInput);
2441
+ }
2442
+ else {
2443
+ innerApplySchemaUsage(p.schema, schemaUsage);
2444
+ }
2445
+ });
2446
+ }
2293
2447
  if (schema instanceof ObjectSchema) {
2294
2448
  (_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
2449
  (_e = (_d = schema.parents) === null || _d === void 0 ? void 0 : _d.immediate) === null || _e === void 0 ? void 0 : _e.forEach((p) => innerApplySchemaUsage(p, schemaUsage));