@kubb/plugin-oas 2.19.6 → 2.20.0
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/{OperationGenerator-BL3W1CH2.d.ts → OperationGenerator-8DNneYd8.d.ts} +4 -1
- package/dist/{OperationGenerator-B6_KXF47.d.cts → OperationGenerator-BHo9OWOG.d.cts} +4 -1
- package/dist/{chunk-AHPYTLES.js → chunk-5PS7VSVP.js} +2 -2
- package/dist/{chunk-VHGCZBHU.js → chunk-7KC6HDZA.js} +3 -3
- package/dist/{chunk-VHGCZBHU.js.map → chunk-7KC6HDZA.js.map} +1 -1
- package/dist/{chunk-XE6N3VWS.cjs → chunk-C4DNEBEV.cjs} +23 -23
- package/dist/{chunk-IJDG7KT6.cjs → chunk-ERS2ZSAT.cjs} +21 -21
- package/dist/{chunk-LXHYPSLT.cjs → chunk-GWI26OTO.cjs} +3 -3
- package/dist/{chunk-LXHYPSLT.cjs.map → chunk-GWI26OTO.cjs.map} +1 -1
- package/dist/{chunk-MZJFTD2Z.cjs → chunk-I5OXSD6K.cjs} +3 -3
- package/dist/{chunk-V7H5ZWZY.js → chunk-N6CQRWVS.js} +2 -2
- package/dist/{chunk-RLUQTHVB.js → chunk-YPTFMYOL.js} +3 -3
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +3 -3
- package/dist/hooks.cjs +31 -18
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +9 -3
- package/dist/hooks.d.ts +9 -3
- package/dist/hooks.js +21 -8
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +27 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +8 -8
- package/dist/utils.js +2 -2
- package/package.json +10 -10
- package/src/OperationGenerator.ts +10 -7
- package/src/hooks/useOperationManager.ts +27 -7
- /package/dist/{chunk-AHPYTLES.js.map → chunk-5PS7VSVP.js.map} +0 -0
- /package/dist/{chunk-XE6N3VWS.cjs.map → chunk-C4DNEBEV.cjs.map} +0 -0
- /package/dist/{chunk-IJDG7KT6.cjs.map → chunk-ERS2ZSAT.cjs.map} +0 -0
- /package/dist/{chunk-MZJFTD2Z.cjs.map → chunk-I5OXSD6K.cjs.map} +0 -0
- /package/dist/{chunk-V7H5ZWZY.js.map → chunk-N6CQRWVS.js.map} +0 -0
- /package/dist/{chunk-RLUQTHVB.js.map → chunk-YPTFMYOL.js.map} +0 -0
package/dist/hooks.cjs
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
require('./chunk-
|
|
5
|
+
var _chunkC4DNEBEVcjs = require('./chunk-C4DNEBEV.cjs');
|
|
6
|
+
require('./chunk-ERS2ZSAT.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkGWI26OTOcjs = require('./chunk-GWI26OTO.cjs');
|
|
10
10
|
|
|
11
11
|
// src/hooks/index.ts
|
|
12
|
-
|
|
12
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
13
13
|
|
|
14
14
|
// src/hooks/useOas.ts
|
|
15
|
-
|
|
15
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
16
16
|
var _react = require('@kubb/react');
|
|
17
17
|
function useOas() {
|
|
18
|
-
const { oas } = _react.useContext.call(void 0,
|
|
18
|
+
const { oas } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Oas.Context);
|
|
19
19
|
if (!oas) {
|
|
20
20
|
throw new Error("Oas is not defined");
|
|
21
21
|
}
|
|
@@ -23,10 +23,10 @@ function useOas() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
// src/hooks/useOperation.ts
|
|
26
|
-
|
|
26
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
27
27
|
|
|
28
28
|
function useOperation() {
|
|
29
|
-
const { operation } = _react.useContext.call(void 0,
|
|
29
|
+
const { operation } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Operation.Context);
|
|
30
30
|
if (!operation) {
|
|
31
31
|
throw new Error("Operation is not defined");
|
|
32
32
|
}
|
|
@@ -34,11 +34,11 @@ function useOperation() {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// src/hooks/useOperationManager.ts
|
|
37
|
-
|
|
37
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
38
38
|
|
|
39
39
|
function useOperationManager() {
|
|
40
40
|
const { plugin, pluginManager } = _react.useApp.call(void 0, );
|
|
41
|
-
const { generator } = _react.useContext.call(void 0,
|
|
41
|
+
const { generator } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Oas.Context);
|
|
42
42
|
if (!generator) {
|
|
43
43
|
throw new Error(`'generator' is not defined`);
|
|
44
44
|
}
|
|
@@ -68,7 +68,7 @@ function useOperationManager() {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
-
const
|
|
71
|
+
const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
|
|
72
72
|
const schemas = generator.getSchemas(operation);
|
|
73
73
|
const errors = (schemas.errors || []).reduce(
|
|
74
74
|
(prev, acc) => {
|
|
@@ -77,7 +77,7 @@ function useOperationManager() {
|
|
|
77
77
|
}
|
|
78
78
|
prev[acc.statusCode] = pluginManager.resolveName({
|
|
79
79
|
name: acc.name,
|
|
80
|
-
pluginKey
|
|
80
|
+
pluginKey,
|
|
81
81
|
type
|
|
82
82
|
});
|
|
83
83
|
return prev;
|
|
@@ -113,23 +113,36 @@ function useOperationManager() {
|
|
|
113
113
|
pluginKey,
|
|
114
114
|
type
|
|
115
115
|
}),
|
|
116
|
+
["default"]: pluginManager.resolveName({
|
|
117
|
+
name: schemas.response.name,
|
|
118
|
+
pluginKey,
|
|
119
|
+
type
|
|
120
|
+
}),
|
|
116
121
|
...errors
|
|
117
|
-
}
|
|
122
|
+
},
|
|
123
|
+
errors
|
|
118
124
|
};
|
|
119
125
|
};
|
|
120
126
|
return {
|
|
121
127
|
getName,
|
|
122
128
|
getFile,
|
|
123
|
-
getSchemas: (operation, forStatusCode) => generator.getSchemas(operation,
|
|
124
|
-
|
|
129
|
+
getSchemas: (operation, params, forStatusCode) => generator.getSchemas(operation, {
|
|
130
|
+
forStatusCode,
|
|
131
|
+
resolveName: (name) => pluginManager.resolveName({
|
|
132
|
+
name,
|
|
133
|
+
pluginKey: _optionalChain([params, 'optionalAccess', _14 => _14.pluginKey]),
|
|
134
|
+
type: _optionalChain([params, 'optionalAccess', _15 => _15.type])
|
|
135
|
+
})
|
|
136
|
+
}),
|
|
137
|
+
groupSchemasByName
|
|
125
138
|
};
|
|
126
139
|
}
|
|
127
140
|
|
|
128
141
|
// src/hooks/useOperations.ts
|
|
129
|
-
|
|
142
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
130
143
|
|
|
131
144
|
function useOperations({ method, path } = {}) {
|
|
132
|
-
const { operations } = _react.useContext.call(void 0,
|
|
145
|
+
const { operations } = _react.useContext.call(void 0, _chunkC4DNEBEVcjs.Oas.Context);
|
|
133
146
|
if (!operations) {
|
|
134
147
|
throw new Error("Operations is not defined");
|
|
135
148
|
}
|
|
@@ -148,5 +161,5 @@ function useOperations({ method, path } = {}) {
|
|
|
148
161
|
|
|
149
162
|
|
|
150
163
|
|
|
151
|
-
exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema =
|
|
164
|
+
exports.useOas = useOas; exports.useOperation = useOperation; exports.useOperationManager = useOperationManager; exports.useOperations = useOperations; exports.useSchema = _chunkC4DNEBEVcjs.useSchema;
|
|
152
165
|
//# sourceMappingURL=hooks.cjs.map
|
package/dist/hooks.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"names":["useContext"],"mappings":";;;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,kBAAkB;AAMpB,SAAS,SAAkB;AAChC,QAAM,EAAE,IAAI,IAAI,WAAW,IAAI,OAAO;AAEtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAEA,SAAO;AACT;;;ACdA;AAAA,SAAS,cAAAA,mBAAkB;AASpB,SAAS,eAA8B;AAC5C,QAAM,EAAE,UAAU,IAAIA,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;AAAA,SAAS,QAAQ,cAAAA,mBAAkB;
|
|
1
|
+
{"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"names":["useContext"],"mappings":";;;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,kBAAkB;AAMpB,SAAS,SAAkB;AAChC,QAAM,EAAE,IAAI,IAAI,WAAW,IAAI,OAAO;AAEtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAEA,SAAO;AACT;;;ACdA;AAAA,SAAS,cAAAA,mBAAkB;AASpB,SAAS,eAA8B;AAC5C,QAAM,EAAE,UAAU,IAAIA,YAAW,UAAU,OAAO;AAElD,MAAI,CAAC,WAAW;AACd,UAAM,IAAI,MAAM,0BAA0B;AAAA,EAC5C;AAEA,SAAO;AACT;;;ACjBA;AAAA,SAAS,QAAQ,cAAAA,mBAAkB;AAwC5B,SAAS,sBAAiD;AAC/D,QAAM,EAAE,QAAQ,cAAc,IAAI,OAAO;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ACf,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,MAAI,QAAQ;AAEZ,MAAI,MAAM;AACR,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;AAAA,EACnD;AAEA,MAAI,QAAQ;AACV,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACvD;AAEA,SAAO;AACT","sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n"]}
|
package/dist/hooks.d.cts
CHANGED
|
@@ -27,7 +27,10 @@ type SchemaNames = {
|
|
|
27
27
|
query: string | undefined;
|
|
28
28
|
header: string | undefined;
|
|
29
29
|
};
|
|
30
|
-
responses:
|
|
30
|
+
responses: {
|
|
31
|
+
default?: string;
|
|
32
|
+
} & Record<number | string, string>;
|
|
33
|
+
errors: Record<number | string, string>;
|
|
31
34
|
};
|
|
32
35
|
type UseOperationManagerResult = {
|
|
33
36
|
getName: (operation: Operation, params: {
|
|
@@ -38,11 +41,14 @@ type UseOperationManagerResult = {
|
|
|
38
41
|
pluginKey?: Plugin['key'];
|
|
39
42
|
extName?: KubbFile.Extname;
|
|
40
43
|
}) => KubbFile.File<FileMeta>;
|
|
41
|
-
|
|
44
|
+
groupSchemasByName: (operation: Operation, params: {
|
|
42
45
|
pluginKey?: Plugin['key'];
|
|
43
46
|
type: ResolveNameParams['type'];
|
|
44
47
|
}) => SchemaNames;
|
|
45
|
-
getSchemas: (operation: Operation,
|
|
48
|
+
getSchemas: (operation: Operation, params?: {
|
|
49
|
+
pluginKey?: Plugin['key'];
|
|
50
|
+
type?: ResolveNameParams['type'];
|
|
51
|
+
}, forStatusCode?: string | number) => OperationSchemas;
|
|
46
52
|
};
|
|
47
53
|
/**
|
|
48
54
|
* `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
|
package/dist/hooks.d.ts
CHANGED
|
@@ -27,7 +27,10 @@ type SchemaNames = {
|
|
|
27
27
|
query: string | undefined;
|
|
28
28
|
header: string | undefined;
|
|
29
29
|
};
|
|
30
|
-
responses:
|
|
30
|
+
responses: {
|
|
31
|
+
default?: string;
|
|
32
|
+
} & Record<number | string, string>;
|
|
33
|
+
errors: Record<number | string, string>;
|
|
31
34
|
};
|
|
32
35
|
type UseOperationManagerResult = {
|
|
33
36
|
getName: (operation: Operation, params: {
|
|
@@ -38,11 +41,14 @@ type UseOperationManagerResult = {
|
|
|
38
41
|
pluginKey?: Plugin['key'];
|
|
39
42
|
extName?: KubbFile.Extname;
|
|
40
43
|
}) => KubbFile.File<FileMeta>;
|
|
41
|
-
|
|
44
|
+
groupSchemasByName: (operation: Operation, params: {
|
|
42
45
|
pluginKey?: Plugin['key'];
|
|
43
46
|
type: ResolveNameParams['type'];
|
|
44
47
|
}) => SchemaNames;
|
|
45
|
-
getSchemas: (operation: Operation,
|
|
48
|
+
getSchemas: (operation: Operation, params?: {
|
|
49
|
+
pluginKey?: Plugin['key'];
|
|
50
|
+
type?: ResolveNameParams['type'];
|
|
51
|
+
}, forStatusCode?: string | number) => OperationSchemas;
|
|
46
52
|
};
|
|
47
53
|
/**
|
|
48
54
|
* `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.
|
package/dist/hooks.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
Oas,
|
|
3
3
|
Operation,
|
|
4
4
|
useSchema
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-YPTFMYOL.js";
|
|
6
|
+
import "./chunk-5PS7VSVP.js";
|
|
7
7
|
import {
|
|
8
8
|
init_esm_shims
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7KC6HDZA.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/index.ts
|
|
12
12
|
init_esm_shims();
|
|
@@ -68,7 +68,7 @@ function useOperationManager() {
|
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
70
|
};
|
|
71
|
-
const
|
|
71
|
+
const groupSchemasByName = (operation, { pluginKey = plugin.key, type }) => {
|
|
72
72
|
const schemas = generator.getSchemas(operation);
|
|
73
73
|
const errors = (schemas.errors || []).reduce(
|
|
74
74
|
(prev, acc) => {
|
|
@@ -77,7 +77,7 @@ function useOperationManager() {
|
|
|
77
77
|
}
|
|
78
78
|
prev[acc.statusCode] = pluginManager.resolveName({
|
|
79
79
|
name: acc.name,
|
|
80
|
-
pluginKey
|
|
80
|
+
pluginKey,
|
|
81
81
|
type
|
|
82
82
|
});
|
|
83
83
|
return prev;
|
|
@@ -113,15 +113,28 @@ function useOperationManager() {
|
|
|
113
113
|
pluginKey,
|
|
114
114
|
type
|
|
115
115
|
}),
|
|
116
|
+
["default"]: pluginManager.resolveName({
|
|
117
|
+
name: schemas.response.name,
|
|
118
|
+
pluginKey,
|
|
119
|
+
type
|
|
120
|
+
}),
|
|
116
121
|
...errors
|
|
117
|
-
}
|
|
122
|
+
},
|
|
123
|
+
errors
|
|
118
124
|
};
|
|
119
125
|
};
|
|
120
126
|
return {
|
|
121
127
|
getName,
|
|
122
128
|
getFile,
|
|
123
|
-
getSchemas: (operation, forStatusCode) => generator.getSchemas(operation,
|
|
124
|
-
|
|
129
|
+
getSchemas: (operation, params, forStatusCode) => generator.getSchemas(operation, {
|
|
130
|
+
forStatusCode,
|
|
131
|
+
resolveName: (name) => pluginManager.resolveName({
|
|
132
|
+
name,
|
|
133
|
+
pluginKey: params?.pluginKey,
|
|
134
|
+
type: params?.type
|
|
135
|
+
})
|
|
136
|
+
}),
|
|
137
|
+
groupSchemasByName
|
|
125
138
|
};
|
|
126
139
|
}
|
|
127
140
|
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: Record<number, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n
|
|
1
|
+
{"version":3,"sources":["../src/hooks/index.ts","../src/hooks/useOas.ts","../src/hooks/useOperation.ts","../src/hooks/useOperationManager.ts","../src/hooks/useOperations.ts"],"sourcesContent":["export { useOas } from './useOas.ts'\nexport { useOperation } from './useOperation.ts'\nexport { useOperationManager } from './useOperationManager.ts'\nexport { useOperations } from './useOperations.ts'\nexport { useSchema } from './useSchema.ts'\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { Oas as OasType } from '@kubb/oas'\n\nexport function useOas(): OasType {\n const { oas } = useContext(Oas.Context)\n\n if (!oas) {\n throw new Error('Oas is not defined')\n }\n\n return oas\n}\n","import { useContext } from '@kubb/react'\n\nimport { Operation } from '../components/Operation.tsx'\n\nimport type { Operation as OperationType } from '@kubb/oas'\n\n/**\n * `useOperation` will return the current `Operation`\n */\nexport function useOperation(): OperationType {\n const { operation } = useContext(Operation.Context)\n\n if (!operation) {\n throw new Error('Operation is not defined')\n }\n\n return operation\n}\n","import { useApp, useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { FileMetaBase, Plugin, ResolveNameParams } from '@kubb/core'\nimport type * as KubbFile from '@kubb/fs/types'\nimport type { Operation, Operation as OperationType } from '@kubb/oas'\nimport type { OperationSchemas } from '../types.ts'\n\ntype FileMeta = FileMetaBase & {\n pluginKey: Plugin['key']\n name: string\n tag?: string\n}\n\ntype SchemaNames = {\n request: string | undefined\n parameters: {\n path: string | undefined\n query: string | undefined\n header: string | undefined\n }\n responses: { default?: string } & Record<number | string, string>\n errors: Record<number | string, string>\n}\n\ntype UseOperationManagerResult = {\n getName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => string\n getFile: (operation: OperationType, params?: { pluginKey?: Plugin['key']; extName?: KubbFile.Extname }) => KubbFile.File<FileMeta>\n groupSchemasByName: (operation: OperationType, params: { pluginKey?: Plugin['key']; type: ResolveNameParams['type'] }) => SchemaNames\n getSchemas: (\n operation: Operation,\n params?: { pluginKey?: Plugin['key']; type?: ResolveNameParams['type'] },\n forStatusCode?: string | number,\n ) => OperationSchemas\n}\n\n/**\n * `useOperationManager` will return some helper functions that can be used to get the operation file, get the operation name.\n */\nexport function useOperationManager(): UseOperationManagerResult {\n const { plugin, pluginManager } = useApp()\n const { generator } = useContext(Oas.Context)\n\n if (!generator) {\n throw new Error(`'generator' is not defined`)\n }\n\n const getName: UseOperationManagerResult['getName'] = (operation, { pluginKey = plugin.key, type }) => {\n return pluginManager.resolveName({\n name: operation.getOperationId(),\n pluginKey,\n type,\n })\n }\n\n const getFile: UseOperationManagerResult['getFile'] = (operation, { pluginKey = plugin.key, extName = '.ts' } = {}) => {\n // needed for the `output.group`\n const tag = operation.getTags().at(0)?.name\n const name = getName(operation, { type: 'file', pluginKey })\n\n const file = pluginManager.getFile({\n name,\n extName,\n pluginKey,\n options: { type: 'file', pluginKey, tag },\n })\n\n return {\n ...file,\n meta: {\n ...file.meta,\n name,\n pluginKey,\n tag,\n },\n }\n }\n\n const groupSchemasByName: UseOperationManagerResult['groupSchemasByName'] = (operation, { pluginKey = plugin.key, type }) => {\n const schemas = generator.getSchemas(operation)\n\n const errors = (schemas.errors || []).reduce(\n (prev, acc) => {\n if (!acc.statusCode) {\n return prev\n }\n\n prev[acc.statusCode] = pluginManager.resolveName({\n name: acc.name,\n pluginKey,\n type,\n })\n\n return prev\n },\n {} as Record<number, string>,\n )\n\n return {\n request: schemas.request?.name\n ? pluginManager.resolveName({\n name: schemas.request.name,\n pluginKey,\n type,\n })\n : undefined,\n parameters: {\n path: schemas.pathParams?.name\n ? pluginManager.resolveName({\n name: schemas.pathParams.name,\n pluginKey,\n type,\n })\n : undefined,\n query: schemas.queryParams?.name\n ? pluginManager.resolveName({\n name: schemas.queryParams.name,\n pluginKey,\n type,\n })\n : undefined,\n header: schemas.headerParams?.name\n ? pluginManager.resolveName({\n name: schemas.headerParams.name,\n pluginKey,\n type,\n })\n : undefined,\n },\n responses: {\n [schemas.response.statusCode || 'default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ['default']: pluginManager.resolveName({\n name: schemas.response.name,\n pluginKey,\n type,\n }),\n ...errors,\n },\n errors,\n }\n }\n\n return {\n getName,\n getFile,\n getSchemas: (operation, params, forStatusCode) =>\n generator.getSchemas(operation, {\n forStatusCode,\n resolveName: (name) =>\n pluginManager.resolveName({\n name,\n pluginKey: params?.pluginKey,\n type: params?.type,\n }),\n }),\n groupSchemasByName,\n }\n}\n","import { useContext } from '@kubb/react'\n\nimport { Oas } from '../components/Oas.tsx'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype UseOperationsProps = {\n /**\n * Filter based on path\n * Weight: 2\n */\n path?: string\n /**\n * Filter based on method\n * Weight: 1\n */\n method?: HttpMethod\n}\n\n/**\n * `useOperations` will return all the Operations\n */\nexport function useOperations({ method, path }: UseOperationsProps = {}): Operation[] {\n const { operations } = useContext(Oas.Context)\n\n if (!operations) {\n throw new Error('Operations is not defined')\n }\n let items = operations\n\n if (path) {\n items = items.filter((item) => item.path === path)\n }\n\n if (method) {\n items = items.filter((item) => item.method === method)\n }\n\n return items\n}\n"],"mappings":";;;;;;;;;;;AAAA;;;ACAA;AAAA,SAAS,kBAAkB;AAMpB,SAAS,SAAkB;AAChC,QAAM,EAAE,IAAI,IAAI,WAAW,IAAI,OAAO;AAEtC,MAAI,CAAC,KAAK;AACR,UAAM,IAAI,MAAM,oBAAoB;AAAA,EACtC;AAEA,SAAO;AAC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AAc,YAAY;AAAA,QACxB;AAAA,QACA,WAAW,QAAQ;AAAA,QACnB,MAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,IACL,CAAC;AAAA,IACH;AAAA,EACF;AACF;;;AClKA;AAAA,SAAS,cAAAC,mBAAkB;AAsBpB,SAAS,cAAc,EAAE,QAAQ,KAAK,IAAwB,CAAC,GAAgB;AACpF,QAAM,EAAE,WAAW,IAAIC,YAAW,IAAI,OAAO;AAE7C,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,2BAA2B;AAAA,EAC7C;AACA,MAAI,QAAQ;AAEZ,MAAI,MAAM;AACR,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,SAAS,IAAI;AAAA,EACnD;AAEA,MAAI,QAAQ;AACV,YAAQ,MAAM,OAAO,CAAC,SAAS,KAAK,WAAW,MAAM;AAAA,EACvD;AAEA,SAAO;AACT;","names":["useContext","useContext","useContext","useContext","useContext","useContext"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkI5OXSD6Kcjs = require('./chunk-I5OXSD6K.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunkERS2ZSATcjs = require('./chunk-ERS2ZSAT.cjs');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -13,13 +13,13 @@ var _chunkIJDG7KT6cjs = require('./chunk-IJDG7KT6.cjs');
|
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _chunkGWI26OTOcjs = require('./chunk-GWI26OTO.cjs');
|
|
17
17
|
|
|
18
18
|
// src/index.ts
|
|
19
|
-
|
|
19
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
20
20
|
|
|
21
21
|
// src/plugin.ts
|
|
22
|
-
|
|
22
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
23
23
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
24
24
|
var _core = require('@kubb/core');
|
|
25
25
|
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
@@ -35,7 +35,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
35
35
|
} = options;
|
|
36
36
|
const getOas = async ({ config, logger, formatOptions }) => {
|
|
37
37
|
try {
|
|
38
|
-
const oas = await
|
|
38
|
+
const oas = await _chunkI5OXSD6Kcjs.parseFromConfig.call(void 0, config, formatOptions);
|
|
39
39
|
if (validate) {
|
|
40
40
|
await oas.valdiate();
|
|
41
41
|
}
|
|
@@ -43,7 +43,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
43
43
|
} catch (e) {
|
|
44
44
|
const error = e;
|
|
45
45
|
logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
|
|
46
|
-
return
|
|
46
|
+
return _chunkI5OXSD6Kcjs.parseFromConfig.call(void 0, config);
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
return {
|
|
@@ -57,7 +57,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
57
57
|
},
|
|
58
58
|
async getSchemas({ includes } = {}) {
|
|
59
59
|
const oas = await this.getOas();
|
|
60
|
-
return
|
|
60
|
+
return _chunkGWI26OTOcjs.getSchemas.call(void 0, { oas, contentType, includes });
|
|
61
61
|
},
|
|
62
62
|
async getBaseURL() {
|
|
63
63
|
const oasInstance = await this.getOas();
|
|
@@ -96,7 +96,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
await oas.dereference();
|
|
99
|
-
const schemas =
|
|
99
|
+
const schemas = _chunkGWI26OTOcjs.getSchemas.call(void 0, { oas, contentType });
|
|
100
100
|
const mapSchema = async ([name, schema]) => {
|
|
101
101
|
const resolvedPath = this.resolvePath({
|
|
102
102
|
baseName: `${name}.json`,
|
|
@@ -126,23 +126,23 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
|
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
// src/OperationGenerator.ts
|
|
129
|
-
|
|
129
|
+
_chunkGWI26OTOcjs.init_cjs_shims.call(void 0, );
|
|
130
130
|
|
|
131
131
|
|
|
132
132
|
var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
|
|
133
133
|
var OperationGenerator = class extends _core.Generator {
|
|
134
134
|
constructor() {
|
|
135
135
|
super(...arguments);
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
_chunkGWI26OTOcjs.__privateAdd.call(void 0, this, _OperationGenerator_instances);
|
|
137
|
+
_chunkGWI26OTOcjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
|
|
138
138
|
}
|
|
139
139
|
get operationsByMethod() {
|
|
140
|
-
return
|
|
140
|
+
return _chunkGWI26OTOcjs.__privateGet.call(void 0, this, _operationsByMethod);
|
|
141
141
|
}
|
|
142
142
|
set operationsByMethod(paths) {
|
|
143
|
-
|
|
143
|
+
_chunkGWI26OTOcjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
|
|
144
144
|
}
|
|
145
|
-
getSchemas(operation, forStatusCode) {
|
|
145
|
+
getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
|
|
146
146
|
const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
|
|
147
147
|
const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
|
|
148
148
|
const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
|
|
@@ -156,7 +156,7 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
156
156
|
}
|
|
157
157
|
const schema = this.context.oas.getResponseSchema(operation, statusCode);
|
|
158
158
|
return {
|
|
159
|
-
name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`),
|
|
159
|
+
name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`)),
|
|
160
160
|
description: _optionalChain([operation, 'access', _7 => _7.getResponseByStatusCode, 'call', _8 => _8(statusCode), 'optionalAccess', _9 => _9.description]),
|
|
161
161
|
schema,
|
|
162
162
|
operation,
|
|
@@ -167,28 +167,28 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
167
167
|
});
|
|
168
168
|
return {
|
|
169
169
|
pathParams: pathParamsSchema ? {
|
|
170
|
-
name: _transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`),
|
|
170
|
+
name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`)),
|
|
171
171
|
operation,
|
|
172
172
|
operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
|
|
173
173
|
schema: pathParamsSchema,
|
|
174
174
|
keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
|
|
175
175
|
} : void 0,
|
|
176
176
|
queryParams: queryParamsSchema ? {
|
|
177
|
-
name: _transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`),
|
|
177
|
+
name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
|
|
178
178
|
operation,
|
|
179
179
|
operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
|
|
180
180
|
schema: queryParamsSchema,
|
|
181
181
|
keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
|
|
182
182
|
} : void 0,
|
|
183
183
|
headerParams: headerParamsSchema ? {
|
|
184
|
-
name: _transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`),
|
|
184
|
+
name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
|
|
185
185
|
operation,
|
|
186
186
|
operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
|
|
187
187
|
schema: headerParamsSchema,
|
|
188
188
|
keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
|
|
189
189
|
} : void 0,
|
|
190
190
|
request: requestSchema ? {
|
|
191
|
-
name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`),
|
|
191
|
+
name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
|
|
192
192
|
description: _optionalChain([operation, 'access', _11 => _11.schema, 'access', _12 => _12.requestBody, 'optionalAccess', _13 => _13.description]),
|
|
193
193
|
operation,
|
|
194
194
|
operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
|
|
@@ -200,7 +200,7 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
200
200
|
}) : void 0
|
|
201
201
|
} : void 0,
|
|
202
202
|
response: {
|
|
203
|
-
name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`),
|
|
203
|
+
name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
|
|
204
204
|
description: _optionalChain([operation, 'access', _17 => _17.getResponseAsJSONSchema, 'call', _18 => _18(responseStatusCode), 'optionalAccess', _19 => _19.at, 'call', _20 => _20(0), 'optionalAccess', _21 => _21.description]),
|
|
205
205
|
operation,
|
|
206
206
|
operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
|
|
@@ -223,9 +223,9 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
223
223
|
const methods = Object.keys(method);
|
|
224
224
|
methods.forEach((method2) => {
|
|
225
225
|
const operation = oas.operation(path2, method2);
|
|
226
|
-
if (operation &&
|
|
227
|
-
const isExcluded =
|
|
228
|
-
const isIncluded = this.context.include ?
|
|
226
|
+
if (operation && _chunkGWI26OTOcjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get)[method2]) {
|
|
227
|
+
const isExcluded = _chunkGWI26OTOcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
|
|
228
|
+
const isIncluded = this.context.include ? _chunkGWI26OTOcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
|
|
229
229
|
if (isIncluded && !isExcluded) {
|
|
230
230
|
if (!acc[path2]) {
|
|
231
231
|
acc[path2] = {};
|
|
@@ -246,8 +246,8 @@ var OperationGenerator = class extends _core.Generator {
|
|
|
246
246
|
const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
|
|
247
247
|
methods.forEach((method) => {
|
|
248
248
|
const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
|
|
249
|
-
const options =
|
|
250
|
-
const promiseMethod = _optionalChain([
|
|
249
|
+
const options = _chunkGWI26OTOcjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
|
|
250
|
+
const promiseMethod = _optionalChain([_chunkGWI26OTOcjs.__privateGet.call(void 0, this, _OperationGenerator_instances, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
|
|
251
251
|
...this.options,
|
|
252
252
|
...options
|
|
253
253
|
})]);
|
|
@@ -402,5 +402,5 @@ var src_default = definePluginDefault;
|
|
|
402
402
|
|
|
403
403
|
|
|
404
404
|
|
|
405
|
-
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator =
|
|
405
|
+
exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkERS2ZSATcjs.SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkERS2ZSATcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkERS2ZSATcjs.schemaKeywords;
|
|
406
406
|
//# sourceMappingURL=index.cjs.map
|