@orpc/openapi 0.46.0 → 1.0.0-beta.1
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 +3 -2
- package/dist/adapters/fetch/index.d.ts +3 -2
- package/dist/adapters/fetch/index.mjs +5 -4
- package/dist/adapters/hono/index.d.mts +2 -1
- package/dist/adapters/hono/index.d.ts +2 -1
- package/dist/adapters/hono/index.mjs +5 -4
- package/dist/adapters/next/index.d.mts +2 -1
- package/dist/adapters/next/index.d.ts +2 -1
- package/dist/adapters/next/index.mjs +5 -4
- package/dist/adapters/node/index.d.mts +3 -2
- package/dist/adapters/node/index.d.ts +3 -2
- package/dist/adapters/node/index.mjs +12 -8
- package/dist/adapters/standard/index.d.mts +18 -7
- package/dist/adapters/standard/index.d.ts +18 -7
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +91 -140
- package/dist/index.d.ts +91 -140
- package/dist/index.mjs +225 -583
- package/dist/shared/{openapi.CDsfPHgw.mjs → openapi.BNHmrMe2.mjs} +21 -24
- package/dist/shared/openapi.DZzpQAb-.mjs +231 -0
- package/dist/shared/openapi.Dv-KT_Bx.mjs +33 -0
- package/dist/shared/openapi.IfmmOyba.d.mts +8 -0
- package/dist/shared/openapi.IfmmOyba.d.ts +8 -0
- package/package.json +11 -11
- package/dist/shared/openapi.BHG_gu5Z.mjs +0 -8
- package/dist/shared/openapi.BcJH4F9P.mjs +0 -27
- package/dist/shared/openapi.Dz_6xooR.d.mts +0 -7
- package/dist/shared/openapi.Dz_6xooR.d.ts +0 -7
package/dist/index.d.ts
CHANGED
@@ -1,169 +1,120 @@
|
|
1
|
-
import { AnyContractProcedure,
|
2
|
-
import
|
3
|
-
export { OpenAPI };
|
4
|
-
|
5
|
-
import * as JSONSchema from 'json-schema-typed/draft-2020-12';
|
6
|
-
export { JSONSchema };
|
7
|
-
export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
8
|
-
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';
|
4
|
+
import { StandardOpenAPIJsonSerializerOptions } from '@orpc/openapi-client/standard';
|
9
5
|
import { AnyRouter } from '@orpc/server';
|
6
|
+
import { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
7
|
+
export { JSONSchema, Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
|
10
8
|
|
11
|
-
type OverrideOperationValue =
|
12
|
-
declare function
|
13
|
-
declare function
|
14
|
-
declare function
|
9
|
+
type OverrideOperationValue = Partial<OpenAPIV3_1.OperationObject> | ((current: OpenAPIV3_1.OperationObject, procedure: AnyContractProcedure) => OpenAPIV3_1.OperationObject);
|
10
|
+
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
11
|
+
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
12
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPIV3_1.OperationObject, contract: AnyContractProcedure): OpenAPIV3_1.OperationObject;
|
15
13
|
|
16
|
-
|
14
|
+
/**
|
15
|
+
* @internal
|
16
|
+
*/
|
17
|
+
type ObjectSchema = JSONSchema & {
|
17
18
|
type: 'object';
|
18
19
|
} & object;
|
19
|
-
|
20
|
+
/**
|
21
|
+
* @internal
|
22
|
+
*/
|
23
|
+
type FileSchema = JSONSchema & {
|
20
24
|
type: 'string';
|
21
25
|
contentMediaType: string;
|
22
26
|
} & object;
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
isObjectSchema(schema: JSONSchema.JSONSchema): schema is ObjectSchema;
|
28
|
-
isAnySchema(schema: JSONSchema.JSONSchema): boolean;
|
29
|
-
isUndefinableSchema(schema: JSONSchema.JSONSchema): boolean;
|
30
|
-
separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
31
|
-
filterSchemaBranches(schema: JSONSchema.JSONSchema, check: (schema: JSONSchema.JSONSchema) => boolean, matches?: JSONSchema.JSONSchema[]): [matches: JSONSchema.JSONSchema[], rest: JSONSchema.JSONSchema | undefined];
|
32
|
-
}
|
33
|
-
type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
|
34
|
-
|
35
|
-
declare class OpenAPIContentBuilder {
|
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>;
|
41
|
-
|
42
|
-
declare class OpenAPIPathParser {
|
43
|
-
parseDynamicParams(path: string): {
|
44
|
-
name: string;
|
45
|
-
raw: string;
|
46
|
-
}[];
|
47
|
-
}
|
48
|
-
type PublicOpenAPIPathParser = Pick<OpenAPIPathParser, keyof OpenAPIPathParser>;
|
27
|
+
/**
|
28
|
+
* @internal
|
29
|
+
*/
|
30
|
+
declare const LOGIC_KEYWORDS: string[];
|
49
31
|
|
50
32
|
interface SchemaConvertOptions {
|
51
33
|
strategy: 'input' | 'output';
|
52
34
|
}
|
53
35
|
interface SchemaConverter {
|
54
|
-
|
55
|
-
|
36
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
|
37
|
+
}
|
38
|
+
interface ConditionalSchemaConverter extends SchemaConverter {
|
39
|
+
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): boolean;
|
56
40
|
}
|
57
41
|
declare class CompositeSchemaConverter implements SchemaConverter {
|
58
42
|
private readonly converters;
|
59
|
-
constructor(converters:
|
60
|
-
|
61
|
-
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
62
|
-
}
|
63
|
-
|
64
|
-
interface OpenAPIInputStructureParseResult {
|
65
|
-
paramsSchema: ObjectSchema | undefined;
|
66
|
-
querySchema: ObjectSchema | undefined;
|
67
|
-
headersSchema: ObjectSchema | undefined;
|
68
|
-
bodySchema: JSONSchema.JSONSchema | undefined;
|
69
|
-
}
|
70
|
-
declare class OpenAPIInputStructureParser {
|
71
|
-
private readonly schemaConverter;
|
72
|
-
private readonly schemaUtils;
|
73
|
-
private readonly pathParser;
|
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;
|
43
|
+
constructor(converters: ConditionalSchemaConverter[]);
|
44
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: JSONSchema];
|
102
45
|
}
|
103
|
-
type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
|
104
46
|
|
105
|
-
|
106
|
-
|
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;
|
47
|
+
interface OpenAPIGeneratorOptions extends StandardOpenAPIJsonSerializerOptions {
|
48
|
+
schemaConverters?: ConditionalSchemaConverter[];
|
142
49
|
}
|
143
50
|
declare class OpenAPIGenerator {
|
144
|
-
private
|
145
|
-
private readonly
|
146
|
-
private readonly
|
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;
|
51
|
+
#private;
|
52
|
+
private readonly serializer;
|
53
|
+
private readonly converter;
|
156
54
|
constructor(options?: OpenAPIGeneratorOptions);
|
157
|
-
generate(router:
|
55
|
+
generate(router: AnyContractRouter | AnyRouter, base: Omit<OpenAPIV3_1.Document, 'openapi'>): Promise<OpenAPIV3_1.Document>;
|
158
56
|
}
|
159
57
|
|
58
|
+
/**
|
59
|
+
* @internal
|
60
|
+
*/
|
160
61
|
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
161
|
-
|
62
|
+
/**
|
63
|
+
* @internal
|
64
|
+
*/
|
65
|
+
declare function toOpenAPIPath(path: HTTPPath): string;
|
66
|
+
/**
|
67
|
+
* @internal
|
68
|
+
*/
|
69
|
+
declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
|
70
|
+
/**
|
71
|
+
* @internal
|
72
|
+
*/
|
73
|
+
declare function getDynamicParams(path: HTTPPath | undefined): string[] | undefined;
|
74
|
+
/**
|
75
|
+
* @internal
|
76
|
+
*/
|
77
|
+
declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
78
|
+
/**
|
79
|
+
* @internal
|
80
|
+
*/
|
81
|
+
declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPIV3_1.MediaTypeObject>;
|
82
|
+
/**
|
83
|
+
* @internal
|
84
|
+
*/
|
85
|
+
declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPIV3_1.ParameterObject[];
|
86
|
+
/**
|
87
|
+
* @internal
|
88
|
+
*/
|
89
|
+
declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
|
90
|
+
/**
|
91
|
+
* @internal
|
92
|
+
*/
|
93
|
+
declare function toOpenAPISchema(schema: JSONSchema): OpenAPIV3_1.SchemaObject & object;
|
162
94
|
|
163
|
-
/**
|
95
|
+
/**
|
96
|
+
*@internal
|
97
|
+
*/
|
98
|
+
declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
|
99
|
+
/**
|
100
|
+
* @internal
|
101
|
+
*/
|
102
|
+
declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
|
103
|
+
/**
|
104
|
+
* @internal
|
105
|
+
*/
|
106
|
+
declare function isAnySchema(schema: JSONSchema): boolean;
|
107
|
+
/**
|
108
|
+
* @internal
|
109
|
+
*/
|
110
|
+
declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
|
111
|
+
/**
|
112
|
+
* @internal
|
113
|
+
*/
|
114
|
+
declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
|
164
115
|
|
165
116
|
declare const oo: {
|
166
|
-
spec: typeof
|
117
|
+
spec: typeof customOpenAPIOperation;
|
167
118
|
};
|
168
119
|
|
169
|
-
export { CompositeSchemaConverter, type FileSchema,
|
120
|
+
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 };
|