@orpc/openapi 0.0.0-next.4748dc5 → 0.0.0-next.47dbd93
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 +132 -13
- package/dist/adapters/aws-lambda/index.d.mts +4 -3
- package/dist/adapters/aws-lambda/index.d.ts +4 -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 +4 -3
- package/dist/adapters/fetch/index.d.ts +4 -3
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +4 -3
- package/dist/adapters/node/index.d.ts +4 -3
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +7 -16
- package/dist/adapters/standard/index.d.ts +7 -16
- package/dist/adapters/standard/index.mjs +1 -1
- package/dist/index.d.mts +12 -5
- package/dist/index.d.ts +12 -5
- package/dist/index.mjs +3 -3
- package/dist/plugins/index.d.mts +4 -2
- package/dist/plugins/index.d.ts +4 -2
- package/dist/plugins/index.mjs +21 -12
- package/dist/shared/{openapi.BVXcB0u4.mjs → openapi.BB-W-NKv.mjs} +20 -3
- package/dist/shared/{openapi.CfjfVeBJ.d.mts → openapi.BGy4N6eR.d.mts} +16 -4
- package/dist/shared/{openapi.CfjfVeBJ.d.ts → openapi.BGy4N6eR.d.ts} +16 -4
- package/dist/shared/{openapi.BlSv9FKY.mjs → openapi.BwdtJjDu.mjs} +173 -46
- package/dist/shared/openapi.DwaweYRb.d.mts +54 -0
- package/dist/shared/openapi.DwaweYRb.d.ts +54 -0
- package/package.json +20 -13
- package/dist/shared/openapi.CQmjvnb0.d.mts +0 -31
- package/dist/shared/openapi.CQmjvnb0.d.ts +0 -31
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.
|
|
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 '
|
|
6
|
-
export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '
|
|
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.
|
|
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
|
|
|
@@ -81,6 +87,7 @@ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
|
81
87
|
* @internal
|
|
82
88
|
*/
|
|
83
89
|
declare function isAnySchema(schema: JSONSchema): boolean;
|
|
90
|
+
declare function isNeverSchema(schema: JSONSchema): boolean;
|
|
84
91
|
/**
|
|
85
92
|
* @internal
|
|
86
93
|
*/
|
|
@@ -106,5 +113,5 @@ declare const oo: {
|
|
|
106
113
|
spec: typeof customOpenAPIOperation;
|
|
107
114
|
};
|
|
108
115
|
|
|
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 };
|
|
116
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isNeverSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, simplifyComposedObjectJsonSchemasAndRefs, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
110
117
|
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { c as customOpenAPIOperation } from './shared/openapi.
|
|
2
|
-
export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation,
|
|
1
|
+
import { c as customOpenAPIOperation } from './shared/openapi.BwdtJjDu.mjs';
|
|
2
|
+
export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, p as applySchemaOptionality, h as checkParamsSchema, u as expandArrayableSchema, q as expandUnionSchema, o as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, m as isNeverSchema, k as isObjectSchema, v as isPrimitiveSchema, r as resolveOpenAPIJsonSchemaRef, n 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.BwdtJjDu.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 '
|
|
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
|
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -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.
|
|
5
|
+
import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.BGy4N6eR.mjs';
|
|
6
6
|
import '@orpc/openapi-client/standard';
|
|
7
|
-
import '
|
|
7
|
+
import 'json-schema-typed/draft-2020-12';
|
|
8
8
|
|
|
9
9
|
interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGeneratorOptions {
|
|
10
10
|
/**
|
|
@@ -43,6 +43,8 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
|
|
|
43
43
|
/**
|
|
44
44
|
* HTML to inject into the <head> of the docs page.
|
|
45
45
|
*
|
|
46
|
+
* @warning This is not escaped special characters, so must be used with caution to avoid XSS vulnerabilities.
|
|
47
|
+
*
|
|
46
48
|
* @default ''
|
|
47
49
|
*/
|
|
48
50
|
docsHead?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -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.
|
|
5
|
+
import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.BGy4N6eR.js';
|
|
6
6
|
import '@orpc/openapi-client/standard';
|
|
7
|
-
import '
|
|
7
|
+
import 'json-schema-typed/draft-2020-12';
|
|
8
8
|
|
|
9
9
|
interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGeneratorOptions {
|
|
10
10
|
/**
|
|
@@ -43,6 +43,8 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
|
|
|
43
43
|
/**
|
|
44
44
|
* HTML to inject into the <head> of the docs page.
|
|
45
45
|
*
|
|
46
|
+
* @warning This is not escaped special characters, so must be used with caution to avoid XSS vulnerabilities.
|
|
47
|
+
*
|
|
46
48
|
* @default ''
|
|
47
49
|
*/
|
|
48
50
|
docsHead?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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.BwdtJjDu.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 '
|
|
8
|
+
import 'json-schema-typed/draft-2020-12';
|
|
9
9
|
|
|
10
10
|
class OpenAPIReferencePlugin {
|
|
11
11
|
generator;
|
|
@@ -30,7 +30,8 @@ class OpenAPIReferencePlugin {
|
|
|
30
30
|
this.docsHead = options.docsHead ?? "";
|
|
31
31
|
this.specPath = options.specPath ?? "/spec.json";
|
|
32
32
|
this.generator = new OpenAPIGenerator(options);
|
|
33
|
-
const
|
|
33
|
+
const escapeHtmlEntities = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
34
|
+
const escapeJsonForHtml = (obj) => stringifyJSON(obj).replace(/&/g, "\\u0026").replace(/'/g, "\\u0027").replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/\//g, "\\u002F");
|
|
34
35
|
this.renderDocsHtml = options.renderDocsHtml ?? ((specUrl, title, head, scriptUrl, config, spec, docsProvider, cssUrl) => {
|
|
35
36
|
let body;
|
|
36
37
|
if (docsProvider === "swagger") {
|
|
@@ -51,11 +52,15 @@ class OpenAPIReferencePlugin {
|
|
|
51
52
|
<body>
|
|
52
53
|
<div id="app"></div>
|
|
53
54
|
|
|
54
|
-
<script src="${
|
|
55
|
+
<script src="${escapeHtmlEntities(scriptUrl)}"><\/script>
|
|
55
56
|
|
|
57
|
+
<!-- IMPORTANT: assign to a variable first to prevent ), ( in values breaking the call expression. -->
|
|
58
|
+
<!-- IMPORTANT: escapeJsonForHtml ensures <, > cannot terminate the <\/script> tag prematurely. -->
|
|
56
59
|
<script>
|
|
60
|
+
const swaggerConfig = ${escapeJsonForHtml(swaggerConfig).replace(/"(SwaggerUIBundle\.[^"]+)"/g, "$1")}
|
|
61
|
+
|
|
57
62
|
window.onload = () => {
|
|
58
|
-
window.ui = SwaggerUIBundle(
|
|
63
|
+
window.ui = SwaggerUIBundle(swaggerConfig)
|
|
59
64
|
}
|
|
60
65
|
<\/script>
|
|
61
66
|
</body>
|
|
@@ -67,12 +72,16 @@ class OpenAPIReferencePlugin {
|
|
|
67
72
|
};
|
|
68
73
|
body = `
|
|
69
74
|
<body>
|
|
70
|
-
<div id="app"
|
|
71
|
-
|
|
72
|
-
<script src="${
|
|
73
|
-
|
|
75
|
+
<div id="app"></div>
|
|
76
|
+
|
|
77
|
+
<script src="${escapeHtmlEntities(scriptUrl)}"><\/script>
|
|
78
|
+
|
|
79
|
+
<!-- IMPORTANT: assign to a variable first to prevent ), ( in values breaking the call expression. -->
|
|
80
|
+
<!-- IMPORTANT: escapeJsonForHtml ensures <, > cannot terminate the <\/script> tag prematurely. -->
|
|
74
81
|
<script>
|
|
75
|
-
|
|
82
|
+
const scalarConfig = ${escapeJsonForHtml(scalarConfig)}
|
|
83
|
+
|
|
84
|
+
Scalar.createApiReference('#app', scalarConfig)
|
|
76
85
|
<\/script>
|
|
77
86
|
</body>
|
|
78
87
|
`;
|
|
@@ -83,8 +92,8 @@ class OpenAPIReferencePlugin {
|
|
|
83
92
|
<head>
|
|
84
93
|
<meta charset="utf-8" />
|
|
85
94
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
86
|
-
<title>${
|
|
87
|
-
${cssUrl ? `<link rel="stylesheet" type="text/css" href="${
|
|
95
|
+
<title>${escapeHtmlEntities(title)}</title>
|
|
96
|
+
${cssUrl ? `<link rel="stylesheet" type="text/css" href="${escapeHtmlEntities(cssUrl)}" />` : ""}
|
|
88
97
|
${head}
|
|
89
98
|
</head>
|
|
90
99
|
${body}
|
|
@@ -8,9 +8,11 @@ import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter
|
|
|
8
8
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
9
9
|
|
|
10
10
|
class StandardOpenAPICodec {
|
|
11
|
-
constructor(serializer) {
|
|
11
|
+
constructor(serializer, options = {}) {
|
|
12
12
|
this.serializer = serializer;
|
|
13
|
+
this.customErrorResponseBodyEncoder = options.customErrorResponseBodyEncoder;
|
|
13
14
|
}
|
|
15
|
+
customErrorResponseBodyEncoder;
|
|
14
16
|
async decode(request, params, procedure) {
|
|
15
17
|
const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
|
|
16
18
|
if (inputStructure === "compact") {
|
|
@@ -47,6 +49,13 @@ class StandardOpenAPICodec {
|
|
|
47
49
|
const successStatus = fallbackContractConfig("defaultSuccessStatus", procedure["~orpc"].route.successStatus);
|
|
48
50
|
const outputStructure = fallbackContractConfig("defaultOutputStructure", procedure["~orpc"].route.outputStructure);
|
|
49
51
|
if (outputStructure === "compact") {
|
|
52
|
+
if (output instanceof ReadableStream) {
|
|
53
|
+
return {
|
|
54
|
+
status: successStatus,
|
|
55
|
+
headers: {},
|
|
56
|
+
body: output
|
|
57
|
+
};
|
|
58
|
+
}
|
|
50
59
|
return {
|
|
51
60
|
status: successStatus,
|
|
52
61
|
headers: {},
|
|
@@ -66,6 +75,13 @@ class StandardOpenAPICodec {
|
|
|
66
75
|
${stringifyJSON(output)}
|
|
67
76
|
`);
|
|
68
77
|
}
|
|
78
|
+
if (output.body instanceof ReadableStream) {
|
|
79
|
+
return {
|
|
80
|
+
status: output.status ?? successStatus,
|
|
81
|
+
headers: output.headers ?? {},
|
|
82
|
+
body: output.body
|
|
83
|
+
};
|
|
84
|
+
}
|
|
69
85
|
return {
|
|
70
86
|
status: output.status ?? successStatus,
|
|
71
87
|
headers: output.headers ?? {},
|
|
@@ -73,10 +89,11 @@ class StandardOpenAPICodec {
|
|
|
73
89
|
};
|
|
74
90
|
}
|
|
75
91
|
encodeError(error) {
|
|
92
|
+
const body = this.customErrorResponseBodyEncoder?.(error) ?? error.toJSON();
|
|
76
93
|
return {
|
|
77
94
|
status: error.status,
|
|
78
95
|
headers: {},
|
|
79
|
-
body: this.serializer.serialize(
|
|
96
|
+
body: this.serializer.serialize(body, { outputFormat: "plain" })
|
|
80
97
|
};
|
|
81
98
|
}
|
|
82
99
|
#isDetailedOutput(output) {
|
|
@@ -179,7 +196,7 @@ class StandardOpenAPIHandler extends StandardHandler {
|
|
|
179
196
|
const bracketNotationSerializer = new StandardBracketNotationSerializer(options);
|
|
180
197
|
const serializer = new StandardOpenAPISerializer(jsonSerializer, bracketNotationSerializer);
|
|
181
198
|
const matcher = new StandardOpenAPIMatcher(options);
|
|
182
|
-
const codec = new StandardOpenAPICodec(serializer);
|
|
199
|
+
const codec = new StandardOpenAPICodec(serializer, options);
|
|
183
200
|
super(router, matcher, codec, options);
|
|
184
201
|
}
|
|
185
202
|
}
|
|
@@ -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 '
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
6
|
|
|
7
7
|
interface SchemaConverterComponent {
|
|
8
8
|
allowedStrategies: readonly SchemaConvertOptions['strategy'][];
|
|
@@ -85,11 +85,23 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
|
85
85
|
error: 'UndefinedError';
|
|
86
86
|
schema?: never;
|
|
87
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
|
+
]>;
|
|
88
100
|
}
|
|
89
101
|
/**
|
|
90
102
|
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
91
103
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
104
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
93
105
|
*/
|
|
94
106
|
declare class OpenAPIGenerator {
|
|
95
107
|
#private;
|
|
@@ -99,9 +111,9 @@ declare class OpenAPIGenerator {
|
|
|
99
111
|
/**
|
|
100
112
|
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
101
113
|
*
|
|
102
|
-
* @see {@link https://orpc.
|
|
114
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
103
115
|
*/
|
|
104
|
-
generate(router: AnyContractRouter | AnyRouter,
|
|
116
|
+
generate(router: AnyContractRouter | AnyRouter, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc }?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
105
117
|
}
|
|
106
118
|
|
|
107
119
|
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|
|
@@ -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 '
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
6
|
|
|
7
7
|
interface SchemaConverterComponent {
|
|
8
8
|
allowedStrategies: readonly SchemaConvertOptions['strategy'][];
|
|
@@ -85,11 +85,23 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
|
85
85
|
error: 'UndefinedError';
|
|
86
86
|
schema?: never;
|
|
87
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
|
+
]>;
|
|
88
100
|
}
|
|
89
101
|
/**
|
|
90
102
|
* The generator that converts oRPC routers/contracts to OpenAPI specifications.
|
|
91
103
|
*
|
|
92
|
-
* @see {@link https://orpc.
|
|
104
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
93
105
|
*/
|
|
94
106
|
declare class OpenAPIGenerator {
|
|
95
107
|
#private;
|
|
@@ -99,9 +111,9 @@ declare class OpenAPIGenerator {
|
|
|
99
111
|
/**
|
|
100
112
|
* Generates OpenAPI specifications from oRPC routers/contracts.
|
|
101
113
|
*
|
|
102
|
-
* @see {@link https://orpc.
|
|
114
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
103
115
|
*/
|
|
104
|
-
generate(router: AnyContractRouter | AnyRouter,
|
|
116
|
+
generate(router: AnyContractRouter | AnyRouter, { customErrorResponseBodySchema, commonSchemas, filter: baseFilter, exclude, ...baseDoc }?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
105
117
|
}
|
|
106
118
|
|
|
107
119
|
export { OpenAPIGenerator as b, CompositeSchemaConverter as e };
|