@orpc/openapi 0.0.0-next.e710b76 → 0.0.0-next.e77ba7d
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 +7 -2
- package/dist/adapters/aws-lambda/index.d.mts +6 -3
- package/dist/adapters/aws-lambda/index.d.ts +6 -3
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fastify/index.d.mts +23 -0
- package/dist/adapters/fastify/index.d.ts +23 -0
- package/dist/adapters/fastify/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +9 -3
- package/dist/adapters/fetch/index.d.ts +9 -3
- package/dist/adapters/fetch/index.mjs +1 -1
- package/dist/adapters/node/index.d.mts +9 -3
- package/dist/adapters/node/index.d.ts +9 -3
- package/dist/adapters/node/index.mjs +1 -1
- package/dist/adapters/standard/index.d.mts +8 -23
- package/dist/adapters/standard/index.d.ts +8 -23
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.d.mts +18 -3
- package/dist/plugins/index.d.ts +18 -3
- package/dist/plugins/index.mjs +58 -18
- package/dist/shared/{openapi.C_UtQ8Us.mjs → openapi.DIt-Z9W1.mjs} +19 -8
- package/dist/shared/{openapi.DrrBsJ0w.mjs → openapi.DNv9yFfn.mjs} +160 -45
- package/dist/shared/openapi.DwaweYRb.d.mts +54 -0
- package/dist/shared/openapi.DwaweYRb.d.ts +54 -0
- package/dist/shared/{openapi.B3hexduL.d.mts → openapi.dbQeFCUJ.d.mts} +23 -4
- package/dist/shared/{openapi.B3hexduL.d.ts → openapi.dbQeFCUJ.d.ts} +23 -4
- package/package.json +17 -10
- package/dist/shared/openapi.D3j94c9n.d.mts +0 -12
- package/dist/shared/openapi.D3j94c9n.d.ts +0 -12
|
@@ -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 {
|
|
@@ -33,7 +33,7 @@ interface ConditionalSchemaConverter extends SchemaConverter {
|
|
|
33
33
|
}
|
|
34
34
|
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
35
35
|
private readonly converters;
|
|
36
|
-
constructor(converters: ConditionalSchemaConverter[]);
|
|
36
|
+
constructor(converters: readonly ConditionalSchemaConverter[]);
|
|
37
37
|
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -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
|
*/
|
|
@@ -78,6 +85,18 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
|
78
85
|
error: 'UndefinedError';
|
|
79
86
|
schema?: never;
|
|
80
87
|
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Define a custom JSON schema for the error response body when using
|
|
90
|
+
* type-safe errors. Helps align ORPC error formatting with existing API
|
|
91
|
+
* response standards or conventions.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* - Return `null | undefined` to use the default error response body shaper.
|
|
95
|
+
*/
|
|
96
|
+
customErrorResponseBodySchema?: Value<JSONSchema | undefined | null, [
|
|
97
|
+
definedErrors: [code: string, defaultMessage: string, dataRequired: boolean, dataSchema: JSONSchema][],
|
|
98
|
+
status: number
|
|
99
|
+
]>;
|
|
81
100
|
}
|
|
82
101
|
/**
|
|
83
102
|
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
@@ -94,7 +113,7 @@ declare class OpenAPIGenerator {
|
|
|
94
113
|
*
|
|
95
114
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
96
115
|
*/
|
|
97
|
-
generate(router: AnyContractRouter | AnyRouter,
|
|
116
|
+
generate(router: AnyContractRouter | AnyRouter, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc }?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
98
117
|
}
|
|
99
118
|
|
|
100
119
|
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
|
@@ -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 {
|
|
@@ -33,7 +33,7 @@ interface ConditionalSchemaConverter extends SchemaConverter {
|
|
|
33
33
|
}
|
|
34
34
|
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
35
35
|
private readonly converters;
|
|
36
|
-
constructor(converters: ConditionalSchemaConverter[]);
|
|
36
|
+
constructor(converters: readonly ConditionalSchemaConverter[]);
|
|
37
37
|
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -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
|
*/
|
|
@@ -78,6 +85,18 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
|
78
85
|
error: 'UndefinedError';
|
|
79
86
|
schema?: never;
|
|
80
87
|
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Define a custom JSON schema for the error response body when using
|
|
90
|
+
* type-safe errors. Helps align ORPC error formatting with existing API
|
|
91
|
+
* response standards or conventions.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* - Return `null | undefined` to use the default error response body shaper.
|
|
95
|
+
*/
|
|
96
|
+
customErrorResponseBodySchema?: Value<JSONSchema | undefined | null, [
|
|
97
|
+
definedErrors: [code: string, defaultMessage: string, dataRequired: boolean, dataSchema: JSONSchema][],
|
|
98
|
+
status: number
|
|
99
|
+
]>;
|
|
81
100
|
}
|
|
82
101
|
/**
|
|
83
102
|
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
@@ -94,7 +113,7 @@ declare class OpenAPIGenerator {
|
|
|
94
113
|
*
|
|
95
114
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
96
115
|
*/
|
|
97
|
-
generate(router: AnyContractRouter | AnyRouter,
|
|
116
|
+
generate(router: AnyContractRouter | AnyRouter, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc }?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
98
117
|
}
|
|
99
118
|
|
|
100
119
|
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
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.
|
|
4
|
+
"version": "0.0.0-next.e77ba7d",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -39,6 +39,11 @@
|
|
|
39
39
|
"import": "./dist/adapters/node/index.mjs",
|
|
40
40
|
"default": "./dist/adapters/node/index.mjs"
|
|
41
41
|
},
|
|
42
|
+
"./fastify": {
|
|
43
|
+
"types": "./dist/adapters/fastify/index.d.mts",
|
|
44
|
+
"import": "./dist/adapters/fastify/index.mjs",
|
|
45
|
+
"default": "./dist/adapters/fastify/index.mjs"
|
|
46
|
+
},
|
|
42
47
|
"./aws-lambda": {
|
|
43
48
|
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
|
44
49
|
"import": "./dist/adapters/aws-lambda/index.mjs",
|
|
@@ -49,17 +54,19 @@
|
|
|
49
54
|
"dist"
|
|
50
55
|
],
|
|
51
56
|
"dependencies": {
|
|
52
|
-
"json-schema-typed": "^8.0.
|
|
53
|
-
"rou3": "^0.7.
|
|
54
|
-
"@orpc/
|
|
55
|
-
"@orpc/
|
|
56
|
-
"@orpc/
|
|
57
|
-
"@orpc/
|
|
58
|
-
"@orpc/
|
|
59
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
57
|
+
"json-schema-typed": "^8.0.2",
|
|
58
|
+
"rou3": "^0.7.10",
|
|
59
|
+
"@orpc/contract": "0.0.0-next.e77ba7d",
|
|
60
|
+
"@orpc/interop": "0.0.0-next.e77ba7d",
|
|
61
|
+
"@orpc/client": "0.0.0-next.e77ba7d",
|
|
62
|
+
"@orpc/server": "0.0.0-next.e77ba7d",
|
|
63
|
+
"@orpc/shared": "0.0.0-next.e77ba7d",
|
|
64
|
+
"@orpc/standard-server": "0.0.0-next.e77ba7d",
|
|
65
|
+
"@orpc/openapi-client": "0.0.0-next.e77ba7d"
|
|
60
66
|
},
|
|
61
67
|
"devDependencies": {
|
|
62
|
-
"
|
|
68
|
+
"fastify": "^5.6.2",
|
|
69
|
+
"zod": "^4.1.12"
|
|
63
70
|
},
|
|
64
71
|
"scripts": {
|
|
65
72
|
"build": "unbuild",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { StandardOpenAPIJsonSerializerOptions } 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 {
|
|
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 } 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 {
|
|
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 };
|