@orpc/openapi 0.0.0-next.6083cd9 → 0.0.0-next.67ca77c

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.
@@ -351,41 +351,53 @@ var OpenAPIPayloadCodec = class {
351
351
  };
352
352
  }
353
353
  async decode(re) {
354
- if (re instanceof Headers || re instanceof URLSearchParams || re instanceof FormData) {
355
- return deserialize([...re.entries()]);
356
- }
357
- const contentType = re.headers.get("content-type");
358
- const contentDisposition = re.headers.get("content-disposition");
359
- const fileName = contentDisposition ? cd.parse(contentDisposition).parameters.filename : void 0;
360
- if (fileName) {
361
- const blob2 = await re.blob();
362
- const file = new File([blob2], fileName, {
363
- type: blob2.type
364
- });
365
- return file;
366
- }
367
- if (!contentType || contentType.startsWith("application/json")) {
368
- if (!re.body) {
369
- return void 0;
354
+ try {
355
+ if (re instanceof Headers || re instanceof URLSearchParams || re instanceof FormData) {
356
+ return deserialize([...re.entries()]);
370
357
  }
371
- return await re.json();
372
- }
373
- if (contentType.startsWith("application/x-www-form-urlencoded")) {
374
- const params = new URLSearchParams(await re.text());
375
- return this.decode(params);
376
- }
377
- if (contentType.startsWith("text/")) {
378
- const text = await re.text();
379
- return text;
380
- }
381
- if (contentType.startsWith("multipart/form-data")) {
382
- const form = await re.formData();
383
- return this.decode(form);
358
+ const contentType = re.headers.get("content-type");
359
+ const contentDisposition = re.headers.get("content-disposition");
360
+ const fileName = contentDisposition ? cd.parse(contentDisposition).parameters.filename : void 0;
361
+ if (fileName) {
362
+ const blob2 = await re.blob();
363
+ const file = new File([blob2], fileName, {
364
+ type: blob2.type
365
+ });
366
+ return file;
367
+ }
368
+ if (!contentType || contentType.startsWith("application/json")) {
369
+ if (!re.body) {
370
+ return void 0;
371
+ }
372
+ const text = await re.text();
373
+ if (!text) {
374
+ return void 0;
375
+ }
376
+ return JSON.parse(text);
377
+ }
378
+ if (contentType.startsWith("application/x-www-form-urlencoded")) {
379
+ const params = new URLSearchParams(await re.text());
380
+ return this.decode(params);
381
+ }
382
+ if (contentType.startsWith("text/")) {
383
+ const text = await re.text();
384
+ return text;
385
+ }
386
+ if (contentType.startsWith("multipart/form-data")) {
387
+ const form = await re.formData();
388
+ return this.decode(form);
389
+ }
390
+ const blob = await re.blob();
391
+ return new File([blob], "blob", {
392
+ type: blob.type
393
+ });
394
+ } catch (e) {
395
+ throw new ORPCError({
396
+ code: "BAD_REQUEST",
397
+ message: "Cannot parse request/response. Please check the request/response body and Content-Type header.",
398
+ cause: e
399
+ });
384
400
  }
385
- const blob = await re.blob();
386
- return new File([blob], "blob", {
387
- type: blob.type
388
- });
389
401
  }
390
402
  };
391
403
 
@@ -637,4 +649,4 @@ export {
637
649
  CompositeSchemaCoercer,
638
650
  OpenAPIHandler
639
651
  };
640
- //# sourceMappingURL=chunk-OXOO6JP7.js.map
652
+ //# sourceMappingURL=chunk-WNX6GP4X.js.map
package/dist/fetch.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  parsePath,
11
11
  serialize,
12
12
  stringifyPath
13
- } from "./chunk-OXOO6JP7.js";
13
+ } from "./chunk-WNX6GP4X.js";
14
14
  import "./chunk-KNYXLM77.js";
15
15
 
16
16
  // src/adapters/fetch/openapi-handler-server.ts
package/dist/index.js CHANGED
@@ -426,7 +426,7 @@ var OpenAPIGenerator = class {
426
426
  content: this.contentBuilder.build(bodySchema)
427
427
  } : void 0;
428
428
  const successResponse = {
429
- description: "OK",
429
+ description: fallbackToGlobalConfig2("defaultSuccessDescription", def.route?.successDescription),
430
430
  content: resBodySchema !== void 0 ? this.contentBuilder.build(resBodySchema, {
431
431
  example: def.outputExample
432
432
  }) : void 0,
package/dist/node.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-OXOO6JP7.js";
3
+ } from "./chunk-WNX6GP4X.js";
4
4
  import "./chunk-KNYXLM77.js";
5
5
 
6
6
  // src/adapters/node/openapi-handler.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "0.0.0-next.6083cd9",
4
+ "version": "0.0.0-next.67ca77c",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -49,9 +49,9 @@
49
49
  "json-schema-typed": "^8.0.1",
50
50
  "openapi3-ts": "^4.4.0",
51
51
  "wildcard-match": "^5.1.3",
52
- "@orpc/server": "0.0.0-next.6083cd9",
53
- "@orpc/shared": "0.0.0-next.6083cd9",
54
- "@orpc/contract": "0.0.0-next.6083cd9"
52
+ "@orpc/contract": "0.0.0-next.67ca77c",
53
+ "@orpc/server": "0.0.0-next.67ca77c",
54
+ "@orpc/shared": "0.0.0-next.67ca77c"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@readme/openapi-parser": "^2.6.0",