@orpc/openapi 0.0.0-next.1431467 → 0.0.0-next.15d9202
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 +3 -1
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +4 -3
- package/dist/adapters/hono/index.mjs +4 -3
- package/dist/adapters/next/index.mjs +4 -3
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +4 -3
- package/dist/adapters/standard/index.d.mts +13 -2
- package/dist/adapters/standard/index.d.ts +13 -2
- package/dist/adapters/standard/index.mjs +3 -2
- package/dist/index.d.mts +85 -133
- package/dist/index.d.ts +85 -133
- package/dist/index.mjs +226 -579
- package/dist/shared/{openapi.C_biOx82.mjs → openapi.CJTe38Ya.mjs} +18 -20
- package/dist/shared/{openapi.B6uueFtN.mjs → openapi.CbzTVvGL.mjs} +3 -1
- package/dist/shared/openapi.DZzpQAb-.mjs +231 -0
- package/package.json +10 -10
- package/dist/shared/openapi.BHG_gu5Z.mjs +0 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,167 +1,119 @@
|
|
|
1
|
-
import { AnyContractProcedure,
|
|
2
|
-
import
|
|
3
|
-
export { OpenAPI };
|
|
4
|
-
export { OpenApiBuilder } from 'openapi3-ts/oas31';
|
|
5
|
-
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
|
-
export { JSONSchema, Format as JSONSchemaFormat, keywords as JSONSchemaKeywords } from 'json-schema-typed/draft-2020-12';
|
|
7
|
-
import { OpenAPIJsonSerializer } from '@orpc/openapi-client/standard';
|
|
1
|
+
import { AnyContractProcedure, AnySchema, AnyContractRouter, HTTPPath, HTTPMethod } from '@orpc/contract';
|
|
2
|
+
import { OpenAPIV3_1 } from 'openapi-types';
|
|
3
|
+
export { OpenAPIV3_1 as OpenAPI } from 'openapi-types';
|
|
8
4
|
import { AnyRouter } from '@orpc/server';
|
|
5
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
6
|
+
export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
|
9
7
|
|
|
10
|
-
type OverrideOperationValue =
|
|
11
|
-
declare function
|
|
12
|
-
declare function
|
|
13
|
-
declare function
|
|
8
|
+
type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.OperationObject);
|
|
9
|
+
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
10
|
+
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
11
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
|
|
14
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
15
16
|
type ObjectSchema = JSONSchema & {
|
|
16
17
|
type: 'object';
|
|
17
18
|
} & object;
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
*/
|
|
18
22
|
type FileSchema = JSONSchema & {
|
|
19
23
|
type: 'string';
|
|
20
24
|
contentMediaType: string;
|
|
21
25
|
} & object;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
27
|
-
isAnySchema(schema: JSONSchema): boolean;
|
|
28
|
-
isUndefinableSchema(schema: JSONSchema): boolean;
|
|
29
|
-
separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
30
|
-
filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
31
|
-
}
|
|
32
|
-
type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
declare const LOGIC_KEYWORDS: string[];
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
constructor(schemaUtils: PublicSchemaUtils);
|
|
37
|
-
build(jsonSchema: JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
|
|
31
|
+
interface SchemaConvertOptions {
|
|
32
|
+
strategy: 'input' | 'output';
|
|
38
33
|
}
|
|
39
|
-
type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
|
|
40
|
-
|
|
41
|
-
declare class OpenAPIPathParser {
|
|
42
|
-
parseDynamicParams(path: string): {
|
|
43
|
-
name: string;
|
|
44
|
-
raw: string;
|
|
45
|
-
}[];
|
|
46
|
-
}
|
|
47
|
-
type PublicOpenAPIPathParser = Pick<OpenAPIPathParser, keyof OpenAPIPathParser>;
|
|
48
|
-
|
|
49
|
-
type SchemaConvertStrategy = 'input' | 'output';
|
|
50
34
|
interface SchemaConverter {
|
|
51
|
-
convert(schema:
|
|
35
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
|
|
52
36
|
}
|
|
53
37
|
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
54
|
-
condition(schema:
|
|
38
|
+
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): boolean;
|
|
55
39
|
}
|
|
56
40
|
declare class CompositeSchemaConverter implements SchemaConverter {
|
|
57
41
|
private readonly converters;
|
|
58
42
|
constructor(converters: ConditionalSchemaConverter[]);
|
|
59
|
-
convert(schema:
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
interface OpenAPIInputStructureParseResult {
|
|
63
|
-
paramsSchema: ObjectSchema | undefined;
|
|
64
|
-
querySchema: ObjectSchema | undefined;
|
|
65
|
-
headersSchema: ObjectSchema | undefined;
|
|
66
|
-
bodySchema: JSONSchema | undefined;
|
|
67
|
-
}
|
|
68
|
-
declare class OpenAPIInputStructureParser {
|
|
69
|
-
private readonly schemaConverter;
|
|
70
|
-
private readonly schemaUtils;
|
|
71
|
-
private readonly pathParser;
|
|
72
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
|
|
73
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
|
|
74
|
-
private parseDetailedSchema;
|
|
75
|
-
private parseCompactSchema;
|
|
76
|
-
}
|
|
77
|
-
type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
|
|
78
|
-
|
|
79
|
-
interface OpenAPIOutputStructureParseResult {
|
|
80
|
-
headersSchema: ObjectSchema | undefined;
|
|
81
|
-
bodySchema: JSONSchema | undefined;
|
|
82
|
-
}
|
|
83
|
-
declare class OpenAPIOutputStructureParser {
|
|
84
|
-
private readonly schemaConverter;
|
|
85
|
-
private readonly schemaUtils;
|
|
86
|
-
constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
|
|
87
|
-
parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
|
|
88
|
-
private parseDetailedSchema;
|
|
89
|
-
private parseCompactSchema;
|
|
90
|
-
}
|
|
91
|
-
type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
|
|
92
|
-
|
|
93
|
-
declare class OpenAPIParametersBuilder {
|
|
94
|
-
build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema & {
|
|
95
|
-
type: 'object';
|
|
96
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
|
|
97
|
-
buildHeadersObject(jsonSchema: JSONSchema & {
|
|
98
|
-
type: 'object';
|
|
99
|
-
} & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
|
|
43
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
|
|
100
44
|
}
|
|
101
|
-
type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
|
102
45
|
|
|
103
|
-
type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
|
|
104
46
|
interface OpenAPIGeneratorOptions {
|
|
105
|
-
contentBuilder?: PublicOpenAPIContentBuilder;
|
|
106
|
-
parametersBuilder?: PublicOpenAPIParametersBuilder;
|
|
107
47
|
schemaConverters?: ConditionalSchemaConverter[];
|
|
108
|
-
schemaUtils?: PublicSchemaUtils;
|
|
109
|
-
jsonSerializer?: OpenAPIJsonSerializer;
|
|
110
|
-
pathParser?: PublicOpenAPIPathParser;
|
|
111
|
-
inputStructureParser?: PublicOpenAPIInputStructureParser;
|
|
112
|
-
outputStructureParser?: PublicOpenAPIOutputStructureParser;
|
|
113
|
-
/**
|
|
114
|
-
* Throw error when you missing define tag definition on OpenAPI root tags
|
|
115
|
-
*
|
|
116
|
-
* Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
|
|
117
|
-
* Because OpenAPI root tags is missing 'bar' tag
|
|
118
|
-
*
|
|
119
|
-
* @default false
|
|
120
|
-
*/
|
|
121
|
-
considerMissingTagDefinitionAsError?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Weather ignore procedures that has no path defined.
|
|
124
|
-
*
|
|
125
|
-
* @default false
|
|
126
|
-
*/
|
|
127
|
-
ignoreUndefinedPathProcedures?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* What to do when we found an error with our router
|
|
130
|
-
*
|
|
131
|
-
* @default 'throw'
|
|
132
|
-
*/
|
|
133
|
-
errorHandlerStrategy?: ErrorHandlerStrategy;
|
|
134
|
-
/**
|
|
135
|
-
* Strict error response
|
|
136
|
-
*
|
|
137
|
-
* @default true
|
|
138
|
-
*/
|
|
139
|
-
strictErrorResponses?: boolean;
|
|
140
48
|
}
|
|
141
49
|
declare class OpenAPIGenerator {
|
|
142
|
-
private
|
|
143
|
-
private readonly
|
|
144
|
-
private readonly
|
|
145
|
-
private readonly schemaUtils;
|
|
146
|
-
private readonly jsonSerializer;
|
|
147
|
-
private readonly pathParser;
|
|
148
|
-
private readonly inputStructureParser;
|
|
149
|
-
private readonly outputStructureParser;
|
|
150
|
-
private readonly errorHandlerStrategy;
|
|
151
|
-
private readonly ignoreUndefinedPathProcedures;
|
|
152
|
-
private readonly considerMissingTagDefinitionAsError;
|
|
153
|
-
private readonly strictErrorResponses;
|
|
50
|
+
#private;
|
|
51
|
+
private readonly serializer;
|
|
52
|
+
private readonly converter;
|
|
154
53
|
constructor(options?: OpenAPIGeneratorOptions);
|
|
155
|
-
generate(router:
|
|
54
|
+
generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
|
|
156
55
|
}
|
|
157
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
158
60
|
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
159
|
-
|
|
61
|
+
/**
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
declare function toOpenAPIPath(path: HTTPPath): string;
|
|
65
|
+
/**
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
|
69
|
+
/**
|
|
70
|
+
* @internal
|
|
71
|
+
*/
|
|
72
|
+
declare function getDynamicParams(path: HTTPPath | undefined): string[] | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* @internal
|
|
75
|
+
*/
|
|
76
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
|
77
|
+
/**
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
|
|
85
|
+
/**
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* @internal
|
|
91
|
+
*/
|
|
92
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
|
|
160
93
|
|
|
161
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
*@internal
|
|
96
|
+
*/
|
|
97
|
+
declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
|
|
98
|
+
/**
|
|
99
|
+
* @internal
|
|
100
|
+
*/
|
|
101
|
+
declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
105
|
+
declare function isAnySchema(schema: JSONSchema): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
|
110
|
+
/**
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
|
162
114
|
|
|
163
115
|
declare const oo: {
|
|
164
|
-
spec: typeof
|
|
116
|
+
spec: typeof customOpenAPIOperation;
|
|
165
117
|
};
|
|
166
118
|
|
|
167
|
-
export { CompositeSchemaConverter, type ConditionalSchemaConverter, type FileSchema,
|
|
119
|
+
export { CompositeSchemaConverter, type ConditionalSchemaConverter, type FileSchema, LOGIC_KEYWORDS, type ObjectSchema, OpenAPIGenerator, type OpenAPIGeneratorOptions, type OverrideOperationValue, type SchemaConvertOptions, type SchemaConverter, applyCustomOpenAPIOperation, checkParamsSchema, customOpenAPIOperation, filterSchemaBranches, getCustomOpenAPIOperation, getDynamicParams, isAnySchema, isFileSchema, isObjectSchema, oo, separateObjectSchema, standardizeHTTPPath, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
|