@orpc/openapi 0.0.0-next.e7ee5a9 → 0.0.0-next.e8524dc
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 +28 -20
- package/dist/adapters/aws-lambda/index.d.mts +17 -0
- package/dist/adapters/aws-lambda/index.d.ts +17 -0
- package/dist/adapters/aws-lambda/index.mjs +18 -0
- package/dist/adapters/fetch/index.d.mts +12 -9
- package/dist/adapters/fetch/index.d.ts +12 -9
- package/dist/adapters/fetch/index.mjs +14 -6
- package/dist/adapters/node/index.d.mts +12 -9
- package/dist/adapters/node/index.d.ts +12 -9
- package/dist/adapters/node/index.mjs +9 -20
- package/dist/adapters/standard/index.d.mts +22 -11
- package/dist/adapters/standard/index.d.ts +22 -11
- package/dist/adapters/standard/index.mjs +5 -3
- package/dist/index.d.mts +96 -155
- package/dist/index.d.ts +96 -155
- package/dist/index.mjs +34 -654
- package/dist/plugins/index.d.mts +69 -0
- package/dist/plugins/index.d.ts +69 -0
- package/dist/plugins/index.mjs +108 -0
- package/dist/shared/openapi.B3hexduL.d.mts +101 -0
- package/dist/shared/openapi.B3hexduL.d.ts +101 -0
- package/dist/shared/{openapi.CDsfPHgw.mjs → openapi.C_UtQ8Us.mjs} +61 -30
- package/dist/shared/openapi.D3j94c9n.d.mts +12 -0
- package/dist/shared/openapi.D3j94c9n.d.ts +12 -0
- package/dist/shared/openapi.DrrBsJ0w.mjs +738 -0
- package/package.json +19 -22
- package/dist/adapters/hono/index.d.mts +0 -7
- package/dist/adapters/hono/index.d.ts +0 -7
- package/dist/adapters/hono/index.mjs +0 -10
- package/dist/adapters/next/index.d.mts +0 -7
- package/dist/adapters/next/index.d.ts +0 -7
- package/dist/adapters/next/index.mjs +0 -10
- package/dist/shared/openapi.BHG_gu5Z.mjs +0 -8
- package/dist/shared/openapi.D0VMNR6V.mjs +0 -25
- package/dist/shared/openapi.Dz_6xooR.d.mts +0 -7
- package/dist/shared/openapi.Dz_6xooR.d.ts +0 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,169 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
export { JSONSchema };
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
|
|
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.B3hexduL.mjs';
|
|
4
|
+
import { HTTPPath, HTTPMethod } from '@orpc/client';
|
|
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
|
+
import { JsonifiedClient } from '@orpc/openapi-client';
|
|
8
|
+
import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
|
|
9
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
10
|
+
import '@orpc/openapi-client/standard';
|
|
10
11
|
|
|
11
|
-
type OverrideOperationValue = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
13
|
+
/**
|
|
14
|
+
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
|
|
17
|
+
*/
|
|
18
|
+
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
19
|
+
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
20
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
type ObjectSchema = JSONSchema & {
|
|
17
26
|
type: 'object';
|
|
18
27
|
} & object;
|
|
19
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
type FileSchema = JSONSchema & {
|
|
20
32
|
type: 'string';
|
|
21
33
|
contentMediaType: string;
|
|
22
34
|
} & object;
|
|
23
|
-
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
declare const LOGIC_KEYWORDS: string[];
|
|
24
39
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
declare function toOpenAPIPath(path: HTTPPath): string;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
|
|
68
|
+
declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
|
|
34
69
|
|
|
35
|
-
declare
|
|
36
|
-
private readonly schemaUtils;
|
|
37
|
-
constructor(schemaUtils: PublicSchemaUtils);
|
|
38
|
-
build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
|
|
39
|
-
}
|
|
40
|
-
type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
|
|
70
|
+
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>>;
|
|
41
71
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
declare
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
75
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
76
|
-
private parseDetailedSchema;
|
|
77
|
-
private parseCompactSchema;
|
|
78
|
-
}
|
|
79
|
-
type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
|
|
80
|
-
|
|
81
|
-
interface OpenAPIOutputStructureParseResult {
|
|
82
|
-
headersSchema: ObjectSchema | undefined;
|
|
83
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
84
|
-
}
|
|
85
|
-
declare class OpenAPIOutputStructureParser {
|
|
86
|
-
private readonly schemaConverter;
|
|
87
|
-
private readonly schemaUtils;
|
|
88
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
89
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
90
|
-
private parseDetailedSchema;
|
|
91
|
-
private parseCompactSchema;
|
|
92
|
-
}
|
|
93
|
-
type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
|
|
94
|
-
|
|
95
|
-
declare class OpenAPIParametersBuilder {
|
|
96
|
-
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
|
|
97
|
-
type: 'object';
|
|
98
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
|
|
99
|
-
buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
|
|
100
|
-
type: 'object';
|
|
101
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
|
|
102
|
-
}
|
|
103
|
-
type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
104
|
-
|
|
105
|
-
type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
|
|
106
|
-
interface OpenAPIGeneratorOptions {
|
|
107
|
-
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
108
|
-
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
109
|
-
schemaConverters?: SchemaConverter[];
|
|
110
|
-
schemaUtils?: PublicSchemaUtils;
|
|
111
|
-
jsonSerializer?: OpenAPIJsonSerializer;
|
|
112
|
-
pathParser?: PublicOpenAPIPathParser;
|
|
113
|
-
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
114
|
-
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
115
|
-
/**
|
|
116
|
-
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
117
|
-
*
|
|
118
|
-
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
119
|
-
* Because OpenAPI root tags is missing 'bar' tag
|
|
120
|
-
*
|
|
121
|
-
* @default false
|
|
122
|
-
*/
|
|
123
|
-
considerMissingTagDefinitionAsError?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Weather ignore procedures that has no path defined.
|
|
126
|
-
*
|
|
127
|
-
* @default false
|
|
128
|
-
*/
|
|
129
|
-
ignoreUndefinedPathProcedures?: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* What to do when we found an error with our router
|
|
132
|
-
*
|
|
133
|
-
* @default 'throw'
|
|
134
|
-
*/
|
|
135
|
-
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
136
|
-
/**
|
|
137
|
-
* Strict error response
|
|
138
|
-
*
|
|
139
|
-
* @default true
|
|
140
|
-
*/
|
|
141
|
-
strictErrorResponses?: boolean;
|
|
142
|
-
}
|
|
143
|
-
declare class OpenAPIGenerator {
|
|
144
|
-
private readonly contentBuilder;
|
|
145
|
-
private readonly parametersBuilder;
|
|
146
|
-
private readonly schemaConverter;
|
|
147
|
-
private readonly schemaUtils;
|
|
148
|
-
private readonly jsonSerializer;
|
|
149
|
-
private readonly pathParser;
|
|
150
|
-
private readonly inputStructureParser;
|
|
151
|
-
private readonly outputStructureParser;
|
|
152
|
-
private readonly errorHandlerStrategy;
|
|
153
|
-
private readonly ignoreUndefinedPathProcedures;
|
|
154
|
-
private readonly considerMissingTagDefinitionAsError;
|
|
155
|
-
private readonly strictErrorResponses;
|
|
156
|
-
constructor(options?: OpenAPIGeneratorOptions);
|
|
157
|
-
generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
161
|
-
declare function toOpenAPI31RoutePattern(path: HTTPPath): string;
|
|
162
|
-
|
|
163
|
-
/** unnoq */
|
|
72
|
+
/**
|
|
73
|
+
*@internal
|
|
74
|
+
*/
|
|
75
|
+
declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
declare function isAnySchema(schema: JSONSchema): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
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[];
|
|
99
|
+
declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
|
|
100
|
+
type: 'array';
|
|
101
|
+
items?: JSONSchema;
|
|
102
|
+
}];
|
|
103
|
+
declare function isPrimitiveSchema(schema: JSONSchema): boolean;
|
|
164
104
|
|
|
165
105
|
declare const oo: {
|
|
166
|
-
spec: typeof
|
|
106
|
+
spec: typeof customOpenAPIOperation;
|
|
167
107
|
};
|
|
168
108
|
|
|
169
|
-
export {
|
|
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 };
|
|
110
|
+
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,169 +1,110 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
export { JSONSchema };
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { OpenAPI, AnyContractProcedure } from '@orpc/contract';
|
|
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.B3hexduL.js';
|
|
4
|
+
import { HTTPPath, HTTPMethod } from '@orpc/client';
|
|
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
|
+
import { JsonifiedClient } from '@orpc/openapi-client';
|
|
8
|
+
import { AnyRouter, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@orpc/server';
|
|
9
|
+
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
10
|
+
import '@orpc/openapi-client/standard';
|
|
10
11
|
|
|
11
|
-
type OverrideOperationValue = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
|
|
13
|
+
/**
|
|
14
|
+
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
|
|
17
|
+
*/
|
|
18
|
+
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
19
|
+
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
20
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: AnyContractProcedure): OpenAPI.OperationObject;
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
type ObjectSchema = JSONSchema & {
|
|
17
26
|
type: 'object';
|
|
18
27
|
} & object;
|
|
19
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
type FileSchema = JSONSchema & {
|
|
20
32
|
type: 'string';
|
|
21
33
|
contentMediaType: string;
|
|
22
34
|
} & object;
|
|
23
|
-
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
declare const LOGIC_KEYWORDS: string[];
|
|
24
39
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @internal
|
|
42
|
+
*/
|
|
43
|
+
declare function toOpenAPIPath(path: HTTPPath): string;
|
|
44
|
+
/**
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
48
|
+
/**
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
|
|
52
|
+
/**
|
|
53
|
+
* @internal
|
|
54
|
+
*/
|
|
55
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
*/
|
|
59
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
|
|
60
|
+
/**
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
|
|
68
|
+
declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
|
|
34
69
|
|
|
35
|
-
declare
|
|
36
|
-
private readonly schemaUtils;
|
|
37
|
-
constructor(schemaUtils: PublicSchemaUtils);
|
|
38
|
-
build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
|
|
39
|
-
}
|
|
40
|
-
type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
|
|
70
|
+
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>>;
|
|
41
71
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
declare
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
75
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
76
|
-
private parseDetailedSchema;
|
|
77
|
-
private parseCompactSchema;
|
|
78
|
-
}
|
|
79
|
-
type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
|
|
80
|
-
|
|
81
|
-
interface OpenAPIOutputStructureParseResult {
|
|
82
|
-
headersSchema: ObjectSchema | undefined;
|
|
83
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
|
84
|
-
}
|
|
85
|
-
declare class OpenAPIOutputStructureParser {
|
|
86
|
-
private readonly schemaConverter;
|
|
87
|
-
private readonly schemaUtils;
|
|
88
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
89
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
90
|
-
private parseDetailedSchema;
|
|
91
|
-
private parseCompactSchema;
|
|
92
|
-
}
|
|
93
|
-
type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
|
|
94
|
-
|
|
95
|
-
declare class OpenAPIParametersBuilder {
|
|
96
|
-
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
|
|
97
|
-
type: 'object';
|
|
98
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
|
|
99
|
-
buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
|
|
100
|
-
type: 'object';
|
|
101
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
|
|
102
|
-
}
|
|
103
|
-
type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
104
|
-
|
|
105
|
-
type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
|
|
106
|
-
interface OpenAPIGeneratorOptions {
|
|
107
|
-
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
108
|
-
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
109
|
-
schemaConverters?: SchemaConverter[];
|
|
110
|
-
schemaUtils?: PublicSchemaUtils;
|
|
111
|
-
jsonSerializer?: OpenAPIJsonSerializer;
|
|
112
|
-
pathParser?: PublicOpenAPIPathParser;
|
|
113
|
-
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
114
|
-
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
115
|
-
/**
|
|
116
|
-
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
117
|
-
*
|
|
118
|
-
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
119
|
-
* Because OpenAPI root tags is missing 'bar' tag
|
|
120
|
-
*
|
|
121
|
-
* @default false
|
|
122
|
-
*/
|
|
123
|
-
considerMissingTagDefinitionAsError?: boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Weather ignore procedures that has no path defined.
|
|
126
|
-
*
|
|
127
|
-
* @default false
|
|
128
|
-
*/
|
|
129
|
-
ignoreUndefinedPathProcedures?: boolean;
|
|
130
|
-
/**
|
|
131
|
-
* What to do when we found an error with our router
|
|
132
|
-
*
|
|
133
|
-
* @default 'throw'
|
|
134
|
-
*/
|
|
135
|
-
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
136
|
-
/**
|
|
137
|
-
* Strict error response
|
|
138
|
-
*
|
|
139
|
-
* @default true
|
|
140
|
-
*/
|
|
141
|
-
strictErrorResponses?: boolean;
|
|
142
|
-
}
|
|
143
|
-
declare class OpenAPIGenerator {
|
|
144
|
-
private readonly contentBuilder;
|
|
145
|
-
private readonly parametersBuilder;
|
|
146
|
-
private readonly schemaConverter;
|
|
147
|
-
private readonly schemaUtils;
|
|
148
|
-
private readonly jsonSerializer;
|
|
149
|
-
private readonly pathParser;
|
|
150
|
-
private readonly inputStructureParser;
|
|
151
|
-
private readonly outputStructureParser;
|
|
152
|
-
private readonly errorHandlerStrategy;
|
|
153
|
-
private readonly ignoreUndefinedPathProcedures;
|
|
154
|
-
private readonly considerMissingTagDefinitionAsError;
|
|
155
|
-
private readonly strictErrorResponses;
|
|
156
|
-
constructor(options?: OpenAPIGeneratorOptions);
|
|
157
|
-
generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
161
|
-
declare function toOpenAPI31RoutePattern(path: HTTPPath): string;
|
|
162
|
-
|
|
163
|
-
/** unnoq */
|
|
72
|
+
/**
|
|
73
|
+
*@internal
|
|
74
|
+
*/
|
|
75
|
+
declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
80
|
+
/**
|
|
81
|
+
* @internal
|
|
82
|
+
*/
|
|
83
|
+
declare function isAnySchema(schema: JSONSchema): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
91
|
+
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
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[];
|
|
99
|
+
declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
|
|
100
|
+
type: 'array';
|
|
101
|
+
items?: JSONSchema;
|
|
102
|
+
}];
|
|
103
|
+
declare function isPrimitiveSchema(schema: JSONSchema): boolean;
|
|
164
104
|
|
|
165
105
|
declare const oo: {
|
|
166
|
-
spec: typeof
|
|
106
|
+
spec: typeof customOpenAPIOperation;
|
|
167
107
|
};
|
|
168
108
|
|
|
169
|
-
export {
|
|
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 };
|
|
110
|
+
export type { FileSchema, ObjectSchema, OverrideOperationValue };
|