@orpc/openapi 0.0.0-next.3cc45a9 → 0.0.0-next.3d9f498
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/fetch/index.mjs +2 -1
- package/dist/adapters/node/index.mjs +2 -1
- package/dist/adapters/standard/index.d.mts +1 -0
- package/dist/adapters/standard/index.d.ts +1 -0
- package/dist/adapters/standard/index.mjs +2 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.mjs +2 -2
- package/dist/plugins/index.d.mts +6 -6
- package/dist/plugins/index.d.ts +6 -6
- package/dist/plugins/index.mjs +1 -1
- package/dist/shared/{openapi.p5tsmBXx.mjs → openapi.C_UtQ8Us.mjs} +27 -6
- package/dist/shared/{openapi.DqPCYbM9.mjs → openapi.PDTdnRIU.mjs} +73 -26
- package/package.json +8 -8
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FetchHandler } from '@orpc/server/fetch';
|
|
2
|
+
import '@orpc/client';
|
|
2
3
|
import '@orpc/contract';
|
|
3
4
|
import '@orpc/shared';
|
|
4
|
-
import { a as StandardOpenAPIHandler } from '../../shared/openapi.
|
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.C_UtQ8Us.mjs';
|
|
5
6
|
import '@orpc/client/standard';
|
|
6
7
|
import '@orpc/server';
|
|
7
8
|
import 'rou3';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { NodeHttpHandler } from '@orpc/server/node';
|
|
2
|
+
import '@orpc/client';
|
|
2
3
|
import '@orpc/contract';
|
|
3
4
|
import '@orpc/shared';
|
|
4
|
-
import { a as StandardOpenAPIHandler } from '../../shared/openapi.
|
|
5
|
+
import { a as StandardOpenAPIHandler } from '../../shared/openapi.C_UtQ8Us.mjs';
|
|
5
6
|
import '@orpc/client/standard';
|
|
6
7
|
import '@orpc/server';
|
|
7
8
|
import 'rou3';
|
|
@@ -6,6 +6,7 @@ import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
|
6
6
|
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.mjs';
|
|
7
7
|
|
|
8
8
|
declare class StandardOpenAPICodec implements StandardCodec {
|
|
9
|
+
#private;
|
|
9
10
|
private readonly serializer;
|
|
10
11
|
constructor(serializer: StandardOpenAPISerializer);
|
|
11
12
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
@@ -6,6 +6,7 @@ import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
|
|
6
6
|
export { a as StandardOpenAPIHandler, S as StandardOpenAPIHandlerOptions } from '../../shared/openapi.D3j94c9n.js';
|
|
7
7
|
|
|
8
8
|
declare class StandardOpenAPICodec implements StandardCodec {
|
|
9
|
+
#private;
|
|
9
10
|
private readonly serializer;
|
|
10
11
|
constructor(serializer: StandardOpenAPISerializer);
|
|
11
12
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
@@ -1,6 +1,7 @@
|
|
|
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.C_UtQ8Us.mjs';
|
|
2
2
|
import '@orpc/openapi-client/standard';
|
|
3
3
|
import '@orpc/server/standard';
|
|
4
|
+
import '@orpc/client';
|
|
4
5
|
import '@orpc/contract';
|
|
5
6
|
import '@orpc/shared';
|
|
6
7
|
import '@orpc/client/standard';
|
package/dist/index.d.mts
CHANGED
|
@@ -90,10 +90,16 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
|
|
|
90
90
|
*/
|
|
91
91
|
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
92
92
|
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
93
|
+
/**
|
|
94
|
+
* Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
|
|
95
|
+
* recursively expands it into an array of its constituent, non-union base schemas.
|
|
96
|
+
* If the schema is not a simple union or is a base type, it's returned as a single-element array.
|
|
97
|
+
*/
|
|
98
|
+
declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
|
|
93
99
|
|
|
94
100
|
declare const oo: {
|
|
95
101
|
spec: typeof customOpenAPIOperation;
|
|
96
102
|
};
|
|
97
103
|
|
|
98
|
-
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
104
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
99
105
|
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -90,10 +90,16 @@ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties:
|
|
|
90
90
|
*/
|
|
91
91
|
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
92
92
|
declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
|
|
93
|
+
/**
|
|
94
|
+
* Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
|
|
95
|
+
* recursively expands it into an array of its constituent, non-union base schemas.
|
|
96
|
+
* If the schema is not a simple union or is a base type, it's returned as a single-element array.
|
|
97
|
+
*/
|
|
98
|
+
declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
|
|
93
99
|
|
|
94
100
|
declare const oo: {
|
|
95
101
|
spec: typeof customOpenAPIOperation;
|
|
96
102
|
};
|
|
97
103
|
|
|
98
|
-
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
104
|
+
export { LOGIC_KEYWORDS, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, createJsonifiedRouterClient, customOpenAPIOperation, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|
|
99
105
|
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|
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, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, 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.PDTdnRIU.mjs';
|
|
2
|
+
export { C as CompositeSchemaConverter, L as LOGIC_KEYWORDS, O as OpenAPIGenerator, a as applyCustomOpenAPIOperation, n as applySchemaOptionality, h as checkParamsSchema, o as expandUnionSchema, m as filterSchemaBranches, g as getCustomOpenAPIOperation, l as isAnySchema, j as isFileSchema, k as isObjectSchema, s as separateObjectSchema, d as toOpenAPIContent, e as toOpenAPIEventIteratorContent, b as toOpenAPIMethod, f as toOpenAPIParameters, t as toOpenAPIPath, i as toOpenAPISchema } from './shared/openapi.PDTdnRIU.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, HTTPPath, Router } from '@orpc/server';
|
|
2
2
|
import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
|
3
|
-
import { Value } from '@orpc/shared';
|
|
3
|
+
import { Value, Promisable } from '@orpc/shared';
|
|
4
4
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
5
5
|
import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.CwdCLgSU.mjs';
|
|
6
6
|
import '@orpc/contract';
|
|
@@ -12,7 +12,7 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
|
|
|
12
12
|
* Options to pass to the OpenAPI generate.
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
|
-
specGenerateOptions?: Value<OpenAPIGeneratorGenerateOptions
|
|
15
|
+
specGenerateOptions?: Value<Promisable<OpenAPIGeneratorGenerateOptions>, [StandardHandlerInterceptorOptions<T>]>;
|
|
16
16
|
/**
|
|
17
17
|
* The URL path at which to serve the OpenAPI JSON.
|
|
18
18
|
*
|
|
@@ -30,23 +30,23 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
|
|
|
30
30
|
*
|
|
31
31
|
* @default 'API Reference'
|
|
32
32
|
*/
|
|
33
|
-
docsTitle?: Value<string
|
|
33
|
+
docsTitle?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
|
34
34
|
/**
|
|
35
35
|
* Arbitrary configuration object for the UI.
|
|
36
36
|
*/
|
|
37
|
-
docsConfig?: Value<Record<string, unknown
|
|
37
|
+
docsConfig?: Value<Promisable<Record<string, unknown>>, [StandardHandlerInterceptorOptions<T>]>;
|
|
38
38
|
/**
|
|
39
39
|
* HTML to inject into the <head> of the docs page.
|
|
40
40
|
*
|
|
41
41
|
* @default ''
|
|
42
42
|
*/
|
|
43
|
-
docsHead?: Value<string
|
|
43
|
+
docsHead?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
|
44
44
|
/**
|
|
45
45
|
* URL of the external script bundle for the reference UI.
|
|
46
46
|
*
|
|
47
47
|
* @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'
|
|
48
48
|
*/
|
|
49
|
-
docsScriptUrl?: Value<string
|
|
49
|
+
docsScriptUrl?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
|
50
50
|
/**
|
|
51
51
|
* Override function to generate the full HTML for the docs page.
|
|
52
52
|
*/
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, HTTPPath, Router } from '@orpc/server';
|
|
2
2
|
import { StandardHandlerInterceptorOptions, StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
|
3
|
-
import { Value } from '@orpc/shared';
|
|
3
|
+
import { Value, Promisable } from '@orpc/shared';
|
|
4
4
|
import { OpenAPIV3_1 } from 'openapi-types';
|
|
5
5
|
import { O as OpenAPIGeneratorOptions, a as OpenAPIGeneratorGenerateOptions } from '../shared/openapi.CwdCLgSU.js';
|
|
6
6
|
import '@orpc/contract';
|
|
@@ -12,7 +12,7 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
|
|
|
12
12
|
* Options to pass to the OpenAPI generate.
|
|
13
13
|
*
|
|
14
14
|
*/
|
|
15
|
-
specGenerateOptions?: Value<OpenAPIGeneratorGenerateOptions
|
|
15
|
+
specGenerateOptions?: Value<Promisable<OpenAPIGeneratorGenerateOptions>, [StandardHandlerInterceptorOptions<T>]>;
|
|
16
16
|
/**
|
|
17
17
|
* The URL path at which to serve the OpenAPI JSON.
|
|
18
18
|
*
|
|
@@ -30,23 +30,23 @@ interface OpenAPIReferencePluginOptions<T extends Context> extends OpenAPIGenera
|
|
|
30
30
|
*
|
|
31
31
|
* @default 'API Reference'
|
|
32
32
|
*/
|
|
33
|
-
docsTitle?: Value<string
|
|
33
|
+
docsTitle?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
|
34
34
|
/**
|
|
35
35
|
* Arbitrary configuration object for the UI.
|
|
36
36
|
*/
|
|
37
|
-
docsConfig?: Value<Record<string, unknown
|
|
37
|
+
docsConfig?: Value<Promisable<Record<string, unknown>>, [StandardHandlerInterceptorOptions<T>]>;
|
|
38
38
|
/**
|
|
39
39
|
* HTML to inject into the <head> of the docs page.
|
|
40
40
|
*
|
|
41
41
|
* @default ''
|
|
42
42
|
*/
|
|
43
|
-
docsHead?: Value<string
|
|
43
|
+
docsHead?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
|
44
44
|
/**
|
|
45
45
|
* URL of the external script bundle for the reference UI.
|
|
46
46
|
*
|
|
47
47
|
* @default 'https://cdn.jsdelivr.net/npm/@scalar/api-reference'
|
|
48
48
|
*/
|
|
49
|
-
docsScriptUrl?: Value<string
|
|
49
|
+
docsScriptUrl?: Value<Promisable<string>, [StandardHandlerInterceptorOptions<T>]>;
|
|
50
50
|
/**
|
|
51
51
|
* Override function to generate the full HTML for the docs page.
|
|
52
52
|
*/
|
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.PDTdnRIU.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/client/standard';
|
|
5
5
|
import '@orpc/contract';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { standardizeHTTPPath, StandardOpenAPIJsonSerializer, StandardBracketNotationSerializer, StandardOpenAPISerializer } from '@orpc/openapi-client/standard';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
+
import { isORPCErrorStatus } from '@orpc/client';
|
|
3
4
|
import { fallbackContractConfig } from '@orpc/contract';
|
|
4
|
-
import { isObject } from '@orpc/shared';
|
|
5
|
+
import { isObject, stringifyJSON } from '@orpc/shared';
|
|
5
6
|
import { toHttpPath } from '@orpc/client/standard';
|
|
6
7
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@orpc/server';
|
|
7
8
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
@@ -52,13 +53,21 @@ class StandardOpenAPICodec {
|
|
|
52
53
|
body: this.serializer.serialize(output)
|
|
53
54
|
};
|
|
54
55
|
}
|
|
55
|
-
if (!
|
|
56
|
-
throw new Error(
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
if (!this.#isDetailedOutput(output)) {
|
|
57
|
+
throw new Error(`
|
|
58
|
+
Invalid "detailed" output structure:
|
|
59
|
+
\u2022 Expected an object with optional properties:
|
|
60
|
+
- status (number 200-399)
|
|
61
|
+
- headers (Record<string, string | string[]>)
|
|
62
|
+
- body (any)
|
|
63
|
+
\u2022 No extra keys allowed.
|
|
64
|
+
|
|
65
|
+
Actual value:
|
|
66
|
+
${stringifyJSON(output)}
|
|
67
|
+
`);
|
|
59
68
|
}
|
|
60
69
|
return {
|
|
61
|
-
status: successStatus,
|
|
70
|
+
status: output.status ?? successStatus,
|
|
62
71
|
headers: output.headers ?? {},
|
|
63
72
|
body: this.serializer.serialize(output.body)
|
|
64
73
|
};
|
|
@@ -70,6 +79,18 @@ class StandardOpenAPICodec {
|
|
|
70
79
|
body: this.serializer.serialize(error.toJSON(), { outputFormat: "plain" })
|
|
71
80
|
};
|
|
72
81
|
}
|
|
82
|
+
#isDetailedOutput(output) {
|
|
83
|
+
if (!isObject(output)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (output.headers && !isObject(output.headers)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
73
94
|
}
|
|
74
95
|
|
|
75
96
|
function toRou3Pattern(path) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { fallbackORPCErrorStatus, fallbackORPCErrorMessage } from '@orpc/client';
|
|
1
|
+
import { isORPCErrorStatus, fallbackORPCErrorStatus, fallbackORPCErrorMessage } from '@orpc/client';
|
|
2
2
|
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, findDeepMatches, toArray, clone } from '@orpc/shared';
|
|
6
|
+
import { isObject, findDeepMatches, toArray, clone, stringifyJSON } from '@orpc/shared';
|
|
7
7
|
import 'json-schema-typed/draft-2020-12';
|
|
8
8
|
|
|
9
9
|
const OPERATION_EXTENDER_SYMBOL = Symbol("ORPC_OPERATION_EXTENDER");
|
|
@@ -184,6 +184,18 @@ function applySchemaOptionality(required, schema) {
|
|
|
184
184
|
]
|
|
185
185
|
};
|
|
186
186
|
}
|
|
187
|
+
function expandUnionSchema(schema) {
|
|
188
|
+
if (typeof schema === "object") {
|
|
189
|
+
for (const keyword of ["anyOf", "oneOf"]) {
|
|
190
|
+
if (schema[keyword] && Object.keys(schema).every(
|
|
191
|
+
(k) => k === keyword || !LOGIC_KEYWORDS.includes(k)
|
|
192
|
+
)) {
|
|
193
|
+
return schema[keyword].flatMap((s) => expandUnionSchema(s));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return [schema];
|
|
198
|
+
}
|
|
187
199
|
|
|
188
200
|
function toOpenAPIPath(path) {
|
|
189
201
|
return standardizeHTTPPath(path).replace(/\/\{\+([^}]+)\}/g, "/{$1}");
|
|
@@ -463,36 +475,71 @@ ${errors.join("\n\n")}`
|
|
|
463
475
|
return;
|
|
464
476
|
}
|
|
465
477
|
const [required, json] = await this.converter.convert(outputSchema, { strategy: "output" });
|
|
466
|
-
ref.responses ??= {};
|
|
467
|
-
ref.responses[status] = {
|
|
468
|
-
description
|
|
469
|
-
};
|
|
470
478
|
if (outputStructure === "compact") {
|
|
479
|
+
ref.responses ??= {};
|
|
480
|
+
ref.responses[status] = {
|
|
481
|
+
description
|
|
482
|
+
};
|
|
471
483
|
ref.responses[status].content = toOpenAPIContent(applySchemaOptionality(required, json));
|
|
472
484
|
return;
|
|
473
485
|
}
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
486
|
+
const handledStatuses = /* @__PURE__ */ new Set();
|
|
487
|
+
for (const item of expandUnionSchema(json)) {
|
|
488
|
+
const error = new OpenAPIGeneratorError(`
|
|
489
|
+
When output structure is "detailed", output schema must satisfy:
|
|
490
|
+
{
|
|
491
|
+
status?: number, // must be a literal number and in the range of 200-399
|
|
492
|
+
headers?: Record<string, unknown>,
|
|
493
|
+
body?: unknown
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
But got: ${stringifyJSON(item)}
|
|
497
|
+
`);
|
|
498
|
+
if (!isObjectSchema(item)) {
|
|
482
499
|
throw error;
|
|
483
500
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
}
|
|
501
|
+
let schemaStatus;
|
|
502
|
+
let schemaDescription;
|
|
503
|
+
if (item.properties?.status !== void 0) {
|
|
504
|
+
if (typeof item.properties.status !== "object" || item.properties.status.const === void 0 || typeof item.properties.status.const !== "number" || !Number.isInteger(item.properties.status.const) || isORPCErrorStatus(item.properties.status.const)) {
|
|
505
|
+
throw error;
|
|
506
|
+
}
|
|
507
|
+
schemaStatus = item.properties.status.const;
|
|
508
|
+
schemaDescription = item.properties.status.description;
|
|
509
|
+
}
|
|
510
|
+
const itemStatus = schemaStatus ?? status;
|
|
511
|
+
const itemDescription = schemaDescription ?? description;
|
|
512
|
+
if (handledStatuses.has(itemStatus)) {
|
|
513
|
+
throw new OpenAPIGeneratorError(`
|
|
514
|
+
When output structure is "detailed", each success status must be unique.
|
|
515
|
+
But got status: ${itemStatus} used more than once.
|
|
516
|
+
`);
|
|
517
|
+
}
|
|
518
|
+
handledStatuses.add(itemStatus);
|
|
519
|
+
ref.responses ??= {};
|
|
520
|
+
ref.responses[itemStatus] = {
|
|
521
|
+
description: itemDescription
|
|
522
|
+
};
|
|
523
|
+
if (item.properties?.headers !== void 0) {
|
|
524
|
+
if (!isObjectSchema(item.properties.headers)) {
|
|
525
|
+
throw error;
|
|
526
|
+
}
|
|
527
|
+
for (const key in item.properties.headers.properties) {
|
|
528
|
+
const headerSchema = item.properties.headers.properties[key];
|
|
529
|
+
if (headerSchema !== void 0) {
|
|
530
|
+
ref.responses[itemStatus].headers ??= {};
|
|
531
|
+
ref.responses[itemStatus].headers[key] = {
|
|
532
|
+
schema: toOpenAPISchema(headerSchema),
|
|
533
|
+
required: item.properties.headers.required?.includes(key)
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (item.properties?.body !== void 0) {
|
|
539
|
+
ref.responses[itemStatus].content = toOpenAPIContent(
|
|
540
|
+
applySchemaOptionality(item.required?.includes("body") ?? false, item.properties.body)
|
|
541
|
+
);
|
|
490
542
|
}
|
|
491
|
-
}
|
|
492
|
-
if (json.properties?.body !== void 0) {
|
|
493
|
-
ref.responses[status].content = toOpenAPIContent(
|
|
494
|
-
applySchemaOptionality(json.required?.includes("body") ?? false, json.properties.body)
|
|
495
|
-
);
|
|
496
543
|
}
|
|
497
544
|
}
|
|
498
545
|
async #errorResponse(ref, def) {
|
|
@@ -545,4 +592,4 @@ ${errors.join("\n\n")}`
|
|
|
545
592
|
}
|
|
546
593
|
}
|
|
547
594
|
|
|
548
|
-
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, separateObjectSchema as s, toOpenAPIPath as t };
|
|
595
|
+
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, separateObjectSchema as s, toOpenAPIPath as t };
|
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.3d9f498",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
"json-schema-typed": "^8.0.1",
|
|
48
48
|
"openapi-types": "^12.1.3",
|
|
49
49
|
"rou3": "^0.6.0",
|
|
50
|
-
"@orpc/client": "0.0.0-next.
|
|
51
|
-
"@orpc/
|
|
52
|
-
"@orpc/
|
|
53
|
-
"@orpc/
|
|
54
|
-
"@orpc/
|
|
55
|
-
"@orpc/
|
|
50
|
+
"@orpc/client": "0.0.0-next.3d9f498",
|
|
51
|
+
"@orpc/contract": "0.0.0-next.3d9f498",
|
|
52
|
+
"@orpc/openapi-client": "0.0.0-next.3d9f498",
|
|
53
|
+
"@orpc/shared": "0.0.0-next.3d9f498",
|
|
54
|
+
"@orpc/standard-server": "0.0.0-next.3d9f498",
|
|
55
|
+
"@orpc/server": "0.0.0-next.3d9f498"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"zod": "^3.
|
|
58
|
+
"zod": "^3.25.11"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "unbuild",
|