@orpc/openapi 0.0.0-next.8aec8f6 → 0.0.0-next.8b6cb3a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@
30
30
  - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
31
31
  - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
32
32
  - **📝 Contract-First Development**: Optionally define your API contract before implementation.
33
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
33
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
34
34
  - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
35
  - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
36
  - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
2
2
  export { OpenAPI } from '@orpc/contract';
3
- export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.B3hexduL.mjs';
3
+ export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.DYi1fARS.mjs';
4
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
5
  import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
6
  export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
2
2
  export { OpenAPI } from '@orpc/contract';
3
- export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.B3hexduL.js';
3
+ export { e as CompositeSchemaConverter, C as ConditionalSchemaConverter, b as OpenAPIGenerator, a as OpenAPIGeneratorGenerateOptions, O as OpenAPIGeneratorOptions, c as SchemaConvertOptions, d as SchemaConverter, S as SchemaConverterComponent } from './shared/openapi.DYi1fARS.js';
4
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
5
  import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
6
  export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { c as customOpenAPIOperation } from './shared/openapi.DrrBsJ0w.mjs';
2
- export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, p as expandArrayableSchema, o as expandUnionSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, q as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.DrrBsJ0w.mjs';
1
+ import { c as customOpenAPIOperation } from './shared/openapi.C_3bk7bB.mjs';
2
+ export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, p as expandArrayableSchema, o as expandUnionSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, q as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.C_3bk7bB.mjs';
3
3
  import { createORPCErrorFromJson } from '@orpc/client';
4
4
  import { StandardOpenAPISerializer, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer } from '@orpc/openapi-client/standard';
5
5
  import { ORPCError, createRouterClient } from '@orpc/server';
@@ -2,7 +2,7 @@ import { OpenAPI } from '@orpc/contract';
2
2
  import { Context, HTTPPath, Router } from '@orpc/server';
3
3
  import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
4
4
  import { Value, Promisable } from '@orpc/shared';
5
- import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.B3hexduL.mjs';
5
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DYi1fARS.mjs';
6
6
  import '@orpc/openapi-client/standard';
7
7
  import 'json-schema-typed/draft-2020-12';
8
8
 
@@ -2,7 +2,7 @@ import { OpenAPI } from '@orpc/contract';
2
2
  import { Context, HTTPPath, Router } from '@orpc/server';
3
3
  import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
4
4
  import { Value, Promisable } from '@orpc/shared';
5
- import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.B3hexduL.js';
5
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DYi1fARS.js';
6
6
  import '@orpc/openapi-client/standard';
7
7
  import 'json-schema-typed/draft-2020-12';
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { stringifyJSON, once, value } from '@orpc/shared';
2
- import { O as OpenAPIGenerator } from '../shared/openapi.DrrBsJ0w.mjs';
2
+ import { O as OpenAPIGenerator } from '../shared/openapi.C_3bk7bB.mjs';
3
3
  import '@orpc/client';
4
4
  import '@orpc/client/standard';
5
5
  import '@orpc/contract';
@@ -393,7 +393,7 @@ class OpenAPIGenerator {
393
393
  exclude: void 0,
394
394
  commonSchemas: void 0
395
395
  };
396
- const { baseSchemaConvertOptions, undefinedErrorJsonSchema } = await this.#resolveCommonSchemas(doc, options.commonSchemas);
396
+ const baseSchemaConvertOptions = await this.#resolveCommonSchemas(doc, options.commonSchemas);
397
397
  const contracts = [];
398
398
  await resolveContractProcedures({ path: [], router }, ({ contract, path }) => {
399
399
  if (!exclude(contract, path)) {
@@ -420,7 +420,7 @@ class OpenAPIGenerator {
420
420
  };
421
421
  await this.#request(doc, operationObjectRef, def, baseSchemaConvertOptions);
422
422
  await this.#successResponse(doc, operationObjectRef, def, baseSchemaConvertOptions);
423
- await this.#errorResponse(operationObjectRef, def, baseSchemaConvertOptions, undefinedErrorJsonSchema);
423
+ await this.#errorResponse(operationObjectRef, def, baseSchemaConvertOptions);
424
424
  }
425
425
  doc.paths ??= {};
426
426
  doc.paths[httpPath] ??= {};
@@ -445,26 +445,11 @@ ${errors.join("\n\n")}`
445
445
  return this.serializer.serialize(doc)[0];
446
446
  }
447
447
  async #resolveCommonSchemas(doc, commonSchemas) {
448
- let undefinedErrorJsonSchema = {
449
- type: "object",
450
- properties: {
451
- defined: { const: false },
452
- code: { type: "string" },
453
- status: { type: "number" },
454
- message: { type: "string" },
455
- data: {}
456
- },
457
- required: ["defined", "code", "status", "message"]
458
- };
459
- const baseSchemaConvertOptions = {};
448
+ const baseOptions = {};
460
449
  if (commonSchemas) {
461
- baseSchemaConvertOptions.components = [];
450
+ baseOptions.components = [];
462
451
  for (const key in commonSchemas) {
463
- const options = commonSchemas[key];
464
- if (options.schema === void 0) {
465
- continue;
466
- }
467
- const { schema, strategy = "input" } = options;
452
+ const { schema, strategy = "input" } = commonSchemas[key];
468
453
  const [required, json] = await this.converter.convert(schema, { strategy });
469
454
  const allowedStrategies = [strategy];
470
455
  if (strategy === "input") {
@@ -478,7 +463,7 @@ ${errors.join("\n\n")}`
478
463
  allowedStrategies.push("input");
479
464
  }
480
465
  }
481
- baseSchemaConvertOptions.components.push({
466
+ baseOptions.components.push({
482
467
  schema,
483
468
  required,
484
469
  ref: `#/components/schemas/${key}`,
@@ -488,19 +473,11 @@ ${errors.join("\n\n")}`
488
473
  doc.components ??= {};
489
474
  doc.components.schemas ??= {};
490
475
  for (const key in commonSchemas) {
491
- const options = commonSchemas[key];
492
- if (options.schema === void 0) {
493
- if (options.error === "UndefinedError") {
494
- doc.components.schemas[key] = toOpenAPISchema(undefinedErrorJsonSchema);
495
- undefinedErrorJsonSchema = { $ref: `#/components/schemas/${key}` };
496
- }
497
- continue;
498
- }
499
- const { schema, strategy = "input" } = options;
476
+ const { schema, strategy = "input" } = commonSchemas[key];
500
477
  const [, json] = await this.converter.convert(
501
478
  schema,
502
479
  {
503
- ...baseSchemaConvertOptions,
480
+ ...baseOptions,
504
481
  strategy,
505
482
  minStructureDepthForRef: 1
506
483
  // not allow use $ref for root schemas
@@ -509,7 +486,7 @@ ${errors.join("\n\n")}`
509
486
  doc.components.schemas[key] = toOpenAPISchema(json);
510
487
  }
511
488
  }
512
- return { baseSchemaConvertOptions, undefinedErrorJsonSchema };
489
+ return baseOptions;
513
490
  }
514
491
  async #request(doc, ref, def, baseSchemaConvertOptions) {
515
492
  const method = fallbackContractConfig("defaultMethod", def.route.method);
@@ -695,7 +672,7 @@ ${errors.join("\n\n")}`
695
672
  }
696
673
  }
697
674
  }
698
- async #errorResponse(ref, def, baseSchemaConvertOptions, undefinedErrorSchema) {
675
+ async #errorResponse(ref, def, baseSchemaConvertOptions) {
699
676
  const errorMap = def.errorMap;
700
677
  const errors = {};
701
678
  for (const code in errorMap) {
@@ -727,7 +704,17 @@ ${errors.join("\n\n")}`
727
704
  content: toOpenAPIContent({
728
705
  oneOf: [
729
706
  ...schemas,
730
- undefinedErrorSchema
707
+ {
708
+ type: "object",
709
+ properties: {
710
+ defined: { const: false },
711
+ code: { type: "string" },
712
+ status: { type: "number" },
713
+ message: { type: "string" },
714
+ data: {}
715
+ },
716
+ required: ["defined", "code", "status", "message"]
717
+ }
731
718
  ]
732
719
  })
733
720
  };
@@ -74,9 +74,6 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
74
74
  */
75
75
  strategy?: SchemaConvertOptions['strategy'];
76
76
  schema: AnySchema;
77
- } | {
78
- error: 'UndefinedError';
79
- schema?: never;
80
77
  }>;
81
78
  }
82
79
  /**
@@ -74,9 +74,6 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
74
74
  */
75
75
  strategy?: SchemaConvertOptions['strategy'];
76
76
  schema: AnySchema;
77
- } | {
78
- error: 'UndefinedError';
79
- schema?: never;
80
77
  }>;
81
78
  }
82
79
  /**
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.8aec8f6",
4
+ "version": "0.0.0-next.8b6cb3a",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -50,16 +50,16 @@
50
50
  ],
51
51
  "dependencies": {
52
52
  "json-schema-typed": "^8.0.1",
53
- "rou3": "^0.7.2",
54
- "@orpc/client": "0.0.0-next.8aec8f6",
55
- "@orpc/contract": "0.0.0-next.8aec8f6",
56
- "@orpc/server": "0.0.0-next.8aec8f6",
57
- "@orpc/shared": "0.0.0-next.8aec8f6",
58
- "@orpc/standard-server": "0.0.0-next.8aec8f6",
59
- "@orpc/openapi-client": "0.0.0-next.8aec8f6"
53
+ "rou3": "^0.6.0",
54
+ "@orpc/openapi-client": "0.0.0-next.8b6cb3a",
55
+ "@orpc/server": "0.0.0-next.8b6cb3a",
56
+ "@orpc/client": "0.0.0-next.8b6cb3a",
57
+ "@orpc/contract": "0.0.0-next.8b6cb3a",
58
+ "@orpc/standard-server": "0.0.0-next.8b6cb3a",
59
+ "@orpc/shared": "0.0.0-next.8b6cb3a"
60
60
  },
61
61
  "devDependencies": {
62
- "zod": "^3.25.67"
62
+ "zod": "^3.25.63"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "unbuild",