@orpc/openapi 1.7.0 → 1.7.2
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/dist/adapters/aws-lambda/index.d.mts +3 -1
- package/dist/adapters/aws-lambda/index.d.ts +3 -1
- package/dist/adapters/aws-lambda/index.mjs +1 -1
- package/dist/adapters/fetch/index.d.mts +3 -1
- package/dist/adapters/fetch/index.d.ts +3 -1
- package/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/node/index.d.mts +3 -1
- package/dist/adapters/node/index.d.ts +3 -1
- package/dist/adapters/node/index.mjs +1 -1
- package/dist/adapters/standard/index.d.mts +5 -11
- package/dist/adapters/standard/index.d.ts +5 -11
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/shared/{openapi.-sXpEIAO.mjs → openapi.BkBlt1Qf.mjs} +11 -3
- package/dist/shared/{openapi.DrrBsJ0w.mjs → openapi.BtoY8ZFF.mjs} +9 -5
- package/dist/shared/openapi.CQmjvnb0.d.mts +31 -0
- package/dist/shared/openapi.CQmjvnb0.d.ts +31 -0
- package/dist/shared/{openapi.8DHd5bRK.d.mts → openapi.DPAN3GVs.d.mts} +9 -2
- package/dist/shared/{openapi.8DHd5bRK.d.ts → openapi.DPAN3GVs.d.ts} +9 -2
- package/package.json +7 -7
- package/dist/shared/openapi.BWrlhfev.d.mts +0 -12
- package/dist/shared/openapi.BWrlhfev.d.ts +0 -12
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
2
2
|
import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
|
3
|
-
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.mjs';
|
4
4
|
import '@orpc/openapi-client/standard';
|
5
5
|
import '@orpc/server/standard';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/shared';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* OpenAPI Handler for AWS Lambda.
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
2
2
|
import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
|
3
|
-
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.js';
|
4
4
|
import '@orpc/openapi-client/standard';
|
5
5
|
import '@orpc/server/standard';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/shared';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* OpenAPI Handler for AWS Lambda.
|
@@ -2,7 +2,7 @@ import { AwsLambdaHandler } from '@orpc/server/aws-lambda';
|
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/contract';
|
4
4
|
import '@orpc/shared';
|
5
|
-
import { a as StandardOpenAPIHandler } from '../../shared/openapi
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.BkBlt1Qf.mjs';
|
6
6
|
import '@orpc/client/standard';
|
7
7
|
import '@orpc/server';
|
8
8
|
import 'rou3';
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
2
2
|
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
3
|
-
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.mjs';
|
4
4
|
import '@orpc/openapi-client/standard';
|
5
5
|
import '@orpc/server/standard';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/shared';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* OpenAPI Handler for Fetch Server
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
2
2
|
import { FetchHandler, FetchHandlerOptions } from '@orpc/server/fetch';
|
3
|
-
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.js';
|
4
4
|
import '@orpc/openapi-client/standard';
|
5
5
|
import '@orpc/server/standard';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/shared';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* OpenAPI Handler for Fetch Server
|
@@ -2,7 +2,7 @@ import { FetchHandler } from '@orpc/server/fetch';
|
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/contract';
|
4
4
|
import '@orpc/shared';
|
5
|
-
import { a as StandardOpenAPIHandler } from '../../shared/openapi
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.BkBlt1Qf.mjs';
|
6
6
|
import '@orpc/client/standard';
|
7
7
|
import '@orpc/server';
|
8
8
|
import 'rou3';
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
2
2
|
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
3
|
-
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.mjs';
|
4
4
|
import '@orpc/openapi-client/standard';
|
5
5
|
import '@orpc/server/standard';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/shared';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* OpenAPI Handler for Node Server
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
2
2
|
import { NodeHttpHandler, NodeHttpHandlerOptions } from '@orpc/server/node';
|
3
|
-
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
3
|
+
import { S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.CQmjvnb0.js';
|
4
4
|
import '@orpc/openapi-client/standard';
|
5
5
|
import '@orpc/server/standard';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/shared';
|
6
8
|
|
7
9
|
/**
|
8
10
|
* OpenAPI Handler for Node Server
|
@@ -2,7 +2,7 @@ import { NodeHttpHandler } from '@orpc/server/node';
|
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/contract';
|
4
4
|
import '@orpc/shared';
|
5
|
-
import { a as StandardOpenAPIHandler } from '../../shared/openapi
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.BkBlt1Qf.mjs';
|
6
6
|
import '@orpc/client/standard';
|
7
7
|
import '@orpc/server';
|
8
8
|
import 'rou3';
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { ORPCError, HTTPPath } from '@orpc/client';
|
2
2
|
import { StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
3
|
-
import { AnyProcedure
|
4
|
-
import { StandardCodec, StandardParams
|
3
|
+
import { AnyProcedure } from '@orpc/server';
|
4
|
+
import { StandardCodec, StandardParams } from '@orpc/server/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
6
|
+
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions, c as StandardOpenAPIMatcher, b as StandardOpenAPIMatcherOptions } from '../../shared/openapi.CQmjvnb0.mjs';
|
7
|
+
import '@orpc/shared';
|
7
8
|
|
8
9
|
declare class StandardOpenAPICodec implements StandardCodec {
|
9
10
|
#private;
|
@@ -14,13 +15,6 @@ declare class StandardOpenAPICodec implements StandardCodec {
|
|
14
15
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
15
16
|
}
|
16
17
|
|
17
|
-
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
18
|
-
private readonly tree;
|
19
|
-
private pendingRouters;
|
20
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
21
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
22
|
-
}
|
23
|
-
|
24
18
|
/**
|
25
19
|
* {@link https://github.com/unjs/rou3}
|
26
20
|
*
|
@@ -32,4 +26,4 @@ declare function toRou3Pattern(path: HTTPPath): string;
|
|
32
26
|
*/
|
33
27
|
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
34
28
|
|
35
|
-
export { StandardOpenAPICodec,
|
29
|
+
export { StandardOpenAPICodec, decodeParams, toRou3Pattern };
|
@@ -1,9 +1,10 @@
|
|
1
1
|
import { ORPCError, HTTPPath } from '@orpc/client';
|
2
2
|
import { StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
3
|
-
import { AnyProcedure
|
4
|
-
import { StandardCodec, StandardParams
|
3
|
+
import { AnyProcedure } from '@orpc/server';
|
4
|
+
import { StandardCodec, StandardParams } from '@orpc/server/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.
|
6
|
+
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions, c as StandardOpenAPIMatcher, b as StandardOpenAPIMatcherOptions } from '../../shared/openapi.CQmjvnb0.js';
|
7
|
+
import '@orpc/shared';
|
7
8
|
|
8
9
|
declare class StandardOpenAPICodec implements StandardCodec {
|
9
10
|
#private;
|
@@ -14,13 +15,6 @@ declare class StandardOpenAPICodec implements StandardCodec {
|
|
14
15
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
15
16
|
}
|
16
17
|
|
17
|
-
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
18
|
-
private readonly tree;
|
19
|
-
private pendingRouters;
|
20
|
-
init(router: AnyRouter, path?: readonly string[]): void;
|
21
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
22
|
-
}
|
23
|
-
|
24
18
|
/**
|
25
19
|
* {@link https://github.com/unjs/rou3}
|
26
20
|
*
|
@@ -32,4 +26,4 @@ declare function toRou3Pattern(path: HTTPPath): string;
|
|
32
26
|
*/
|
33
27
|
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
34
28
|
|
35
|
-
export { StandardOpenAPICodec,
|
29
|
+
export { StandardOpenAPICodec, decodeParams, toRou3Pattern };
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi
|
1
|
+
export { S as StandardOpenAPICodec, a as StandardOpenAPIHandler, b as StandardOpenAPIMatcher, d as decodeParams, t as toRou3Pattern } from '../../shared/openapi.BkBlt1Qf.mjs';
|
2
2
|
import '@orpc/openapi-client/standard';
|
3
3
|
import '@orpc/server/standard';
|
4
4
|
import '@orpc/client';
|
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.
|
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.DPAN3GVs.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.
|
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.DPAN3GVs.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.
|
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.
|
1
|
+
import { c as customOpenAPIOperation } from './shared/openapi.BtoY8ZFF.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.BtoY8ZFF.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';
|
package/dist/plugins/index.d.mts
CHANGED
@@ -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.
|
5
|
+
import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DPAN3GVs.mjs';
|
6
6
|
import '@orpc/openapi-client/standard';
|
7
7
|
import 'json-schema-typed/draft-2020-12';
|
8
8
|
|
package/dist/plugins/index.d.ts
CHANGED
@@ -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.
|
5
|
+
import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.DPAN3GVs.js';
|
6
6
|
import '@orpc/openapi-client/standard';
|
7
7
|
import 'json-schema-typed/draft-2020-12';
|
8
8
|
|
package/dist/plugins/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { stringifyJSON, once, value } from '@orpc/shared';
|
2
|
-
import { O as OpenAPIGenerator } from '../shared/openapi.
|
2
|
+
import { O as OpenAPIGenerator } from '../shared/openapi.BtoY8ZFF.mjs';
|
3
3
|
import '@orpc/client';
|
4
4
|
import '@orpc/client/standard';
|
5
5
|
import '@orpc/contract';
|
@@ -2,7 +2,7 @@ import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, StandardBracketNota
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
3
3
|
import { isORPCErrorStatus } from '@orpc/client';
|
4
4
|
import { fallbackContractConfig } from '@orpc/contract';
|
5
|
-
import { isObject, stringifyJSON } from '@orpc/shared';
|
5
|
+
import { isObject, stringifyJSON, value } from '@orpc/shared';
|
6
6
|
import { toHttpPath } from '@orpc/client/standard';
|
7
7
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@orpc/server';
|
8
8
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
@@ -101,10 +101,18 @@ function decodeParams(params) {
|
|
101
101
|
}
|
102
102
|
|
103
103
|
class StandardOpenAPIMatcher {
|
104
|
+
filter;
|
104
105
|
tree = createRouter();
|
105
106
|
pendingRouters = [];
|
107
|
+
constructor(options = {}) {
|
108
|
+
this.filter = options.filter ?? true;
|
109
|
+
}
|
106
110
|
init(router, path = []) {
|
107
|
-
const laziedOptions = traverseContractProcedures({ router, path }, (
|
111
|
+
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
112
|
+
if (!value(this.filter, traverseOptions)) {
|
113
|
+
return;
|
114
|
+
}
|
115
|
+
const { path: path2, contract } = traverseOptions;
|
108
116
|
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
109
117
|
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
110
118
|
if (isProcedure(contract)) {
|
@@ -170,7 +178,7 @@ class StandardOpenAPIHandler extends StandardHandler {
|
|
170
178
|
const jsonSerializer = new StandardOpenAPIJsonSerializer(options);
|
171
179
|
const bracketNotationSerializer = new StandardBracketNotationSerializer(options);
|
172
180
|
const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
|
173
|
-
const matcher = new StandardOpenAPIMatcher();
|
181
|
+
const matcher = new StandardOpenAPIMatcher(options);
|
174
182
|
const codec = new StandardOpenAPICodec(serializer);
|
175
183
|
super(router, matcher, codec, options);
|
176
184
|
}
|
@@ -3,7 +3,7 @@ import { toHttpPath } from '@orpc/client/standard';
|
|
3
3
|
import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@orpc/contract';
|
4
4
|
import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, getDynamicParams } from '@orpc/openapi-client/standard';
|
5
5
|
import { isProcedure, resolveContractProcedures } from '@orpc/server';
|
6
|
-
import { isObject, stringifyJSON, findDeepMatches, toArray, clone } from '@orpc/shared';
|
6
|
+
import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value } from '@orpc/shared';
|
7
7
|
import { TypeName } from 'json-schema-typed/draft-2020-12';
|
8
8
|
|
9
9
|
const OPERATION_EXTENDER_SYMBOL = Symbol("ORPC_OPERATION_EXTENDER");
|
@@ -385,20 +385,24 @@ class OpenAPIGenerator {
|
|
385
385
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
386
386
|
*/
|
387
387
|
async generate(router, options = {}) {
|
388
|
-
const
|
388
|
+
const filter = options.filter ?? (({ contract, path }) => {
|
389
|
+
return !(options.exclude?.(contract, path) ?? false);
|
390
|
+
});
|
389
391
|
const doc = {
|
390
392
|
...clone(options),
|
391
393
|
info: options.info ?? { title: "API Reference", version: "0.0.0" },
|
392
394
|
openapi: "3.1.1",
|
393
395
|
exclude: void 0,
|
396
|
+
filter: void 0,
|
394
397
|
commonSchemas: void 0
|
395
398
|
};
|
396
399
|
const { baseSchemaConvertOptions, undefinedErrorJsonSchema } = await this.#resolveCommonSchemas(doc, options.commonSchemas);
|
397
400
|
const contracts = [];
|
398
|
-
await resolveContractProcedures({ path: [], router }, (
|
399
|
-
if (!
|
400
|
-
|
401
|
+
await resolveContractProcedures({ path: [], router }, (traverseOptions) => {
|
402
|
+
if (!value(filter, traverseOptions)) {
|
403
|
+
return;
|
401
404
|
}
|
405
|
+
contracts.push(traverseOptions);
|
402
406
|
});
|
403
407
|
const errors = [];
|
404
408
|
for (const { contract, path } of contracts) {
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
2
|
+
import { TraverseContractProcedureCallbackOptions, AnyRouter, Context, Router } from '@orpc/server';
|
3
|
+
import { StandardMatcher, StandardMatchResult, StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
4
|
+
import { HTTPPath } from '@orpc/client';
|
5
|
+
import { Value } from '@orpc/shared';
|
6
|
+
|
7
|
+
interface StandardOpenAPIMatcherOptions {
|
8
|
+
/**
|
9
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
10
|
+
*
|
11
|
+
* @default true
|
12
|
+
*/
|
13
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
14
|
+
}
|
15
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
16
|
+
private readonly filter;
|
17
|
+
private readonly tree;
|
18
|
+
private pendingRouters;
|
19
|
+
constructor(options?: StandardOpenAPIMatcherOptions);
|
20
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
21
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
22
|
+
}
|
23
|
+
|
24
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPIMatcherOptions {
|
25
|
+
}
|
26
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
27
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
28
|
+
}
|
29
|
+
|
30
|
+
export { StandardOpenAPIHandler as a, StandardOpenAPIMatcher as c };
|
31
|
+
export type { StandardOpenAPIHandlerOptions as S, StandardOpenAPIMatcherOptions as b };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
2
|
+
import { TraverseContractProcedureCallbackOptions, AnyRouter, Context, Router } from '@orpc/server';
|
3
|
+
import { StandardMatcher, StandardMatchResult, StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
4
|
+
import { HTTPPath } from '@orpc/client';
|
5
|
+
import { Value } from '@orpc/shared';
|
6
|
+
|
7
|
+
interface StandardOpenAPIMatcherOptions {
|
8
|
+
/**
|
9
|
+
* Filter procedures. Return `false` to exclude a procedure from matching.
|
10
|
+
*
|
11
|
+
* @default true
|
12
|
+
*/
|
13
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
14
|
+
}
|
15
|
+
declare class StandardOpenAPIMatcher implements StandardMatcher {
|
16
|
+
private readonly filter;
|
17
|
+
private readonly tree;
|
18
|
+
private pendingRouters;
|
19
|
+
constructor(options?: StandardOpenAPIMatcherOptions);
|
20
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
21
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
22
|
+
}
|
23
|
+
|
24
|
+
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions, StandardOpenAPIMatcherOptions {
|
25
|
+
}
|
26
|
+
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
27
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
28
|
+
}
|
29
|
+
|
30
|
+
export { StandardOpenAPIHandler as a, StandardOpenAPIMatcher as c };
|
31
|
+
export type { StandardOpenAPIHandlerOptions as S, StandardOpenAPIMatcherOptions as b };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@orpc/contract';
|
2
2
|
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
3
|
-
import { AnyProcedure, AnyRouter } from '@orpc/server';
|
4
|
-
import { Promisable } from '@orpc/shared';
|
3
|
+
import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter } from '@orpc/server';
|
4
|
+
import { Promisable, Value } from '@orpc/shared';
|
5
5
|
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
6
6
|
|
7
7
|
interface SchemaConverterComponent {
|
@@ -44,9 +44,16 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
44
44
|
/**
|
45
45
|
* Exclude procedures from the OpenAPI specification.
|
46
46
|
*
|
47
|
+
* @deprecated Use `filter` option instead.
|
47
48
|
* @default () => false
|
48
49
|
*/
|
49
50
|
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
51
|
+
/**
|
52
|
+
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
53
|
+
*
|
54
|
+
* @default true
|
55
|
+
*/
|
56
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
50
57
|
/**
|
51
58
|
* Common schemas to be used for $ref resolution.
|
52
59
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { AnySchema, OpenAPI, AnyContractProcedure, AnyContractRouter } from '@orpc/contract';
|
2
2
|
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
3
|
-
import { AnyProcedure, AnyRouter } from '@orpc/server';
|
4
|
-
import { Promisable } from '@orpc/shared';
|
3
|
+
import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter } from '@orpc/server';
|
4
|
+
import { Promisable, Value } from '@orpc/shared';
|
5
5
|
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
6
6
|
|
7
7
|
interface SchemaConverterComponent {
|
@@ -44,9 +44,16 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
44
44
|
/**
|
45
45
|
* Exclude procedures from the OpenAPI specification.
|
46
46
|
*
|
47
|
+
* @deprecated Use `filter` option instead.
|
47
48
|
* @default () => false
|
48
49
|
*/
|
49
50
|
exclude?: (procedure: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
|
51
|
+
/**
|
52
|
+
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
53
|
+
*
|
54
|
+
* @default true
|
55
|
+
*/
|
56
|
+
filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
|
50
57
|
/**
|
51
58
|
* Common schemas to be used for $ref resolution.
|
52
59
|
*/
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/openapi",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.7.
|
4
|
+
"version": "1.7.2",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -51,12 +51,12 @@
|
|
51
51
|
"dependencies": {
|
52
52
|
"json-schema-typed": "^8.0.1",
|
53
53
|
"rou3": "^0.7.3",
|
54
|
-
"@orpc/contract": "1.7.
|
55
|
-
"@orpc/
|
56
|
-
"@orpc/client": "1.7.
|
57
|
-
"@orpc/server": "1.7.
|
58
|
-
"@orpc/shared": "1.7.
|
59
|
-
"@orpc/standard-server": "1.7.
|
54
|
+
"@orpc/contract": "1.7.2",
|
55
|
+
"@orpc/client": "1.7.2",
|
56
|
+
"@orpc/openapi-client": "1.7.2",
|
57
|
+
"@orpc/server": "1.7.2",
|
58
|
+
"@orpc/shared": "1.7.2",
|
59
|
+
"@orpc/standard-server": "1.7.2"
|
60
60
|
},
|
61
61
|
"devDependencies": {
|
62
62
|
"zod": "^4.0.5"
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
2
|
-
import { Context, Router } from '@orpc/server';
|
3
|
-
import { StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
4
|
-
|
5
|
-
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions {
|
6
|
-
}
|
7
|
-
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
8
|
-
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
9
|
-
}
|
10
|
-
|
11
|
-
export { StandardOpenAPIHandler as a };
|
12
|
-
export type { StandardOpenAPIHandlerOptions as S };
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions } from '@orpc/openapi-client/standard';
|
2
|
-
import { Context, Router } from '@orpc/server';
|
3
|
-
import { StandardHandlerOptions, StandardHandler } from '@orpc/server/standard';
|
4
|
-
|
5
|
-
interface StandardOpenAPIHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardOpenAPIJsonSerializerOptions, StandardBracketNotationSerializerOptions {
|
6
|
-
}
|
7
|
-
declare class StandardOpenAPIHandler<T extends Context> extends StandardHandler<T> {
|
8
|
-
constructor(router: Router<any, T>, options: NoInfer<StandardOpenAPIHandlerOptions<T>>);
|
9
|
-
}
|
10
|
-
|
11
|
-
export { StandardOpenAPIHandler as a };
|
12
|
-
export type { StandardOpenAPIHandlerOptions as S };
|