@byyuurin/nitro-openapi 0.0.2 → 0.0.3
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/index.cjs +159 -0
- package/dist/index.d.cts +105 -0
- package/dist/index.d.mts +17 -6
- package/dist/index.d.ts +17 -6
- package/dist/index.mjs +2 -0
- package/package.json +6 -5
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const defu = require('defu');
|
|
4
|
+
|
|
5
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
6
|
+
|
|
7
|
+
const defu__default = /*#__PURE__*/_interopDefaultCompat(defu);
|
|
8
|
+
|
|
9
|
+
function createOpenApiRegister(defaults) {
|
|
10
|
+
const { paths = {}, components = {}, security = [], servers = [], info, tags = [] } = defaults;
|
|
11
|
+
const defineOperation = (operation) => operation;
|
|
12
|
+
function register(route, routeOperation, method = "get") {
|
|
13
|
+
const _route = normalizeRoute(route);
|
|
14
|
+
paths[_route] = defu__default(
|
|
15
|
+
{ [method]: routeOperation },
|
|
16
|
+
paths[_route]
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
function merge(config) {
|
|
20
|
+
return mergeConfig(
|
|
21
|
+
config,
|
|
22
|
+
{
|
|
23
|
+
paths,
|
|
24
|
+
components,
|
|
25
|
+
security,
|
|
26
|
+
servers,
|
|
27
|
+
info,
|
|
28
|
+
tags
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
configExtends: {
|
|
34
|
+
paths,
|
|
35
|
+
components,
|
|
36
|
+
security,
|
|
37
|
+
servers,
|
|
38
|
+
info,
|
|
39
|
+
tags
|
|
40
|
+
},
|
|
41
|
+
defineOperation,
|
|
42
|
+
register,
|
|
43
|
+
merge
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function normalizeRoute(_route) {
|
|
47
|
+
let anonymousCtr = 0;
|
|
48
|
+
const route = _route.replace(/:(\w+)/g, (_, name) => `{${name}}`).replace(/\/(\*)\//g, () => `/{param${++anonymousCtr}}/`).replace(/\*\*{/, "{").replace(/\/(\*\*)$/g, () => `/{*param${++anonymousCtr}}`);
|
|
49
|
+
return route;
|
|
50
|
+
}
|
|
51
|
+
function mergeConfig(defaults, appends) {
|
|
52
|
+
const methods = /* @__PURE__ */ new Set(["delete", "get", "head", "options", "patch", "post", "put", "trace"]);
|
|
53
|
+
const { info } = appends;
|
|
54
|
+
const { paths = {} } = defaults;
|
|
55
|
+
for (const path in paths) {
|
|
56
|
+
const operations = paths[path];
|
|
57
|
+
if ("$ref" in operations)
|
|
58
|
+
continue;
|
|
59
|
+
paths[path] = Object.fromEntries(Object.entries(operations).map(([key, obj]) => {
|
|
60
|
+
if (methods.has(key))
|
|
61
|
+
return [key, normalizeSchema(obj)];
|
|
62
|
+
return [key, obj];
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
return defu__default({ info }, defaults, appends);
|
|
66
|
+
}
|
|
67
|
+
function normalizeSchema(obj) {
|
|
68
|
+
if ("$ref" in obj)
|
|
69
|
+
return obj;
|
|
70
|
+
const { parameters = [] } = obj;
|
|
71
|
+
obj.parameters = parameters.map((p) => {
|
|
72
|
+
if ("$ref" in p)
|
|
73
|
+
return p;
|
|
74
|
+
return defu__default(p, {
|
|
75
|
+
schema: { type: "string" }
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return obj;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function resolveSchemaObject(value, options = {}) {
|
|
82
|
+
const { allowExample = true, ...defaults } = options || {};
|
|
83
|
+
const resolveResult = (obj, example) => {
|
|
84
|
+
if (allowExample && example != null)
|
|
85
|
+
obj.example = example;
|
|
86
|
+
return { ...defaults, ...obj };
|
|
87
|
+
};
|
|
88
|
+
if (Array.isArray(value)) {
|
|
89
|
+
return resolveResult(
|
|
90
|
+
{
|
|
91
|
+
type: "array",
|
|
92
|
+
items: resolveSchemaObject(value[0], { allowExample: false })
|
|
93
|
+
},
|
|
94
|
+
value
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
const _type = typeof value;
|
|
98
|
+
switch (_type) {
|
|
99
|
+
case "function":
|
|
100
|
+
case "symbol":
|
|
101
|
+
case "undefined":
|
|
102
|
+
return { type: "null" };
|
|
103
|
+
case "object":
|
|
104
|
+
return resolveResult(
|
|
105
|
+
{
|
|
106
|
+
type: "object",
|
|
107
|
+
properties: Object.fromEntries(Object.entries(value).map(([k, v]) => [
|
|
108
|
+
k,
|
|
109
|
+
resolveSchemaObject(v, {
|
|
110
|
+
allowExample: false
|
|
111
|
+
})
|
|
112
|
+
]))
|
|
113
|
+
},
|
|
114
|
+
value
|
|
115
|
+
);
|
|
116
|
+
case "bigint":
|
|
117
|
+
return resolveResult(
|
|
118
|
+
{ type: "integer" },
|
|
119
|
+
value
|
|
120
|
+
);
|
|
121
|
+
case "string":
|
|
122
|
+
return resolveResult(
|
|
123
|
+
{ type: "string" },
|
|
124
|
+
value || null
|
|
125
|
+
);
|
|
126
|
+
default:
|
|
127
|
+
return resolveResult(
|
|
128
|
+
{ type: _type },
|
|
129
|
+
value
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function toExampleSchema(example, description, options) {
|
|
134
|
+
if (typeof example !== "object") {
|
|
135
|
+
return resolveSchemaObject(
|
|
136
|
+
example,
|
|
137
|
+
typeof description === "string" ? { ...options, description } : {}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
if (Array.isArray(example)) {
|
|
141
|
+
if (typeof description === "string")
|
|
142
|
+
return resolveSchemaObject(example, { ...options, description });
|
|
143
|
+
const schema2 = resolveSchemaObject(example, { allowExample: false });
|
|
144
|
+
schema2.items = toExampleSchema(example[0], description, options);
|
|
145
|
+
return schema2;
|
|
146
|
+
}
|
|
147
|
+
if (typeof description === "string")
|
|
148
|
+
return resolveSchemaObject(example, { ...options, description });
|
|
149
|
+
const schema = resolveSchemaObject(example, options);
|
|
150
|
+
schema.properties = Object.fromEntries(Object.entries(schema.properties).map(([p, item]) => [p, {
|
|
151
|
+
...item,
|
|
152
|
+
...typeof description === "object" ? { description: description?.[p] } : {}
|
|
153
|
+
}]));
|
|
154
|
+
return schema;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
exports.createOpenApiRegister = createOpenApiRegister;
|
|
158
|
+
exports.resolveSchemaObject = resolveSchemaObject;
|
|
159
|
+
exports.toExampleSchema = toExampleSchema;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import * as openapi_typescript from 'openapi-typescript';
|
|
2
|
+
import { SchemaObject, ReferenceObject, PathItemObject, ResponseObject, MediaTypeObject, OperationObject, ParameterObject, RequestBodyObject, SecurityRequirementObject, OpenAPI3 } from 'openapi-typescript';
|
|
3
|
+
|
|
4
|
+
type ReferenceRef<T extends OpenApiRegisterConfig> = T extends {
|
|
5
|
+
components: infer C;
|
|
6
|
+
} ? {
|
|
7
|
+
[K in keyof C]: C[K] extends object ? `#/components/${K & string}/${keyof C[K] & string}` : never;
|
|
8
|
+
}[keyof C] : string;
|
|
9
|
+
type SchemaExtended<T extends string> = SchemaObject | ({
|
|
10
|
+
type: 'array';
|
|
11
|
+
prefixItems?: MaybeReference<SchemaExtended<T>, T>[];
|
|
12
|
+
items?: MaybeReference<SchemaExtended<T>, T> | MaybeReference<SchemaExtended<T>, T>[];
|
|
13
|
+
enum?: MaybeReference<SchemaExtended<T>, T>[];
|
|
14
|
+
description?: string;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'object' | ['object', 'null'];
|
|
17
|
+
properties?: {
|
|
18
|
+
[name: string]: MaybeReference<SchemaExtended<T>, T>;
|
|
19
|
+
};
|
|
20
|
+
allOf?: MaybeReference<SchemaExtended<T>, T>[];
|
|
21
|
+
anyOf?: MaybeReference<SchemaExtended<T>, T>[];
|
|
22
|
+
enum?: MaybeReference<SchemaExtended<T>, T>[];
|
|
23
|
+
description?: string;
|
|
24
|
+
});
|
|
25
|
+
type ReferenceExtended<T extends string> = Omit<ReferenceObject, '$ref'> & {
|
|
26
|
+
$ref: T;
|
|
27
|
+
};
|
|
28
|
+
type MaybeReference<T, R extends string = string> = T | ReferenceExtended<R>;
|
|
29
|
+
type MaybeValueOrObject<ExampleT, ContentT> = ExampleT extends number | string | boolean ? ContentT : ExampleT extends (infer ArrayT)[] ? ContentT | MaybeValueOrObject<ArrayT, ContentT> : ExampleT extends Record<infer PropertyT, unknown> ? {
|
|
30
|
+
[key in PropertyT]?: ContentT;
|
|
31
|
+
} | ContentT : ContentT;
|
|
32
|
+
type PathOperations = Omit<PathItemObject, 'servers' | 'parameters' | `x-${string}`>;
|
|
33
|
+
type PathOperationMethod = keyof PathOperations;
|
|
34
|
+
type PathResponse<RefT extends string> = Omit<ResponseObject, 'content'> & {
|
|
35
|
+
content?: {
|
|
36
|
+
[contentType: string]: Omit<MediaTypeObject, 'schema'> & {
|
|
37
|
+
schema?: MaybeReference<SchemaExtended<RefT>, RefT>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type PathOperationItem<T extends OpenApiRegisterConfig> = Omit<OperationObject, 'tags' | 'parameters' | 'requestBody' | 'responses' | 'security'> & {
|
|
42
|
+
tags?: T extends {
|
|
43
|
+
tags: infer Tags;
|
|
44
|
+
} ? Tags extends ({
|
|
45
|
+
name: infer Tag;
|
|
46
|
+
})[] ? Tag[] | string[] : string[] : string[];
|
|
47
|
+
parameters?: MaybeReference<ParameterObject & {
|
|
48
|
+
schema?: SchemaExtended<ReferenceRef<T>>;
|
|
49
|
+
}, ReferenceRef<T>>[];
|
|
50
|
+
requestBody?: MaybeReference<RequestBodyObject & {
|
|
51
|
+
content: {
|
|
52
|
+
[contentType: string]: MaybeReference<MediaTypeObject, ReferenceRef<T>>;
|
|
53
|
+
};
|
|
54
|
+
}, ReferenceRef<T>>;
|
|
55
|
+
responses?: {
|
|
56
|
+
[responseCode: string]: MaybeReference<PathResponse<ReferenceRef<T>>, ReferenceRef<T>>;
|
|
57
|
+
} & {
|
|
58
|
+
default?: MaybeReference<PathResponse<ReferenceRef<T>>, ReferenceRef<T>>;
|
|
59
|
+
};
|
|
60
|
+
security?: T extends {
|
|
61
|
+
components: infer C;
|
|
62
|
+
} ? C extends {
|
|
63
|
+
securitySchemes: infer S;
|
|
64
|
+
} ? {
|
|
65
|
+
[SecurityName in keyof S]?: string[];
|
|
66
|
+
}[] : SecurityRequirementObject[] : SecurityRequirementObject[];
|
|
67
|
+
};
|
|
68
|
+
type OpenApiRegisterConfig = Pick<Partial<OpenAPI3>, 'paths' | 'components' | 'security' | 'servers' | 'info' | 'tags'>;
|
|
69
|
+
|
|
70
|
+
declare function createOpenApiRegister<T extends OpenApiRegisterConfig = OpenApiRegisterConfig>(defaults: T): {
|
|
71
|
+
configExtends: T;
|
|
72
|
+
defineOperation: (operation: PathOperationItem<T>) => PathOperationItem<T>;
|
|
73
|
+
register: (route: string, routeOperation: MaybeReference<PathOperationItem<T>, ReferenceRef<T>>, method?: keyof PathOperations) => void;
|
|
74
|
+
merge: (config: Partial<OpenAPI3>) => Partial<OpenAPI3>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type SchemaObjectOptions = SchemaObject & {
|
|
78
|
+
allowExample?: boolean;
|
|
79
|
+
};
|
|
80
|
+
declare function resolveSchemaObject(value: any, options?: SchemaObjectOptions): SchemaObject;
|
|
81
|
+
type ExampleDescription<ExampleT> = MaybeValueOrObject<ExampleT, string>;
|
|
82
|
+
declare function toExampleSchema<T = any>(example: T, description?: ExampleDescription<T>, options?: SchemaObject): {
|
|
83
|
+
[key: `x-${string}`]: any;
|
|
84
|
+
discriminator?: openapi_typescript.DiscriminatorObject | undefined;
|
|
85
|
+
xml?: openapi_typescript.XMLObject | undefined;
|
|
86
|
+
externalDocs?: openapi_typescript.ExternalDocumentationObject | undefined;
|
|
87
|
+
example?: any;
|
|
88
|
+
title?: string | undefined;
|
|
89
|
+
description?: string | undefined;
|
|
90
|
+
$comment?: string | undefined;
|
|
91
|
+
deprecated?: boolean | undefined;
|
|
92
|
+
readOnly?: boolean | undefined;
|
|
93
|
+
writeOnly?: boolean | undefined;
|
|
94
|
+
enum?: unknown[] | undefined;
|
|
95
|
+
const?: unknown;
|
|
96
|
+
default?: unknown;
|
|
97
|
+
format?: string | undefined;
|
|
98
|
+
nullable?: boolean | undefined;
|
|
99
|
+
oneOf?: (SchemaObject | openapi_typescript.ReferenceObject)[] | undefined;
|
|
100
|
+
allOf?: (SchemaObject | openapi_typescript.ReferenceObject)[] | undefined;
|
|
101
|
+
anyOf?: (SchemaObject | openapi_typescript.ReferenceObject)[] | undefined;
|
|
102
|
+
required?: string[] | undefined;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export { type MaybeReference, type MaybeValueOrObject, type OpenApiRegisterConfig, type PathOperationItem, type PathOperationMethod, type PathOperations, type PathResponse, type ReferenceExtended, type ReferenceRef, type SchemaExtended, createOpenApiRegister, resolveSchemaObject, toExampleSchema };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as openapi_typescript from 'openapi-typescript';
|
|
2
|
-
import { SchemaObject, ReferenceObject, PathItemObject, OperationObject, ParameterObject, RequestBodyObject,
|
|
2
|
+
import { SchemaObject, ReferenceObject, PathItemObject, ResponseObject, MediaTypeObject, OperationObject, ParameterObject, RequestBodyObject, SecurityRequirementObject, OpenAPI3 } from 'openapi-typescript';
|
|
3
3
|
|
|
4
4
|
type ReferenceRef<T extends OpenApiRegisterConfig> = T extends {
|
|
5
5
|
components: infer C;
|
|
@@ -31,7 +31,14 @@ type MaybeValueOrObject<ExampleT, ContentT> = ExampleT extends number | string |
|
|
|
31
31
|
} | ContentT : ContentT;
|
|
32
32
|
type PathOperations = Omit<PathItemObject, 'servers' | 'parameters' | `x-${string}`>;
|
|
33
33
|
type PathOperationMethod = keyof PathOperations;
|
|
34
|
-
type
|
|
34
|
+
type PathResponse<RefT extends string> = Omit<ResponseObject, 'content'> & {
|
|
35
|
+
content?: {
|
|
36
|
+
[contentType: string]: Omit<MediaTypeObject, 'schema'> & {
|
|
37
|
+
schema?: MaybeReference<SchemaExtended<RefT>, RefT>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type PathOperationItem<T extends OpenApiRegisterConfig> = Omit<OperationObject, 'tags' | 'parameters' | 'requestBody' | 'responses' | 'security'> & {
|
|
35
42
|
tags?: T extends {
|
|
36
43
|
tags: infer Tags;
|
|
37
44
|
} ? Tags extends ({
|
|
@@ -45,6 +52,11 @@ type PathOperationItem<T extends OpenApiRegisterConfig> = Omit<OperationObject,
|
|
|
45
52
|
[contentType: string]: MaybeReference<MediaTypeObject, ReferenceRef<T>>;
|
|
46
53
|
};
|
|
47
54
|
}, ReferenceRef<T>>;
|
|
55
|
+
responses?: {
|
|
56
|
+
[responseCode: string]: MaybeReference<PathResponse<ReferenceRef<T>>, ReferenceRef<T>>;
|
|
57
|
+
} & {
|
|
58
|
+
default?: MaybeReference<PathResponse<ReferenceRef<T>>, ReferenceRef<T>>;
|
|
59
|
+
};
|
|
48
60
|
security?: T extends {
|
|
49
61
|
components: infer C;
|
|
50
62
|
} ? C extends {
|
|
@@ -57,10 +69,9 @@ type OpenApiRegisterConfig = Pick<Partial<OpenAPI3>, 'paths' | 'components' | 's
|
|
|
57
69
|
|
|
58
70
|
declare function createOpenApiRegister<T extends OpenApiRegisterConfig = OpenApiRegisterConfig>(defaults: T): {
|
|
59
71
|
configExtends: T;
|
|
72
|
+
defineOperation: (operation: PathOperationItem<T>) => PathOperationItem<T>;
|
|
60
73
|
register: (route: string, routeOperation: MaybeReference<PathOperationItem<T>, ReferenceRef<T>>, method?: keyof PathOperations) => void;
|
|
61
|
-
merge: (config: Partial<OpenAPI3>) =>
|
|
62
|
-
info: openapi_typescript.InfoObject | undefined;
|
|
63
|
-
};
|
|
74
|
+
merge: (config: Partial<OpenAPI3>) => Partial<OpenAPI3>;
|
|
64
75
|
};
|
|
65
76
|
|
|
66
77
|
type SchemaObjectOptions = SchemaObject & {
|
|
@@ -91,4 +102,4 @@ declare function toExampleSchema<T = any>(example: T, description?: ExampleDescr
|
|
|
91
102
|
required?: string[] | undefined;
|
|
92
103
|
};
|
|
93
104
|
|
|
94
|
-
export { type MaybeReference, type MaybeValueOrObject, type OpenApiRegisterConfig, type PathOperationItem, type PathOperationMethod, type PathOperations, type ReferenceExtended, type ReferenceRef, type SchemaExtended, createOpenApiRegister, resolveSchemaObject, toExampleSchema };
|
|
105
|
+
export { type MaybeReference, type MaybeValueOrObject, type OpenApiRegisterConfig, type PathOperationItem, type PathOperationMethod, type PathOperations, type PathResponse, type ReferenceExtended, type ReferenceRef, type SchemaExtended, createOpenApiRegister, resolveSchemaObject, toExampleSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as openapi_typescript from 'openapi-typescript';
|
|
2
|
-
import { SchemaObject, ReferenceObject, PathItemObject, OperationObject, ParameterObject, RequestBodyObject,
|
|
2
|
+
import { SchemaObject, ReferenceObject, PathItemObject, ResponseObject, MediaTypeObject, OperationObject, ParameterObject, RequestBodyObject, SecurityRequirementObject, OpenAPI3 } from 'openapi-typescript';
|
|
3
3
|
|
|
4
4
|
type ReferenceRef<T extends OpenApiRegisterConfig> = T extends {
|
|
5
5
|
components: infer C;
|
|
@@ -31,7 +31,14 @@ type MaybeValueOrObject<ExampleT, ContentT> = ExampleT extends number | string |
|
|
|
31
31
|
} | ContentT : ContentT;
|
|
32
32
|
type PathOperations = Omit<PathItemObject, 'servers' | 'parameters' | `x-${string}`>;
|
|
33
33
|
type PathOperationMethod = keyof PathOperations;
|
|
34
|
-
type
|
|
34
|
+
type PathResponse<RefT extends string> = Omit<ResponseObject, 'content'> & {
|
|
35
|
+
content?: {
|
|
36
|
+
[contentType: string]: Omit<MediaTypeObject, 'schema'> & {
|
|
37
|
+
schema?: MaybeReference<SchemaExtended<RefT>, RefT>;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type PathOperationItem<T extends OpenApiRegisterConfig> = Omit<OperationObject, 'tags' | 'parameters' | 'requestBody' | 'responses' | 'security'> & {
|
|
35
42
|
tags?: T extends {
|
|
36
43
|
tags: infer Tags;
|
|
37
44
|
} ? Tags extends ({
|
|
@@ -45,6 +52,11 @@ type PathOperationItem<T extends OpenApiRegisterConfig> = Omit<OperationObject,
|
|
|
45
52
|
[contentType: string]: MaybeReference<MediaTypeObject, ReferenceRef<T>>;
|
|
46
53
|
};
|
|
47
54
|
}, ReferenceRef<T>>;
|
|
55
|
+
responses?: {
|
|
56
|
+
[responseCode: string]: MaybeReference<PathResponse<ReferenceRef<T>>, ReferenceRef<T>>;
|
|
57
|
+
} & {
|
|
58
|
+
default?: MaybeReference<PathResponse<ReferenceRef<T>>, ReferenceRef<T>>;
|
|
59
|
+
};
|
|
48
60
|
security?: T extends {
|
|
49
61
|
components: infer C;
|
|
50
62
|
} ? C extends {
|
|
@@ -57,10 +69,9 @@ type OpenApiRegisterConfig = Pick<Partial<OpenAPI3>, 'paths' | 'components' | 's
|
|
|
57
69
|
|
|
58
70
|
declare function createOpenApiRegister<T extends OpenApiRegisterConfig = OpenApiRegisterConfig>(defaults: T): {
|
|
59
71
|
configExtends: T;
|
|
72
|
+
defineOperation: (operation: PathOperationItem<T>) => PathOperationItem<T>;
|
|
60
73
|
register: (route: string, routeOperation: MaybeReference<PathOperationItem<T>, ReferenceRef<T>>, method?: keyof PathOperations) => void;
|
|
61
|
-
merge: (config: Partial<OpenAPI3>) =>
|
|
62
|
-
info: openapi_typescript.InfoObject | undefined;
|
|
63
|
-
};
|
|
74
|
+
merge: (config: Partial<OpenAPI3>) => Partial<OpenAPI3>;
|
|
64
75
|
};
|
|
65
76
|
|
|
66
77
|
type SchemaObjectOptions = SchemaObject & {
|
|
@@ -91,4 +102,4 @@ declare function toExampleSchema<T = any>(example: T, description?: ExampleDescr
|
|
|
91
102
|
required?: string[] | undefined;
|
|
92
103
|
};
|
|
93
104
|
|
|
94
|
-
export { type MaybeReference, type MaybeValueOrObject, type OpenApiRegisterConfig, type PathOperationItem, type PathOperationMethod, type PathOperations, type ReferenceExtended, type ReferenceRef, type SchemaExtended, createOpenApiRegister, resolveSchemaObject, toExampleSchema };
|
|
105
|
+
export { type MaybeReference, type MaybeValueOrObject, type OpenApiRegisterConfig, type PathOperationItem, type PathOperationMethod, type PathOperations, type PathResponse, type ReferenceExtended, type ReferenceRef, type SchemaExtended, createOpenApiRegister, resolveSchemaObject, toExampleSchema };
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import defu from 'defu';
|
|
|
2
2
|
|
|
3
3
|
function createOpenApiRegister(defaults) {
|
|
4
4
|
const { paths = {}, components = {}, security = [], servers = [], info, tags = [] } = defaults;
|
|
5
|
+
const defineOperation = (operation) => operation;
|
|
5
6
|
function register(route, routeOperation, method = "get") {
|
|
6
7
|
const _route = normalizeRoute(route);
|
|
7
8
|
paths[_route] = defu(
|
|
@@ -31,6 +32,7 @@ function createOpenApiRegister(defaults) {
|
|
|
31
32
|
info,
|
|
32
33
|
tags
|
|
33
34
|
},
|
|
35
|
+
defineOperation,
|
|
34
36
|
register,
|
|
35
37
|
merge
|
|
36
38
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@byyuurin/nitro-openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/byyuurin/nitro-openapi",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.mjs"
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.cjs"
|
|
16
17
|
}
|
|
17
18
|
},
|
|
18
19
|
"main": "./dist/index.mjs",
|
|
@@ -26,11 +27,11 @@
|
|
|
26
27
|
"openapi-typescript": "^6.7.4"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
|
-
"@byyuurin/eslint-config": "^1.0.
|
|
30
|
-
"bumpp": "^9.3.
|
|
30
|
+
"@byyuurin/eslint-config": "^1.0.2",
|
|
31
|
+
"bumpp": "^9.3.1",
|
|
31
32
|
"nitropack": "latest",
|
|
32
33
|
"unbuild": "^2.0.0",
|
|
33
|
-
"vitest": "^1.3.
|
|
34
|
+
"vitest": "^1.3.1"
|
|
34
35
|
},
|
|
35
36
|
"resolutions": {
|
|
36
37
|
"@byyuurin/nitro-openapi": "link:."
|