@orpc/openapi 0.0.0-next.b1b9914 → 0.0.0-next.b2d00a3

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
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
2
+ <image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
3
3
  </div>
4
4
 
5
5
  <h1></h1>
@@ -45,7 +45,7 @@
45
45
 
46
46
  ## Documentation
47
47
 
48
- You can find the full documentation [here](https://orpc.unnoq.com).
48
+ You can find the full documentation [here](https://orpc.dev).
49
49
 
50
50
  ## Packages
51
51
 
@@ -66,7 +66,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
66
66
 
67
67
  ## `@orpc/openapi`
68
68
 
69
- Generate OpenAPI specs and handle OpenAPI requests. Read the [documentation](https://orpc.unnoq.com/docs/openapi/getting-started) for more information.
69
+ Generate OpenAPI specs and handle OpenAPI requests. Read the [documentation](https://orpc.dev/docs/openapi/getting-started) for more information.
70
70
 
71
71
  ```ts
72
72
  import { createServer } from 'node:http'
@@ -10,8 +10,8 @@ import '@orpc/shared';
10
10
  /**
11
11
  * OpenAPI Handler for AWS Lambda.
12
12
  *
13
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
14
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
13
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
14
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
15
15
  */
16
16
  declare class OpenAPIHandler<T extends Context> extends AwsLambdaHandler<T> {
17
17
  constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & AwsLambdaHandlerOptions>);
@@ -10,8 +10,8 @@ import '@orpc/shared';
10
10
  /**
11
11
  * OpenAPI Handler for AWS Lambda.
12
12
  *
13
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
14
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
13
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
14
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
15
15
  */
16
16
  declare class OpenAPIHandler<T extends Context> extends AwsLambdaHandler<T> {
17
17
  constructor(router: Router<any, T>, options?: NoInfer<StandardOpenAPIHandlerOptions<T> & AwsLambdaHandlerOptions>);
@@ -12,8 +12,8 @@ interface OpenAPIHandlerOptions<T extends Context> extends FastifyHandlerOptions
12
12
  /**
13
13
  * OpenAPI Handler for Fastify Server
14
14
  *
15
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
15
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
17
17
  */
18
18
  declare class OpenAPIHandler<T extends Context> extends FastifyHandler<T> {
19
19
  constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
@@ -12,8 +12,8 @@ interface OpenAPIHandlerOptions<T extends Context> extends FastifyHandlerOptions
12
12
  /**
13
13
  * OpenAPI Handler for Fastify Server
14
14
  *
15
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
15
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
17
17
  */
18
18
  declare class OpenAPIHandler<T extends Context> extends FastifyHandler<T> {
19
19
  constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
@@ -12,8 +12,8 @@ interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T
12
12
  /**
13
13
  * OpenAPI Handler for Fetch Server
14
14
  *
15
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
15
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
17
17
  */
18
18
  declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
19
19
  constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
@@ -12,8 +12,8 @@ interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T
12
12
  /**
13
13
  * OpenAPI Handler for Fetch Server
14
14
  *
15
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
15
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
17
17
  */
18
18
  declare class OpenAPIHandler<T extends Context> extends FetchHandler<T> {
19
19
  constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
@@ -12,8 +12,8 @@ interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOption
12
12
  /**
13
13
  * OpenAPI Handler for Node Server
14
14
  *
15
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
15
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
17
17
  */
18
18
  declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
19
19
  constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
@@ -12,8 +12,8 @@ interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOption
12
12
  /**
13
13
  * OpenAPI Handler for Node Server
14
14
  *
15
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
- * @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
15
+ * @see {@link https://orpc.dev/docs/openapi/openapi-handler OpenAPI Handler Docs}
16
+ * @see {@link https://orpc.dev/docs/adapters/http HTTP Adapter Docs}
17
17
  */
18
18
  declare class OpenAPIHandler<T extends Context> extends NodeHttpHandler<T> {
19
19
  constructor(router: Router<any, T>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
package/dist/index.d.mts CHANGED
@@ -1,9 +1,9 @@
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.BfNjg7j9.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.BGy4N6eR.mjs';
4
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
- import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
6
- export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/interop/json-schema-typed/draft-2020-12';
5
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
7
7
  import { JsonifiedClient } from '@orpc/openapi-client';
8
8
  import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
9
9
  import { MaybeOptionalOptions } from '@orpc/shared';
@@ -13,7 +13,7 @@ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: Open
13
13
  /**
14
14
  * Customize The Operation Object by proxy an error map item or a middleware.
15
15
  *
16
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
16
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
17
  */
18
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
@@ -66,6 +66,12 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
66
66
  */
67
67
  declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
68
  declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
69
+ /**
70
+ * Simplifies composed object JSON Schemas (using anyOf, oneOf, allOf) by flattening nested compositions
71
+ *
72
+ * @warning The result is looser than the original schema and may not fully validate the same data.
73
+ */
74
+ declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
69
75
 
70
76
  declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
71
77
 
@@ -106,5 +112,5 @@ declare const oo: {
106
112
  spec: typeof customOpenAPIOperation;
107
113
  };
108
114
 
109
- export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
115
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, simplifyComposedObjectJsonSchemasAndRefs, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
110
116
  export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
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.BfNjg7j9.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.BGy4N6eR.js';
4
4
  import { HTTPPath, HTTPMethod } from '@orpc/client';
5
- import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
6
- export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/interop/json-schema-typed/draft-2020-12';
5
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
7
7
  import { JsonifiedClient } from '@orpc/openapi-client';
8
8
  import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
9
9
  import { MaybeOptionalOptions } from '@orpc/shared';
@@ -13,7 +13,7 @@ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: Open
13
13
  /**
14
14
  * Customize The Operation Object by proxy an error map item or a middleware.
15
15
  *
16
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
16
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
17
17
  */
18
18
  declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
19
19
  declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
@@ -66,6 +66,12 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
66
66
  */
67
67
  declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
68
68
  declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
69
+ /**
70
+ * Simplifies composed object JSON Schemas (using anyOf, oneOf, allOf) by flattening nested compositions
71
+ *
72
+ * @warning The result is looser than the original schema and may not fully validate the same data.
73
+ */
74
+ declare function simplifyComposedObjectJsonSchemasAndRefs(schema: JSONSchema, doc?: OpenAPI.Document): JSONSchema;
69
75
 
70
76
  declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
71
77
 
@@ -106,5 +112,5 @@ declare const oo: {
106
112
  spec: typeof customOpenAPIOperation;
107
113
  };
108
114
 
109
- export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
115
+ export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, simplifyComposedObjectJsonSchemasAndRefs, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
110
116
  export type { FileSchema, ObjectSchema, OverrideOperationValue };
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { c as customOpenAPIOperation } from './shared/openapi.DrTcell5.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.DrTcell5.mjs';
1
+ import { c as customOpenAPIOperation } from './shared/openapi.CoREqFh3.mjs';
2
+ export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, o as applySchemaOptionality, h as checkParamsSchema, q as expandArrayableSchema, p as expandUnionSchema, n as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, u as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, m as separateObjectSchema, s as simplifyComposedObjectJsonSchemasAndRefs, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.CoREqFh3.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';
6
6
  import { resolveMaybeOptionalOptions } from '@orpc/shared';
7
- export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/interop/json-schema-typed/draft-2020-12';
7
+ export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12';
8
8
  import '@orpc/client/standard';
9
9
  import '@orpc/contract';
10
10
 
@@ -2,9 +2,9 @@ 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.BfNjg7j9.mjs';
5
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.BGy4N6eR.mjs';
6
6
  import '@orpc/openapi-client/standard';
7
- import '@orpc/interop/json-schema-typed/draft-2020-12';
7
+ import 'json-schema-typed/draft-2020-12';
8
8
 
9
9
  interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGeneratorOptions {
10
10
  /**
@@ -2,9 +2,9 @@ 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.BfNjg7j9.js';
5
+ import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.BGy4N6eR.js';
6
6
  import '@orpc/openapi-client/standard';
7
- import '@orpc/interop/json-schema-typed/draft-2020-12';
7
+ import 'json-schema-typed/draft-2020-12';
8
8
 
9
9
  interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGeneratorOptions {
10
10
  /**
@@ -1,11 +1,11 @@
1
1
  import { stringifyJSON, once, value } from '@orpc/shared';
2
- import { O as OpenAPIGenerator } from '../shared/openapi.DrTcell5.mjs';
2
+ import { O as OpenAPIGenerator } from '../shared/openapi.CoREqFh3.mjs';
3
3
  import '@orpc/client';
4
4
  import '@orpc/client/standard';
5
5
  import '@orpc/contract';
6
6
  import '@orpc/openapi-client/standard';
7
7
  import '@orpc/server';
8
- import '@orpc/interop/json-schema-typed/draft-2020-12';
8
+ import 'json-schema-typed/draft-2020-12';
9
9
 
10
10
  class OpenAPIReferencePlugin {
11
11
  generator;
@@ -2,7 +2,7 @@ import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@or
2
2
  import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
3
3
  import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter } from '@orpc/server';
4
4
  import { Promisable, Value } from '@orpc/shared';
5
- import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
5
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
6
 
7
7
  interface SchemaConverterComponent {
8
8
  allowedStrategies: readonly SchemaConvertOptions['strategy'][];
@@ -101,7 +101,7 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
101
101
  /**
102
102
  * The generator that converts oRPC routers/contracts to OpenAPI specifications.
103
103
  *
104
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
104
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
105
105
  */
106
106
  declare class OpenAPIGenerator {
107
107
  #private;
@@ -111,7 +111,7 @@ declare class OpenAPIGenerator {
111
111
  /**
112
112
  * Generates OpenAPI specifications from oRPC routers/contracts.
113
113
  *
114
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
114
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
115
115
  */
116
116
  generate(router: AnyContractRouter | AnyRouter, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc }?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
117
117
  }
@@ -2,7 +2,7 @@ import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@or
2
2
  import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
3
3
  import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter } from '@orpc/server';
4
4
  import { Promisable, Value } from '@orpc/shared';
5
- import { JSONSchema } from '@orpc/interop/json-schema-typed/draft-2020-12';
5
+ import { JSONSchema } from 'json-schema-typed/draft-2020-12';
6
6
 
7
7
  interface SchemaConverterComponent {
8
8
  allowedStrategies: readonly SchemaConvertOptions['strategy'][];
@@ -101,7 +101,7 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
101
101
  /**
102
102
  * The generator that converts oRPC routers/contracts to OpenAPI specifications.
103
103
  *
104
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
104
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
105
105
  */
106
106
  declare class OpenAPIGenerator {
107
107
  #private;
@@ -111,7 +111,7 @@ declare class OpenAPIGenerator {
111
111
  /**
112
112
  * Generates OpenAPI specifications from oRPC routers/contracts.
113
113
  *
114
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
114
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
115
115
  */
116
116
  generate(router: AnyContractRouter | AnyRouter, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc }?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
117
117
  }
@@ -4,7 +4,7 @@ import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@orpc/con
4
4
  import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, getDynamicParams } from '@orpc/openapi-client/standard';
5
5
  import { isProcedure, resolveContractProcedures } from '@orpc/server';
6
6
  import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value } from '@orpc/shared';
7
- import { TypeName } from '@orpc/interop/json-schema-typed/draft-2020-12';
7
+ import { TypeName } from 'json-schema-typed/draft-2020-12';
8
8
 
9
9
  const OPERATION_EXTENDER_SYMBOL = Symbol("ORPC_OPERATION_EXTENDER");
10
10
  function customOpenAPIOperation(o, extend) {
@@ -359,6 +359,107 @@ function resolveOpenAPIJsonSchemaRef(doc, schema) {
359
359
  const resolved = doc.components?.schemas?.[name];
360
360
  return resolved ?? schema;
361
361
  }
362
+ function simplifyComposedObjectJsonSchemasAndRefs(schema, doc) {
363
+ if (doc) {
364
+ schema = resolveOpenAPIJsonSchemaRef(doc, schema);
365
+ }
366
+ if (typeof schema !== "object" || !schema.anyOf && !schema.oneOf && !schema.allOf) {
367
+ return schema;
368
+ }
369
+ const unionSchemas = [
370
+ ...toArray(schema.anyOf?.map((s) => simplifyComposedObjectJsonSchemasAndRefs(s, doc))),
371
+ ...toArray(schema.oneOf?.map((s) => simplifyComposedObjectJsonSchemasAndRefs(s, doc)))
372
+ ];
373
+ const objectUnionSchemas = [];
374
+ for (const u of unionSchemas) {
375
+ if (!isObjectSchema(u)) {
376
+ return schema;
377
+ }
378
+ objectUnionSchemas.push(u);
379
+ }
380
+ const mergedUnionPropertyMap = /* @__PURE__ */ new Map();
381
+ for (const u of objectUnionSchemas) {
382
+ if (u.properties) {
383
+ for (const [key, value] of Object.entries(u.properties)) {
384
+ let entry = mergedUnionPropertyMap.get(key);
385
+ if (!entry) {
386
+ const required = objectUnionSchemas.every((s) => s.required?.includes(key));
387
+ entry = { required, schemas: [] };
388
+ mergedUnionPropertyMap.set(key, entry);
389
+ }
390
+ entry.schemas.push(value);
391
+ }
392
+ }
393
+ }
394
+ const intersectionSchemas = toArray(schema.allOf?.map((s) => simplifyComposedObjectJsonSchemasAndRefs(s, doc)));
395
+ const objectIntersectionSchemas = [];
396
+ for (const u of intersectionSchemas) {
397
+ if (!isObjectSchema(u)) {
398
+ return schema;
399
+ }
400
+ objectIntersectionSchemas.push(u);
401
+ }
402
+ if (isObjectSchema(schema)) {
403
+ objectIntersectionSchemas.push(schema);
404
+ }
405
+ const mergedInteractionPropertyMap = /* @__PURE__ */ new Map();
406
+ for (const u of objectIntersectionSchemas) {
407
+ if (u.properties) {
408
+ for (const [key, value] of Object.entries(u.properties)) {
409
+ let entry = mergedInteractionPropertyMap.get(key);
410
+ if (!entry) {
411
+ const required = objectIntersectionSchemas.some((s) => s.required?.includes(key));
412
+ entry = { required, schemas: [] };
413
+ mergedInteractionPropertyMap.set(key, entry);
414
+ }
415
+ entry.schemas.push(value);
416
+ }
417
+ }
418
+ }
419
+ const resultObjectSchema = { type: "object", properties: {}, required: [] };
420
+ const keys = /* @__PURE__ */ new Set([
421
+ ...mergedUnionPropertyMap.keys(),
422
+ ...mergedInteractionPropertyMap.keys()
423
+ ]);
424
+ if (keys.size === 0) {
425
+ return schema;
426
+ }
427
+ const deduplicateSchemas = (schemas) => {
428
+ const seen = /* @__PURE__ */ new Set();
429
+ const result = [];
430
+ for (const schema2 of schemas) {
431
+ const key = stringifyJSON(schema2);
432
+ if (!seen.has(key)) {
433
+ seen.add(key);
434
+ result.push(schema2);
435
+ }
436
+ }
437
+ return result;
438
+ };
439
+ for (const key of keys) {
440
+ const unionEntry = mergedUnionPropertyMap.get(key);
441
+ const intersectionEntry = mergedInteractionPropertyMap.get(key);
442
+ resultObjectSchema.properties[key] = (() => {
443
+ const dedupedUnionSchemas = unionEntry ? deduplicateSchemas(unionEntry.schemas) : [];
444
+ const dedupedIntersectionSchemas = intersectionEntry ? deduplicateSchemas(intersectionEntry.schemas) : [];
445
+ if (!dedupedUnionSchemas.length) {
446
+ return dedupedIntersectionSchemas.length === 1 ? dedupedIntersectionSchemas[0] : { allOf: dedupedIntersectionSchemas };
447
+ }
448
+ if (!dedupedIntersectionSchemas.length) {
449
+ return dedupedUnionSchemas.length === 1 ? dedupedUnionSchemas[0] : { anyOf: dedupedUnionSchemas };
450
+ }
451
+ const allOf = deduplicateSchemas([
452
+ ...dedupedIntersectionSchemas,
453
+ dedupedUnionSchemas.length === 1 ? dedupedUnionSchemas[0] : { anyOf: dedupedUnionSchemas }
454
+ ]);
455
+ return allOf.length === 1 ? allOf[0] : { allOf };
456
+ })();
457
+ if (unionEntry?.required || intersectionEntry?.required) {
458
+ resultObjectSchema.required.push(key);
459
+ }
460
+ }
461
+ return resultObjectSchema;
462
+ }
362
463
 
363
464
  class CompositeSchemaConverter {
364
465
  converters;
@@ -387,7 +488,7 @@ class OpenAPIGenerator {
387
488
  /**
388
489
  * Generates OpenAPI specifications from oRPC routers/contracts.
389
490
  *
390
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
491
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
391
492
  */
392
493
  async generate(router, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc } = {}) {
393
494
  const filter = baseFilter ?? (({ contract, path }) => {
@@ -539,13 +640,15 @@ ${errors.join("\n\n")}`
539
640
  def.inputSchema,
540
641
  {
541
642
  ...baseSchemaConvertOptions,
542
- strategy: "input",
543
- minStructureDepthForRef: dynamicParams?.length || inputStructure === "detailed" ? 1 : 0
643
+ strategy: "input"
544
644
  }
545
645
  );
546
646
  if (isAnySchema(schema) && !dynamicParams?.length) {
547
647
  return;
548
648
  }
649
+ if (inputStructure === "detailed" || inputStructure === "compact" && (dynamicParams?.length || method === "GET")) {
650
+ schema = simplifyComposedObjectJsonSchemasAndRefs(schema, doc);
651
+ }
549
652
  if (inputStructure === "compact") {
550
653
  if (dynamicParams?.length) {
551
654
  const error2 = new OpenAPIGeneratorError(
@@ -564,14 +667,13 @@ ${errors.join("\n\n")}`
564
667
  ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
565
668
  }
566
669
  if (method === "GET") {
567
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, schema);
568
- if (!isObjectSchema(resolvedSchema)) {
670
+ if (!isObjectSchema(schema)) {
569
671
  throw new OpenAPIGeneratorError(
570
672
  'When method is "GET", input schema must satisfy: object | any | unknown'
571
673
  );
572
674
  }
573
675
  ref.parameters ??= [];
574
- ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
676
+ ref.parameters.push(...toOpenAPIParameters(schema, "query"));
575
677
  } else {
576
678
  ref.requestBody = {
577
679
  required,
@@ -586,7 +688,7 @@ ${errors.join("\n\n")}`
586
688
  if (!isObjectSchema(schema)) {
587
689
  throw error;
588
690
  }
589
- const resolvedParamSchema = schema.properties?.params !== void 0 ? resolveOpenAPIJsonSchemaRef(doc, schema.properties.params) : void 0;
691
+ const resolvedParamSchema = schema.properties?.params !== void 0 ? simplifyComposedObjectJsonSchemasAndRefs(schema.properties.params, doc) : void 0;
590
692
  if (dynamicParams?.length && (resolvedParamSchema === void 0 || !isObjectSchema(resolvedParamSchema) || !checkParamsSchema(resolvedParamSchema, dynamicParams))) {
591
693
  throw new OpenAPIGeneratorError(
592
694
  'When input structure is "detailed" and path has dynamic params, the "params" schema must be an object with all dynamic params as required.'
@@ -595,7 +697,7 @@ ${errors.join("\n\n")}`
595
697
  for (const from of ["params", "query", "headers"]) {
596
698
  const fromSchema = schema.properties?.[from];
597
699
  if (fromSchema !== void 0) {
598
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, fromSchema);
700
+ const resolvedSchema = simplifyComposedObjectJsonSchemasAndRefs(fromSchema, doc);
599
701
  if (!isObjectSchema(resolvedSchema)) {
600
702
  throw error;
601
703
  }
@@ -656,13 +758,14 @@ ${errors.join("\n\n")}`
656
758
 
657
759
  But got: ${stringifyJSON(item)}
658
760
  `);
659
- if (!isObjectSchema(item)) {
761
+ const simplifiedItem = simplifyComposedObjectJsonSchemasAndRefs(item, doc);
762
+ if (!isObjectSchema(simplifiedItem)) {
660
763
  throw error;
661
764
  }
662
765
  let schemaStatus;
663
766
  let schemaDescription;
664
- if (item.properties?.status !== void 0) {
665
- const statusSchema = resolveOpenAPIJsonSchemaRef(doc, item.properties.status);
767
+ if (simplifiedItem.properties?.status !== void 0) {
768
+ const statusSchema = resolveOpenAPIJsonSchemaRef(doc, simplifiedItem.properties.status);
666
769
  if (typeof statusSchema !== "object" || statusSchema.const === void 0 || typeof statusSchema.const !== "number" || !Number.isInteger(statusSchema.const) || isORPCErrorStatus(statusSchema.const)) {
667
770
  throw error;
668
771
  }
@@ -682,8 +785,8 @@ ${errors.join("\n\n")}`
682
785
  ref.responses[itemStatus] = {
683
786
  description: itemDescription
684
787
  };
685
- if (item.properties?.headers !== void 0) {
686
- const headersSchema = resolveOpenAPIJsonSchemaRef(doc, item.properties.headers);
788
+ if (simplifiedItem.properties?.headers !== void 0) {
789
+ const headersSchema = simplifyComposedObjectJsonSchemasAndRefs(simplifiedItem.properties.headers, doc);
687
790
  if (!isObjectSchema(headersSchema)) {
688
791
  throw error;
689
792
  }
@@ -693,14 +796,14 @@ ${errors.join("\n\n")}`
693
796
  ref.responses[itemStatus].headers ??= {};
694
797
  ref.responses[itemStatus].headers[key] = {
695
798
  schema: toOpenAPISchema(headerSchema),
696
- required: item.required?.includes("headers") && headersSchema.required?.includes(key)
799
+ required: simplifiedItem.required?.includes("headers") && headersSchema.required?.includes(key)
697
800
  };
698
801
  }
699
802
  }
700
803
  }
701
- if (item.properties?.body !== void 0) {
804
+ if (simplifiedItem.properties?.body !== void 0) {
702
805
  ref.responses[itemStatus].content = toOpenAPIContent(
703
- applySchemaOptionality(item.required?.includes("body") ?? false, item.properties.body)
806
+ applySchemaOptionality(simplifiedItem.required?.includes("body") ?? false, simplifiedItem.properties.body)
704
807
  );
705
808
  }
706
809
  }
@@ -747,4 +850,4 @@ ${errors.join("\n\n")}`
747
850
  }
748
851
  }
749
852
 
750
- export { CompositeSchemaConverter as C, LOGIC_KEYWORDS as L, OpenAPIGenerator as O, applyCustomOpenAPIOperation as a, toOpenAPIMethod as b, customOpenAPIOperation as c, toOpenAPIContent as d, toOpenAPIEventIteratorContent as e, toOpenAPIParameters as f, getCustomOpenAPIOperation as g, checkParamsSchema as h, toOpenAPISchema as i, isFileSchema as j, isObjectSchema as k, isAnySchema as l, filterSchemaBranches as m, applySchemaOptionality as n, expandUnionSchema as o, expandArrayableSchema as p, isPrimitiveSchema as q, resolveOpenAPIJsonSchemaRef as r, separateObjectSchema as s, toOpenAPIPath as t };
853
+ export { CompositeSchemaConverter as C, LOGIC_KEYWORDS as L, OpenAPIGenerator as O, applyCustomOpenAPIOperation as a, toOpenAPIMethod as b, customOpenAPIOperation as c, toOpenAPIContent as d, toOpenAPIEventIteratorContent as e, toOpenAPIParameters as f, getCustomOpenAPIOperation as g, checkParamsSchema as h, toOpenAPISchema as i, isFileSchema as j, isObjectSchema as k, isAnySchema as l, separateObjectSchema as m, filterSchemaBranches as n, applySchemaOptionality as o, expandUnionSchema as p, expandArrayableSchema as q, resolveOpenAPIJsonSchemaRef as r, simplifyComposedObjectJsonSchemasAndRefs as s, toOpenAPIPath as t, isPrimitiveSchema as u };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "0.0.0-next.b1b9914",
4
+ "version": "0.0.0-next.b2d00a3",
5
5
  "license": "MIT",
6
- "homepage": "https://orpc.unnoq.com",
6
+ "homepage": "https://orpc.dev",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/unnoq/orpc.git",
@@ -54,17 +54,18 @@
54
54
  "dist"
55
55
  ],
56
56
  "dependencies": {
57
- "rou3": "^0.7.9",
58
- "@orpc/client": "0.0.0-next.b1b9914",
59
- "@orpc/contract": "0.0.0-next.b1b9914",
60
- "@orpc/interop": "0.0.0-next.b1b9914",
61
- "@orpc/openapi-client": "0.0.0-next.b1b9914",
62
- "@orpc/server": "0.0.0-next.b1b9914",
63
- "@orpc/standard-server": "0.0.0-next.b1b9914",
64
- "@orpc/shared": "0.0.0-next.b1b9914"
57
+ "json-schema-typed": "^8.0.2",
58
+ "rou3": "^0.7.10",
59
+ "@orpc/client": "0.0.0-next.b2d00a3",
60
+ "@orpc/contract": "0.0.0-next.b2d00a3",
61
+ "@orpc/interop": "0.0.0-next.b2d00a3",
62
+ "@orpc/openapi-client": "0.0.0-next.b2d00a3",
63
+ "@orpc/server": "0.0.0-next.b2d00a3",
64
+ "@orpc/shared": "0.0.0-next.b2d00a3",
65
+ "@orpc/standard-server": "0.0.0-next.b2d00a3"
65
66
  },
66
67
  "devDependencies": {
67
- "fastify": "^5.6.1",
68
+ "fastify": "^5.6.2",
68
69
  "zod": "^4.1.12"
69
70
  },
70
71
  "scripts": {