@redocly/cli 2.59.0 → 2.61.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 (141) hide show
  1. package/THIRD_PARTY_NOTICES +2 -2
  2. package/lib/chunks/{PHV3T4WH.js → 22EANOP2.js} +87 -87
  3. package/lib/chunks/{AF5IHTRV.js → 2KG4GEMM.js} +1 -1
  4. package/lib/chunks/2OVI7BIW.js +105 -0
  5. package/lib/chunks/{NFJLKOC3.js → 2WJSVZYJ.js} +1 -1
  6. package/lib/chunks/{J3SQBSQT.js → 3QZ3M2JX.js} +1 -1
  7. package/lib/chunks/{NC5GB4G5.js → 3TBVUHVH.js} +1 -1
  8. package/lib/chunks/{OFVQSSQQ.js → 3VI3PRNZ.js} +1 -1
  9. package/lib/chunks/45DZYRBQ.js +7 -0
  10. package/lib/chunks/{QB6J3FNI.js → 47H7SS4U.js} +1 -1
  11. package/lib/chunks/{OIISHIPF.js → 5PG3ST2N.js} +2 -2
  12. package/lib/chunks/{PCJ3RO4V.js → 6DO6IN4A.js} +1 -1
  13. package/lib/chunks/6ETCN64B.js +20 -0
  14. package/lib/chunks/{TJGR5OHF.js → 6GH5BRNP.js} +1 -1
  15. package/lib/chunks/{UESEVDDS.js → 6L6AYZQS.js} +10 -10
  16. package/lib/chunks/{F2MGZZWG.js → 6NGWHZCB.js} +1 -1
  17. package/lib/chunks/{WK3QKCKY.js → 6ZVVKLZR.js} +1 -1
  18. package/lib/chunks/7FLYZDPU.js +11 -0
  19. package/lib/chunks/{FG62OWSV.js → 7RZON3J3.js} +1 -1
  20. package/lib/chunks/{42YAZTOS.js → B6HOY6AV.js} +1 -1
  21. package/lib/chunks/DDAZZC3I.js +20 -0
  22. package/lib/chunks/{KSTWCX27.js → DNQSGL2N.js} +1 -1
  23. package/lib/chunks/{NSK5BX5M.js → E5BMYA7V.js} +1 -1
  24. package/lib/chunks/ERFYZ47T.js +11 -0
  25. package/lib/chunks/{NSLUCFIM.js → F6IXS3RL.js} +1 -1
  26. package/lib/chunks/{B7HK2FMY.js → FAIK7Y6U.js} +1 -1
  27. package/lib/chunks/{PRAHH3RT.js → FAZWASU6.js} +1 -1
  28. package/lib/chunks/{DAQRGYND.js → FDMXHRDK.js} +1 -1
  29. package/lib/chunks/{RS64EP6M.js → FUH5ZFZ2.js} +1 -1
  30. package/lib/chunks/{G5TC4ZEC.js → GGRILIN6.js} +1 -1
  31. package/lib/chunks/{BYWCQTSQ.js → GJDVFWVH.js} +1 -1
  32. package/lib/chunks/{BEYYSLHN.js → GLOLLUKD.js} +1 -1
  33. package/lib/chunks/{7QMY27YR.js → GZ7EDJXV.js} +1 -1
  34. package/lib/chunks/HBPMIV7U.js +9 -0
  35. package/lib/chunks/{CUJVZNF3.js → HHJX3B7U.js} +1 -1
  36. package/lib/chunks/{P6JG7GU7.js → IKDYY4XW.js} +2 -2
  37. package/lib/chunks/{NBRDOUIR.js → IMYWYFYT.js} +1 -1
  38. package/lib/chunks/{AVEIZUZG.js → IRHTRVFK.js} +1 -1
  39. package/lib/chunks/{E2UY7KGT.js → JP2RKFML.js} +1 -1
  40. package/lib/chunks/{IOYEFQOG.js → KRCCY64H.js} +1 -1
  41. package/lib/chunks/{OIPFI3RD.js → KVXNE2UB.js} +1 -1
  42. package/lib/chunks/{UQSXY6X3.js → LR2FZ43E.js} +1 -1
  43. package/lib/chunks/{YYL4GJWR.js → LRLGVYCG.js} +1 -1
  44. package/lib/chunks/{MBJ2NZOC.js → LXU55G2P.js} +1 -1
  45. package/lib/chunks/{CSBPXWYJ.js → MAHMSXK6.js} +1 -1
  46. package/lib/chunks/{GYVNLXXF.js → MK6X55UC.js} +1 -1
  47. package/lib/chunks/{NEOAISVJ.js → MNH2K4WM.js} +1 -1
  48. package/lib/chunks/{TPR5SEOT.js → MUKYSFRK.js} +1 -1
  49. package/lib/chunks/MXOINKB2.js +7 -0
  50. package/lib/chunks/{AVVEOYYF.js → OP7NIAI7.js} +1 -1
  51. package/lib/chunks/{BRJNFWLD.js → OXA7GLZA.js} +1 -1
  52. package/lib/chunks/{QTOB5ERW.js → PSEWUH36.js} +1 -1
  53. package/lib/chunks/{IT53FBW3.js → PTNNX4IU.js} +1 -1
  54. package/lib/chunks/{6367YNHA.js → QFJ6QZPG.js} +1 -1
  55. package/lib/chunks/{GEYI6VH2.js → RPHIT72T.js} +1 -1
  56. package/lib/chunks/{RTZAVLXW.js → RPQMBRTA.js} +1 -1
  57. package/lib/chunks/{MO5BUSRI.js → SFNDGMJM.js} +1 -1
  58. package/lib/chunks/SLQPKXO2.js +7 -0
  59. package/lib/chunks/{7YRZIM5N.js → SYWAPWW7.js} +1 -1
  60. package/lib/chunks/{LHKSVCO3.js → SZVRKEMY.js} +5 -5
  61. package/lib/chunks/{J2APNZBG.js → TBZEEKTV.js} +1 -1
  62. package/lib/chunks/{AX7QT4NM.js → US7X4XPD.js} +1 -1
  63. package/lib/chunks/{J56XVM43.js → V5CIDI6D.js} +58 -12
  64. package/lib/chunks/WCWEP2X5.js +20 -0
  65. package/lib/chunks/{V2MDYOAB.js → WEOCCL26.js} +2 -2
  66. package/lib/chunks/{RSJYGTUN.js → WSOBFTCE.js} +1 -1
  67. package/lib/chunks/{2U6O26CV.js → XJE2OFDN.js} +116 -16
  68. package/lib/chunks/{6IOZ5LPA.js → YEOWW3LR.js} +1 -1
  69. package/lib/chunks/{7W4L5LRS.js → ZH5HJBCG.js} +1 -1
  70. package/lib/chunks/ZOE6CZ74.js +8 -0
  71. package/lib/eject-assets/AGENTS.md +24 -23
  72. package/lib/eject-assets/generators/cli/docs.ts +1 -1
  73. package/lib/eject-assets/generators/cli/engine-source.ts +1 -1
  74. package/lib/eject-assets/generators/cli/index.ts +2 -2
  75. package/lib/eject-assets/generators/cli/render.ts +1 -1
  76. package/lib/eject-assets/generators/go/client.ts +1 -1
  77. package/lib/eject-assets/generators/go/descriptor.ts +1 -1
  78. package/lib/eject-assets/generators/go/index.ts +2 -2
  79. package/lib/eject-assets/generators/go/models.ts +1 -1
  80. package/lib/eject-assets/generators/go/naming.ts +1 -1
  81. package/lib/eject-assets/generators/go/operations.ts +35 -3
  82. package/lib/eject-assets/generators/go/pagination.ts +1 -1
  83. package/lib/eject-assets/generators/go/types.ts +1 -1
  84. package/lib/eject-assets/generators/mock/faker.ts +1 -1
  85. package/lib/eject-assets/generators/mock/index.ts +2 -2
  86. package/lib/eject-assets/generators/mock/render.ts +1 -1
  87. package/lib/eject-assets/generators/mock/sample.ts +1 -1
  88. package/lib/eject-assets/generators/mock/values.ts +1 -1
  89. package/lib/eject-assets/generators/php/client.ts +1 -1
  90. package/lib/eject-assets/generators/php/descriptor.ts +1 -1
  91. package/lib/eject-assets/generators/php/index.ts +2 -2
  92. package/lib/eject-assets/generators/php/models.ts +1 -1
  93. package/lib/eject-assets/generators/php/naming.ts +1 -1
  94. package/lib/eject-assets/generators/php/operations.ts +21 -3
  95. package/lib/eject-assets/generators/php/pagination.ts +1 -1
  96. package/lib/eject-assets/generators/php/types.ts +1 -1
  97. package/lib/eject-assets/generators/python/client.ts +1 -1
  98. package/lib/eject-assets/generators/python/descriptor.ts +1 -1
  99. package/lib/eject-assets/generators/python/index.ts +2 -2
  100. package/lib/eject-assets/generators/python/models.ts +1 -1
  101. package/lib/eject-assets/generators/python/naming.ts +1 -1
  102. package/lib/eject-assets/generators/python/operations.ts +19 -6
  103. package/lib/eject-assets/generators/python/pagination.ts +1 -1
  104. package/lib/eject-assets/generators/python/types.ts +1 -1
  105. package/lib/eject-assets/generators/swr/index.ts +2 -2
  106. package/lib/eject-assets/generators/swr/render.ts +1 -1
  107. package/lib/eject-assets/generators/tanstack-query/index.ts +2 -2
  108. package/lib/eject-assets/generators/tanstack-query/render.ts +1 -1
  109. package/lib/eject-assets/generators/transformers/index.ts +2 -2
  110. package/lib/eject-assets/generators/transformers/render.ts +1 -1
  111. package/lib/eject-assets/generators/typescript/banner.ts +1 -1
  112. package/lib/eject-assets/generators/typescript/client.ts +1 -1
  113. package/lib/eject-assets/generators/typescript/descriptor.ts +1 -1
  114. package/lib/eject-assets/generators/typescript/index.ts +2 -2
  115. package/lib/eject-assets/generators/typescript/inline-runtime.ts +1 -1
  116. package/lib/eject-assets/generators/typescript/operation-signature.ts +1 -1
  117. package/lib/eject-assets/generators/typescript/operation-types.ts +1 -1
  118. package/lib/eject-assets/generators/typescript/operations.ts +3 -4
  119. package/lib/eject-assets/generators/typescript/response-headers.ts +1 -1
  120. package/lib/eject-assets/generators/typescript/type-guards.ts +1 -1
  121. package/lib/eject-assets/generators/typescript/types.ts +1 -1
  122. package/lib/eject-assets/generators/zod/index.ts +2 -2
  123. package/lib/eject-assets/generators/zod/schemas.ts +1 -1
  124. package/lib/eject-assets/skills/client-generators/SKILL.md +24 -23
  125. package/lib/eject-assets/skills/go-generator/SKILL.md +11 -0
  126. package/lib/eject-assets/skills/php-generator/SKILL.md +16 -0
  127. package/lib/eject-assets/skills/python-generator/SKILL.md +13 -0
  128. package/lib/eject-assets/skills/typescript-generator/SKILL.md +16 -0
  129. package/lib/index.js +54 -53
  130. package/package.json +1 -1
  131. package/lib/chunks/2ZE577MX.js +0 -11
  132. package/lib/chunks/6CJDOMNR.js +0 -8
  133. package/lib/chunks/7FNYMCIP.js +0 -105
  134. package/lib/chunks/DBWAOHZO.js +0 -11
  135. package/lib/chunks/ECKYES2X.js +0 -20
  136. package/lib/chunks/IDDPOAAO.js +0 -20
  137. package/lib/chunks/O553F5PN.js +0 -20
  138. package/lib/chunks/QEM3YVSB.js +0 -7
  139. package/lib/chunks/US7OHDWQ.js +0 -7
  140. package/lib/chunks/YSCPIS6C.js +0 -9
  141. package/lib/chunks/ZLNFQUIK.js +0 -7
@@ -259,12 +259,14 @@ func retryDelay(retry RetryConfig, attempt int, retryAfter string) time.Duration
259
259
  }
260
260
 
261
261
  type requestSpec struct {
262
- OperationID string
263
- Method string
264
- URL string
265
- Headers map[string]string
266
- Query url.Values
267
- Body io.Reader
262
+ OperationID string
263
+ Method string
264
+ URL string
265
+ Headers map[string]string
266
+ Query url.Values
267
+ Body io.Reader
268
+ // Stream sends Body as is: no buffering, one attempt, the caller's Content-Type.
269
+ Stream bool
268
270
  ContentType string
269
271
  Timeout time.Duration
270
272
  Retry *RetryConfig
@@ -303,7 +305,7 @@ func send(ctx context.Context, config *Config, spec requestSpec) (*http.Response
303
305
  if httpClient == nil {
304
306
  httpClient = http.DefaultClient
305
307
  }
306
- if spec.Body != nil {
308
+ if spec.Body != nil && !spec.Stream {
307
309
  payload, err := io.ReadAll(spec.Body)
308
310
  if err != nil {
309
311
  return nil, err
@@ -319,6 +321,10 @@ func send(ctx context.Context, config *Config, spec requestSpec) (*http.Response
319
321
  fullURL += separator + spec.Query.Encode()
320
322
  }
321
323
  maxAttempts := 1 + retry.Retries
324
+ if spec.Stream {
325
+ // The first attempt consumes the reader, so there is nothing to replay.
326
+ maxAttempts = 1
327
+ }
322
328
  for attempt := 1; ; attempt++ {
323
329
  attemptCtx := ctx
324
330
  var cancel context.CancelFunc
@@ -326,7 +332,10 @@ func send(ctx context.Context, config *Config, spec requestSpec) (*http.Response
326
332
  attemptCtx, cancel = context.WithTimeout(ctx, timeout)
327
333
  }
328
334
  var bodyReader io.Reader
329
- if spec.bodyBytes != nil {
335
+ switch {
336
+ case spec.Stream:
337
+ bodyReader = spec.Body
338
+ case spec.bodyBytes != nil:
330
339
  bodyReader = bytes.NewReader(spec.bodyBytes)
331
340
  }
332
341
  req, err := http.NewRequestWithContext(attemptCtx, method, fullURL, bodyReader)
@@ -339,7 +348,7 @@ func send(ctx context.Context, config *Config, spec requestSpec) (*http.Response
339
348
  for key, value := range headers {
340
349
  req.Header.Set(key, value)
341
350
  }
342
- if spec.ContentType != "" && spec.bodyBytes != nil {
351
+ if spec.ContentType != "" && bodyReader != nil && req.Header.Get("Content-Type") == "" {
343
352
  req.Header.Set("Content-Type", spec.ContentType)
344
353
  }
345
354
  for _, mw := range config.Middleware {
@@ -863,6 +872,41 @@ func toMultipart(body any) (string, io.Reader, error) {
863
872
  }
864
873
  return writer.FormDataContentType(), buffer, nil
865
874
  }
875
+
876
+ // multipartBody prepares the body of an untyped multipart operation: an io.Reader is
877
+ // streamed and a []byte or string sent as is, all under the caller's Content-Type (the
878
+ // boundary is theirs to set); any other value goes through toMultipart.
879
+ func multipartBody(body any) (string, io.Reader, bool, error) {
880
+ if reader, stream, raw := rawBody(body); raw {
881
+ return "", reader, stream, nil
882
+ }
883
+ contentType, reader, err := toMultipart(body)
884
+ return contentType, reader, false, err
885
+ }
886
+
887
+ // binaryBody prepares the body of a binary operation: an io.Reader is streamed, a
888
+ // []byte or string sent as is, and any other value JSON-marshalled.
889
+ func binaryBody(body any) (io.Reader, bool, error) {
890
+ if reader, stream, raw := rawBody(body); raw {
891
+ return reader, stream, nil
892
+ }
893
+ payload, err := json.Marshal(body)
894
+ return bytes.NewReader(payload), false, err
895
+ }
896
+
897
+ // rawBody recognizes a body that needs no encoding: an io.Reader streams through in one
898
+ // attempt, a []byte or a string is replayable bytes.
899
+ func rawBody(body any) (io.Reader, bool, bool) {
900
+ switch typed := body.(type) {
901
+ case io.Reader:
902
+ return typed, true, true
903
+ case []byte:
904
+ return bytes.NewReader(typed), false, true
905
+ case string:
906
+ return strings.NewReader(typed), false, true
907
+ }
908
+ return nil, false, false
909
+ }
866
910
  `;var t=`<?php
867
911
 
868
912
  // @redocly/client-generator PHP runtime \u2014 embedded into generated clients.
@@ -1080,8 +1124,17 @@ function rawSend(Config $config, array $request): array
1080
1124
  return strlen($line);
1081
1125
  },
1082
1126
  ]);
1083
- if (($request['body'] ?? null) !== null) {
1084
- curl_setopt($handle, CURLOPT_POSTFIELDS, $request['body']);
1127
+ $body = $request['body'] ?? null;
1128
+ if (is_resource($body)) {
1129
+ curl_setopt_array($handle, [CURLOPT_UPLOAD => true, CURLOPT_INFILE => $body]);
1130
+ // php://input and wrappers without stream_stat report seekable but fstat() fails (with a
1131
+ // warning for the wrappers): those go chunked.
1132
+ $stat = @fstat($body);
1133
+ if (stream_get_meta_data($body)['seekable'] && $stat !== false) {
1134
+ curl_setopt($handle, CURLOPT_INFILESIZE, $stat['size'] - ftell($body));
1135
+ }
1136
+ } elseif ($body !== null) {
1137
+ curl_setopt($handle, CURLOPT_POSTFIELDS, $body);
1085
1138
  }
1086
1139
  if ($config->timeout !== null) {
1087
1140
  curl_setopt($handle, CURLOPT_TIMEOUT_MS, (int) round($config->timeout * 1000));
@@ -1120,7 +1173,8 @@ function send(Config $config, array $request): array
1120
1173
  {
1121
1174
  $headers = $request['headers'] ?? [];
1122
1175
  $headers['X-Redocly-Client'] = $config->clientHeader;
1123
- if (($request['contentType'] ?? null) !== null) {
1176
+ $callerContentType = in_array('content-type', array_map('strtolower', array_keys($headers)), true);
1177
+ if (($request['contentType'] ?? null) !== null && !$callerContentType) {
1124
1178
  $headers['Content-Type'] = $request['contentType'];
1125
1179
  }
1126
1180
  if (($request['idempotencyKey'] ?? null) !== null) {
@@ -1134,7 +1188,8 @@ function send(Config $config, array $request): array
1134
1188
  $handler = fn (array $req): array => $middleware($req, $next);
1135
1189
  }
1136
1190
 
1137
- $attempts = max(1, (int) ($config->retry['attempts'] ?? 3));
1191
+ // The first attempt consumes a stream resource, so there is nothing to replay.
1192
+ $attempts = is_resource($request['body'] ?? null) ? 1 : max(1, (int) ($config->retry['attempts'] ?? 3));
1138
1193
  $retryOn = $config->retry['retryOn'] ?? __NAMESPACE__ . '\\\\defaultRetryOn';
1139
1194
  $response = null;
1140
1195
  for ($attempt = 1; $attempt <= $attempts; $attempt++) {
@@ -1367,6 +1422,22 @@ function toMultipart(array $body): array
1367
1422
  $parts .= "--{$boundary}--\\r\\n";
1368
1423
  return ['multipart/form-data; boundary=' . $boundary, $parts];
1369
1424
  }
1425
+
1426
+ /**
1427
+ * The body of an untyped multipart operation: a stream resource or a string passes through
1428
+ * under the caller's Content-Type (the boundary is theirs to set); an array is encoded.
1429
+ * Returns \`[contentType, body]\`.
1430
+ */
1431
+ function multipartBody(mixed $body): array
1432
+ {
1433
+ return is_array($body) ? toMultipart($body) : [null, $body];
1434
+ }
1435
+
1436
+ /** The body of an octet-stream operation: a stream resource or a string passes through; anything else is JSON. */
1437
+ function binaryBody(mixed $body): mixed
1438
+ {
1439
+ return is_resource($body) || is_string($body) ? $body : json_encode($body);
1440
+ }
1370
1441
  `;var n={"_errors.py":`# Runtime errors and the result-mode envelope for generated Python clients.
1371
1442
  # Hand-authored once, embedded into every generated client (see
1372
1443
  # scripts/generate-runtime-sources.mjs) \u2014 mirror of the TypeScript runtime's
@@ -1706,6 +1777,7 @@ def send(
1706
1777
  params: Optional[Dict[str, Any]] = None,
1707
1778
  json_body: Any = None,
1708
1779
  content: Any = None,
1780
+ content_type: Optional[str] = None,
1709
1781
  data: Any = None,
1710
1782
  files: Any = None,
1711
1783
  timeout: Optional[float] = None,
@@ -1727,6 +1799,9 @@ def send(
1727
1799
  merged_headers["Idempotency-Key"] = (
1728
1800
  key if isinstance(key, str) else key() if callable(key) else str(uuid.uuid4())
1729
1801
  )
1802
+ # The declared content type fills the gap; a caller-provided header always wins.
1803
+ if content_type is not None and not any(name.lower() == "content-type" for name in merged_headers):
1804
+ merged_headers["Content-Type"] = content_type
1730
1805
 
1731
1806
  context = {
1732
1807
  "url": url,
@@ -1741,7 +1816,9 @@ def send(
1741
1816
  if on_request:
1742
1817
  on_request(context)
1743
1818
 
1744
- max_attempts = 1 + int(merged_retry.get("retries", 0))
1819
+ # A file-like object or iterator is consumed by the first attempt and cannot be replayed, so it never retries.
1820
+ replayable = content is None or isinstance(content, (bytes, bytearray, str))
1821
+ max_attempts = 1 + int(merged_retry.get("retries", 0)) if replayable else 1
1745
1822
  retry_on = merged_retry.get("retry_on") or (
1746
1823
  lambda ctx: _default_retry_on(context["method"], context["headers"], ctx.get("response"))
1747
1824
  )
@@ -1800,6 +1877,7 @@ async def send_async(
1800
1877
  params: Optional[Dict[str, Any]] = None,
1801
1878
  json_body: Any = None,
1802
1879
  content: Any = None,
1880
+ content_type: Optional[str] = None,
1803
1881
  data: Any = None,
1804
1882
  files: Any = None,
1805
1883
  timeout: Optional[float] = None,
@@ -1819,6 +1897,8 @@ async def send_async(
1819
1897
  merged_headers["Idempotency-Key"] = (
1820
1898
  key if isinstance(key, str) else key() if callable(key) else str(uuid.uuid4())
1821
1899
  )
1900
+ if content_type is not None and not any(name.lower() == "content-type" for name in merged_headers):
1901
+ merged_headers["Content-Type"] = content_type
1822
1902
  context = {
1823
1903
  "url": url,
1824
1904
  "method": method.upper(),
@@ -1831,7 +1911,9 @@ async def send_async(
1831
1911
  on_request = getattr(mw, "on_request", None) or (mw.get("on_request") if isinstance(mw, dict) else None)
1832
1912
  if on_request:
1833
1913
  on_request(context)
1834
- max_attempts = 1 + int(merged_retry.get("retries", 0))
1914
+ # A file-like object or iterator is consumed by the first attempt and cannot be replayed, so it never retries.
1915
+ replayable = content is None or isinstance(content, (bytes, bytearray, str))
1916
+ max_attempts = 1 + int(merged_retry.get("retries", 0)) if replayable else 1
1835
1917
  retry_on = merged_retry.get("retry_on") or (
1836
1918
  lambda ctx: _default_retry_on(context["method"], context["headers"], ctx.get("response"))
1837
1919
  )
@@ -2244,7 +2326,9 @@ async def aiter_sse(
2244
2326
  `,"_multipart.py":`# Multipart bodies for generated Python clients \u2014 a typed dict/dataclass body is
2245
2327
  # split into httpx's (data, files): bytes and file-like values upload as parts,
2246
2328
  # everything else is form data (nested values JSON-encoded, mirroring the
2247
- # TypeScript runtime's FormData serialization).
2329
+ # TypeScript runtime's FormData serialization). A body that is already bytes, a
2330
+ # \`str\`, a file-like object, or an (async) iterator of bytes passes through as httpx
2331
+ # \`content=\` untouched; the caller sets its Content-Type.
2248
2332
  from __future__ import annotations
2249
2333
 
2250
2334
  import json
@@ -2265,4 +2349,20 @@ def to_multipart(body: Any) -> Tuple[Dict[str, Any], Dict[str, Any]]:
2265
2349
  else:
2266
2350
  data[key] = value
2267
2351
  return data, files
2352
+
2353
+
2354
+ def is_stream_body(body: Any) -> bool:
2355
+ return (
2356
+ isinstance(body, (bytes, bytearray, str))
2357
+ or callable(getattr(body, "read", None))
2358
+ or hasattr(body, "__next__")
2359
+ or hasattr(body, "__aiter__")
2360
+ )
2361
+
2362
+
2363
+ def multipart_arguments(body: Any) -> Dict[str, Any]:
2364
+ if is_stream_body(body):
2365
+ return {"content": body}
2366
+ data, files = to_multipart(body)
2367
+ return {"data": data, "files": files}
2268
2368
  `};export{e as a,t as b,n as c};
@@ -4,5 +4,5 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{l as t}from"./NC5GB4G5.js";import"./LRUXN6H5.js";import{ga as o}from"./PHV3T4WH.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function i({version:n}){new t(n).logout(),o.output(`Logged out from the Redocly account. \u270B
7
+ import{l as t}from"./3TBVUHVH.js";import"./LRUXN6H5.js";import{ia as o}from"./22EANOP2.js";import"./NEWT5A6S.js";import"./RFWIIJFG.js";async function i({version:n}){new t(n).logout(),o.output(`Logged out from the Redocly account. \u270B
8
8
  `)}export{i as handleLogout};
@@ -4,4 +4,4 @@ import { dirname as __pathDirname } from 'node:path';
4
4
  const require = __createRequire(import.meta.url);
5
5
  var __filename = __fileURLToPath(import.meta.url);
6
6
  var __dirname = __pathDirname(__filename);
7
- import{a,b,c,d,e,f}from"./IDDPOAAO.js";import"./2U6O26CV.js";import"./DBWAOHZO.js";import"./J56XVM43.js";import"./WZXA5XPB.js";import"./PHV3T4WH.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{f as pythonDocs,d as pythonGenerator,c as pythonOptions,e as pythonSample,a as pythonType,b as renderPythonModels};
7
+ import{a,b,c,d,e,f}from"./WCWEP2X5.js";import"./XJE2OFDN.js";import"./ERFYZ47T.js";import"./V5CIDI6D.js";import"./WZXA5XPB.js";import"./22EANOP2.js";import"./NEWT5A6S.js";import"./UW4UC7ZI.js";import"./RFWIIJFG.js";export{f as pythonDocs,d as pythonGenerator,c as pythonOptions,e as pythonSample,a as pythonType,b as renderPythonModels};
@@ -0,0 +1,8 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __pathDirname } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ var __filename = __fileURLToPath(import.meta.url);
6
+ var __dirname = __pathDirname(__filename);
7
+ import{u as o}from"./F6IXS3RL.js";import{ba as t}from"./22EANOP2.js";var r=" ",a=" ";function g(i){let p=Math.max(...i.map(n=>o(n).length)),e=p+a.length*2,c=r+t("\u2551"+" ".repeat(e)+"\u2551");return["",r+t("\u2554"+"\u2550".repeat(e)+"\u2557"),c,...i.map(n=>{let h=" ".repeat(p-o(n).length);return`${r}${t("\u2551")}${a}${n}${h}${a}${t("\u2551")}`}),c,r+t("\u255A"+"\u2550".repeat(e)+"\u255D"),"",""].join(`
8
+ `)}export{g as a};
@@ -91,29 +91,30 @@ discriminated union on `kind`: `scalar`, `array`, `object`, `record`, `ref`,
91
91
 
92
92
  ## Helpers (import from '@redocly/client-generator')
93
93
 
94
- | Helper | Use |
95
- | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
96
- | `flattenAllOf(schema, model)` | The merged property view of allOf compositions — languages without intersection types render this. |
97
- | `deref(schema, model)` | Follow a `ref` chain to the schema it names (cycle-guarded). |
98
- | `jsonSuccessSchema(op)` / `sseResponse(op)` | The primary JSON success schema; the `text/event-stream` response when the operation streams. |
99
- | `isMultipartBody(op)` | Whether the request body is multipart. |
100
- | `isBinaryContentType(contentType)` | Whether a body of this content type is bytes (archives, PDF, images, media) — decode it as a Blob, not JSON or text. |
101
- | `serverUrlParts(server)` | A server-URL template as literal/variable parts, ready for any concatenation syntax. |
102
- | `securityRequirements(op, model)` | The operation's security as OR-alternatives of AND-sets, denormalized against the declared schemes. |
103
- | `paginationItemSchema(pageSchema, itemsPointer, model)` | The raw element schema behind a pagination rule's `items` pointer — a `ref` element keeps its name. |
104
- | `discriminatorCases(schema, model)` | `{ property, cases }` dispatch table for discriminated unions. |
105
- | `isNullable(schema)` / `unwrapNullable(schema)` | Detect and strip `null` union members (`Optional[T]`, pointers, `Option<T>`). |
106
- | `enumValues(schema)` | Values plus SCREAMING_SNAKE member-name suggestions. |
107
- | `headerCoerceType(schema, model)` | Response-header coerce hint (`integer`/`number`/`boolean`/`string`) through refs, nullables, and allOf wrappers. |
108
- | `casing` / `identifierFor(name, { style, reserved })` | camel/pascal/snake/screaming; keyword-safe identifiers (`RESERVED_WORDS.python/go/typescript` shipped). |
109
- | `uniqueIdentifiers(names, { style, reserved, taken })` | The same, made unique among themselves and among names you already took — for a signature that takes one argument per parameter. |
110
- | `Printer` | Indentation-aware text builder — no manual whitespace bookkeeping. |
111
- | `docText(description)` | Description as trimmed lines for any comment syntax. |
112
- | `schemaAtPointer(schema, pointer, model)` | Resolve an RFC 6901 JSON pointer over a schema (through refs and allOf) — e.g. a pagination `items` pointer to its element type. |
113
- | `paginationRuleFor(op, config)` | The pagination rule that applies to an operation (per-op config > extension > fitting convention), normalized. |
114
- | `renderReferencePage(model, options)` | The Markdown reference page a generator's `docs` hook returns — your `sample` hook supplies its call snippets. |
115
- | `NotSupportedError` | Throw it to reject an option the generator can't honor — the CLI prints the message as a user error, not a crash. |
116
- | `AUTHORING_HELPER_NAMES` | The list of the above (introspection). |
94
+ | Helper | Use |
95
+ | ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
96
+ | `flattenAllOf(schema, model)` | The merged property view of allOf compositions — languages without intersection types render this. |
97
+ | `deref(schema, model)` | Follow a `ref` chain to the schema it names (cycle-guarded). |
98
+ | `jsonSuccessSchema(op)` / `sseResponse(op)` | The primary JSON success schema; the `text/event-stream` response when the operation streams. |
99
+ | `isMultipartBody(op)` | Whether the request body is multipart. |
100
+ | `isUntypedMultipartBody(op)` | Whether the request body is multipart with a schema that is neither an object nor a `$ref`, so the caller supplies the encoded body. |
101
+ | `isBinaryContentType(contentType)` | Whether a body of this content type is bytes (archives, PDF, images, media) — decode it as a Blob, not JSON or text. |
102
+ | `serverUrlParts(server)` | A server-URL template as literal/variable parts, ready for any concatenation syntax. |
103
+ | `securityRequirements(op, model)` | The operation's security as OR-alternatives of AND-sets, denormalized against the declared schemes. |
104
+ | `paginationItemSchema(pageSchema, itemsPointer, model)` | The raw element schema behind a pagination rule's `items` pointer — a `ref` element keeps its name. |
105
+ | `discriminatorCases(schema, model)` | `{ property, cases }` dispatch table for discriminated unions. |
106
+ | `isNullable(schema)` / `unwrapNullable(schema)` | Detect and strip `null` union members (`Optional[T]`, pointers, `Option<T>`). |
107
+ | `enumValues(schema)` | Values plus SCREAMING_SNAKE member-name suggestions. |
108
+ | `headerCoerceType(schema, model)` | Response-header coerce hint (`integer`/`number`/`boolean`/`string`) through refs, nullables, and allOf wrappers. |
109
+ | `casing` / `identifierFor(name, { style, reserved })` | camel/pascal/snake/screaming; keyword-safe identifiers (`RESERVED_WORDS.python/go/typescript` shipped). |
110
+ | `uniqueIdentifiers(names, { style, reserved, taken })` | The same, made unique among themselves and among names you already took — for a signature that takes one argument per parameter. |
111
+ | `Printer` | Indentation-aware text builder — no manual whitespace bookkeeping. |
112
+ | `docText(description)` | Description as trimmed lines for any comment syntax. |
113
+ | `schemaAtPointer(schema, pointer, model)` | Resolve an RFC 6901 JSON pointer over a schema (through refs and allOf) — e.g. a pagination `items` pointer to its element type. |
114
+ | `paginationRuleFor(op, config)` | The pagination rule that applies to an operation (per-op config > extension > fitting convention), normalized. |
115
+ | `renderReferencePage(model, options)` | The Markdown reference page a generator's `docs` hook returns — your `sample` hook supplies its call snippets. |
116
+ | `NotSupportedError` | Throw it to reject an option the generator can't honor — the CLI prints the message as a user error, not a crash. |
117
+ | `AUTHORING_HELPER_NAMES` | The list of the above (introspection). |
117
118
 
118
119
  Worked example: the built-in `python` generator
119
120
  (`packages/client-generator/src/generators/python/index.ts` in the Redocly CLI repo) is
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -86,5 +86,5 @@ export default {
86
86
  docs: cliDocs,
87
87
  requires: ["typescript","zod"],
88
88
  errorModes: ["throw"],
89
- requiresGenerator: '^0.4.24',
89
+ requiresGenerator: '^0.5.0',
90
90
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "cli" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "cli" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator cli --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -332,5 +332,5 @@ export default {
332
332
  "argsStyle": "inputs follow the target language's own idiom",
333
333
  "importExt": "the generated file has no relative imports"
334
334
  },
335
- requiresGenerator: '^0.4.24',
335
+ requiresGenerator: '^0.5.0',
336
336
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -9,7 +9,9 @@ import {
9
9
  type ApiModel,
10
10
  type DateType,
11
11
  headerCoerceType,
12
+ isBinaryContentType,
12
13
  isMultipartBody,
14
+ isUntypedMultipartBody,
13
15
  jsonSuccessSchema,
14
16
  type OperationModel,
15
17
  type ParamModel,
@@ -97,6 +99,10 @@ export function writeGoMethod(
97
99
  const success = jsonSuccessSchema(op);
98
100
  const returnType = success === undefined ? undefined : goType(success, dateType);
99
101
  const headerPlan = envelope ? envelopeHeaderPlan(op, model!) : [];
102
+ // An untyped multipart or a binary body is `any`: the runtime sorts out what it got.
103
+ const passThrough =
104
+ isUntypedMultipartBody(op) ||
105
+ (op.requestBody !== undefined && isBinaryContentType(op.requestBody.contentType));
100
106
  if (envelope) {
101
107
  printer.line(
102
108
  `// ${ident}Headers carries the declared response headers of ${ident}WithHeaders (nil when absent or unparsable).`
@@ -113,7 +119,9 @@ export function writeGoMethod(
113
119
  const args = [
114
120
  'ctx context.Context',
115
121
  ...pathArgs.map(({ go, type }) => `${go} ${type}`),
116
- ...(op.requestBody ? [`body ${goType(op.requestBody.schema, dateType)}`] : []),
122
+ ...(op.requestBody
123
+ ? [`body ${passThrough ? 'any' : goType(op.requestBody.schema, dateType)}`]
124
+ : []),
117
125
  ...(hasParams ? [`params *${ident}Params`] : []),
118
126
  ];
119
127
  const sse = sseResponse(op);
@@ -225,7 +233,31 @@ export function writeGoMethod(
225
233
  'Headers: authHeaders',
226
234
  'Query: query',
227
235
  ];
228
- if (op.requestBody && isMultipartBody(op)) {
236
+ if (isUntypedMultipartBody(op)) {
237
+ printer.line('contentType, reader, stream, err := multipartBody(body)');
238
+ printer.block(
239
+ 'if err != nil {',
240
+ () => {
241
+ printer.line(fail('err'));
242
+ },
243
+ '}'
244
+ );
245
+ specFields.push('Body: reader', 'Stream: stream', 'ContentType: contentType');
246
+ } else if (op.requestBody && passThrough) {
247
+ printer.line('reader, stream, err := binaryBody(body)');
248
+ printer.block(
249
+ 'if err != nil {',
250
+ () => {
251
+ printer.line(fail('err'));
252
+ },
253
+ '}'
254
+ );
255
+ specFields.push(
256
+ 'Body: reader',
257
+ 'Stream: stream',
258
+ `ContentType: ${naming.string(op.requestBody.contentType)}`
259
+ );
260
+ } else if (op.requestBody && isMultipartBody(op)) {
229
261
  printer.line('contentType, reader, err := toMultipart(body)');
230
262
  printer.block(
231
263
  'if err != nil {',
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "go" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "go" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator go --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -31,5 +31,5 @@ export default {
31
31
  name: 'mock',
32
32
  run: mockGenerator,
33
33
  requires: ["typescript"],
34
- requiresGenerator: '^0.4.24',
34
+ requiresGenerator: '^0.5.0',
35
35
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "mock" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "mock" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator mock --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -234,5 +234,5 @@ export default {
234
234
  "argsStyle": "inputs follow the target language's own idiom",
235
235
  "importExt": "the generated file has no relative imports"
236
236
  },
237
- requiresGenerator: '^0.4.24',
237
+ requiresGenerator: '^0.5.0',
238
238
  };
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.
@@ -1,4 +1,4 @@
1
- // Ejected from @redocly/client-generator@0.4.24 — the built-in "php" generator.
1
+ // Ejected from @redocly/client-generator@0.5.0 — the built-in "php" generator.
2
2
  // This file is yours: edit freely; the generated client stays machine-owned and is
3
3
  // rebuilt by `redocly generate-client`. Newer generator versions merge in with
4
4
  // `redocly eject-generator php --update`.