@kubb/plugin-oas 0.0.0-canary-20240804130641 → 0.0.0-canary-20241104172400
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 +14 -5
- package/dist/OperationGenerator-Bw6sj3Eb.d.cts +560 -0
- package/dist/OperationGenerator-Bw6sj3Eb.d.ts +560 -0
- package/dist/{Schema-D41ItX9C.d.ts → Schema-4FwWfdim.d.cts} +2 -13
- package/dist/{Schema-FGI5VPqc.d.cts → Schema-BlGtSgNB.d.ts} +2 -13
- package/dist/chunk-2TGWPVZN.cjs +92 -0
- package/dist/chunk-2TGWPVZN.cjs.map +1 -0
- package/dist/chunk-A3ROGKLW.cjs +752 -0
- package/dist/chunk-A3ROGKLW.cjs.map +1 -0
- package/dist/chunk-ABOQ73FL.cjs +36 -0
- package/dist/chunk-ABOQ73FL.cjs.map +1 -0
- package/dist/chunk-BG77DP54.js +30 -0
- package/dist/chunk-BG77DP54.js.map +1 -0
- package/dist/chunk-GF26SDHQ.js +28 -0
- package/dist/chunk-GF26SDHQ.js.map +1 -0
- package/dist/chunk-JA75IPYU.js +744 -0
- package/dist/chunk-JA75IPYU.js.map +1 -0
- package/dist/chunk-PADR76WZ.cjs +4 -0
- package/dist/chunk-PADR76WZ.cjs.map +1 -0
- package/dist/chunk-QAFBZLJA.cjs +48 -0
- package/dist/chunk-QAFBZLJA.cjs.map +1 -0
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/chunk-TNWNNVQW.js +88 -0
- package/dist/chunk-TNWNNVQW.js.map +1 -0
- package/dist/chunk-XNCEFOE6.js +45 -0
- package/dist/chunk-XNCEFOE6.js.map +1 -0
- package/dist/chunk-ZWHQ54JM.cjs +32 -0
- package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
- package/dist/components.cjs +20 -17
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +12 -9
- package/dist/components.d.ts +12 -9
- package/dist/components.js +3 -17
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +14 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +9 -0
- package/dist/generators.d.ts +9 -0
- package/dist/generators.js +5 -0
- package/dist/generators.js.map +1 -0
- package/dist/hooks.cjs +90 -58
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +37 -10
- package/dist/hooks.d.ts +37 -10
- package/dist/hooks.js +79 -54
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +277 -270
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -78
- package/dist/index.d.ts +6 -78
- package/dist/index.js +235 -255
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +32 -87
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +8 -43
- package/dist/utils.d.ts +8 -43
- package/dist/utils.js +8 -86
- package/dist/utils.js.map +1 -1
- package/package.json +21 -15
- package/src/OperationGenerator.ts +91 -64
- package/src/SchemaGenerator.ts +102 -22
- package/src/SchemaMapper.ts +24 -5
- package/src/components/Oas.tsx +9 -3
- package/src/components/Operation.tsx +1 -1
- package/src/components/Schema.tsx +2 -99
- package/src/generator.tsx +129 -0
- package/src/generators/index.ts +1 -0
- package/src/generators/jsonGenerator.ts +32 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +56 -30
- package/src/hooks/useSchemaManager.ts +77 -0
- package/src/index.ts +5 -13
- package/src/plugin.ts +73 -69
- package/src/types.ts +29 -27
- package/src/utils/getParams.ts +2 -2
- package/src/utils/getSchemaFactory.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/OperationGenerator-BV6QRtkW.d.cts +0 -60
- package/dist/OperationGenerator-DO5tNGuT.d.ts +0 -60
- package/dist/SchemaMapper-CsBQ6eEx.d.cts +0 -248
- package/dist/SchemaMapper-CsBQ6eEx.d.ts +0 -248
- package/dist/chunk-CCPZYOTX.cjs +0 -695
- package/dist/chunk-CCPZYOTX.cjs.map +0 -1
- package/dist/chunk-CO7DS2KL.cjs +0 -35
- package/dist/chunk-CO7DS2KL.cjs.map +0 -1
- package/dist/chunk-EK7UO5ZW.js +0 -35
- package/dist/chunk-EK7UO5ZW.js.map +0 -1
- package/dist/chunk-KI3GNEKH.js +0 -3265
- package/dist/chunk-KI3GNEKH.js.map +0 -1
- package/dist/chunk-LRJFQCDO.js +0 -101
- package/dist/chunk-LRJFQCDO.js.map +0 -1
- package/dist/chunk-PFN2GSIC.cjs +0 -101
- package/dist/chunk-PFN2GSIC.cjs.map +0 -1
- package/dist/chunk-TL7TBM2U.cjs +0 -3265
- package/dist/chunk-TL7TBM2U.cjs.map +0 -1
- package/dist/chunk-UZLE6NIY.js +0 -695
- package/dist/chunk-UZLE6NIY.js.map +0 -1
- package/dist/types-Db0qp8u-.d.cts +0 -148
- package/dist/types-Db0qp8u-.d.ts +0 -148
- package/src/utils/getGroupedByTagFiles.ts +0 -82
- package/src/utils/refSorter.ts +0 -13
package/src/plugin.ts
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { createPlugin } from '@kubb/core'
|
|
4
|
-
import { camelCase } from '@kubb/core/transformers'
|
|
1
|
+
import { FileManager, createPlugin } from '@kubb/core'
|
|
5
2
|
|
|
6
3
|
import { getSchemas } from './utils/getSchemas.ts'
|
|
4
|
+
import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
7
5
|
|
|
6
|
+
import path from 'node:path'
|
|
8
7
|
import type { Config } from '@kubb/core'
|
|
9
8
|
import type { Logger } from '@kubb/core/logger'
|
|
10
|
-
import type { Oas
|
|
11
|
-
import
|
|
9
|
+
import type { Oas } from '@kubb/oas'
|
|
10
|
+
import { OperationGenerator } from './OperationGenerator.ts'
|
|
11
|
+
import { SchemaGenerator } from './SchemaGenerator.ts'
|
|
12
|
+
import { jsonGenerator } from './generators'
|
|
12
13
|
import type { PluginOas } from './types.ts'
|
|
13
|
-
import { parseFromConfig } from './utils/parseFromConfig.ts'
|
|
14
14
|
|
|
15
15
|
export const pluginOasName = 'plugin-oas' satisfies PluginOas['name']
|
|
16
16
|
|
|
17
17
|
export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
18
18
|
const {
|
|
19
|
-
output = {
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
output = {
|
|
20
|
+
path: 'schemas',
|
|
21
|
+
},
|
|
22
22
|
validate = true,
|
|
23
|
-
|
|
23
|
+
generators = [jsonGenerator],
|
|
24
|
+
serverIndex,
|
|
24
25
|
contentType,
|
|
25
26
|
oasClass,
|
|
26
27
|
} = options
|
|
27
28
|
|
|
28
|
-
const getOas = async ({ config, logger
|
|
29
|
+
const getOas = async ({ config, logger }: { config: Config; logger: Logger }): Promise<Oas> => {
|
|
29
30
|
try {
|
|
30
31
|
// needs to be in a different variable or the catch here will not work(return of a promise instead)
|
|
31
|
-
const oas = await parseFromConfig(config,
|
|
32
|
+
const oas = await parseFromConfig(config, oasClass)
|
|
32
33
|
|
|
33
34
|
if (validate) {
|
|
34
35
|
await oas.valdiate()
|
|
@@ -39,20 +40,22 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
39
40
|
const error = e as Error
|
|
40
41
|
|
|
41
42
|
logger.emit('warning', error?.message)
|
|
42
|
-
return parseFromConfig(config,
|
|
43
|
+
return parseFromConfig(config, oasClass)
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
return {
|
|
47
48
|
name: pluginOasName,
|
|
48
|
-
options
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
options: {
|
|
50
|
+
output,
|
|
51
|
+
...options,
|
|
52
|
+
},
|
|
53
|
+
context() {
|
|
51
54
|
const { config, logger } = this
|
|
52
55
|
|
|
53
56
|
return {
|
|
54
|
-
getOas(
|
|
55
|
-
return getOas({ config, logger
|
|
57
|
+
getOas() {
|
|
58
|
+
return getOas({ config, logger })
|
|
56
59
|
},
|
|
57
60
|
async getSchemas({ includes } = {}) {
|
|
58
61
|
const oas = await this.getOas()
|
|
@@ -60,30 +63,28 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
60
63
|
},
|
|
61
64
|
async getBaseURL() {
|
|
62
65
|
const oasInstance = await this.getOas()
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
if (serverIndex) {
|
|
67
|
+
return oasInstance.api.servers?.at(serverIndex)?.url
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return undefined
|
|
65
71
|
},
|
|
66
72
|
contentType,
|
|
67
73
|
}
|
|
68
74
|
},
|
|
69
|
-
resolvePath(baseName) {
|
|
70
|
-
if (output === false) {
|
|
71
|
-
return undefined
|
|
72
|
-
}
|
|
73
|
-
|
|
75
|
+
resolvePath(baseName, pathMode, options) {
|
|
74
76
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
77
|
+
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
|
|
78
|
+
|
|
79
|
+
if (mode === 'single') {
|
|
80
|
+
/**
|
|
81
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
82
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
83
|
+
*/
|
|
84
|
+
return path.resolve(root, output.path)
|
|
84
85
|
}
|
|
85
86
|
|
|
86
|
-
return
|
|
87
|
+
return path.resolve(root, output.path, baseName)
|
|
87
88
|
},
|
|
88
89
|
async buildStart() {
|
|
89
90
|
if (!output) {
|
|
@@ -93,42 +94,45 @@ export const pluginOas = createPlugin<PluginOas>((options) => {
|
|
|
93
94
|
const oas = await getOas({
|
|
94
95
|
config: this.config,
|
|
95
96
|
logger: this.logger,
|
|
96
|
-
formatOptions: {
|
|
97
|
-
filterSet: filter,
|
|
98
|
-
sortSet: sort,
|
|
99
|
-
},
|
|
100
97
|
})
|
|
101
98
|
await oas.dereference()
|
|
102
|
-
const schemas = getSchemas({ oas, contentType })
|
|
103
|
-
|
|
104
|
-
const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {
|
|
105
|
-
const resolvedPath = this.resolvePath({
|
|
106
|
-
baseName: `${name}.json`,
|
|
107
|
-
pluginKey: this.plugin.key,
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
const resvoledFileName = this.resolveName({
|
|
111
|
-
name: `${name}.json`,
|
|
112
|
-
pluginKey: [pluginOasName],
|
|
113
|
-
type: 'file',
|
|
114
|
-
}) as `${string}.json`
|
|
115
|
-
|
|
116
|
-
if (!resolvedPath) {
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
await this.addFile({
|
|
121
|
-
path: resolvedPath,
|
|
122
|
-
baseName: resvoledFileName,
|
|
123
|
-
source: JSON.stringify(schema),
|
|
124
|
-
meta: {
|
|
125
|
-
pluginKey: this.plugin.key,
|
|
126
|
-
},
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
99
|
|
|
130
|
-
const
|
|
131
|
-
|
|
100
|
+
const schemaGenerator = new SchemaGenerator(
|
|
101
|
+
{
|
|
102
|
+
unknownType: 'unknown',
|
|
103
|
+
dateType: 'date',
|
|
104
|
+
transformers: {},
|
|
105
|
+
...this.plugin.options,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
oas,
|
|
109
|
+
pluginManager: this.pluginManager,
|
|
110
|
+
plugin: this.plugin,
|
|
111
|
+
contentType,
|
|
112
|
+
include: undefined,
|
|
113
|
+
override: undefined,
|
|
114
|
+
mode: 'split',
|
|
115
|
+
output: output.path,
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
const schemaFiles = await schemaGenerator.build(...generators)
|
|
120
|
+
await this.addFile(...schemaFiles)
|
|
121
|
+
|
|
122
|
+
const operationGenerator = new OperationGenerator(this.plugin.options, {
|
|
123
|
+
oas,
|
|
124
|
+
pluginManager: this.pluginManager,
|
|
125
|
+
plugin: this.plugin,
|
|
126
|
+
contentType,
|
|
127
|
+
exclude: undefined,
|
|
128
|
+
include: undefined,
|
|
129
|
+
override: undefined,
|
|
130
|
+
mode: 'split',
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
const operationFiles = await operationGenerator.build(...generators)
|
|
134
|
+
|
|
135
|
+
await this.addFile(...operationFiles)
|
|
132
136
|
},
|
|
133
137
|
}
|
|
134
138
|
})
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Plugin } from '@kubb/core'
|
|
1
|
+
import type { Output, Plugin } from '@kubb/core'
|
|
2
2
|
import type { PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
|
|
3
3
|
import type * as KubbFile from '@kubb/fs/types'
|
|
4
4
|
|
|
5
5
|
import type { HttpMethod, Oas, Operation, SchemaObject, contentType } from '@kubb/oas'
|
|
6
|
-
import type {
|
|
6
|
+
import type { Generator } from './generator.tsx'
|
|
7
7
|
import type { GetSchemasProps } from './utils/getSchemas.ts'
|
|
8
8
|
|
|
9
9
|
export type ResolvePathOptions = {
|
|
@@ -13,7 +13,7 @@ export type ResolvePathOptions = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export type API = {
|
|
16
|
-
getOas: (
|
|
16
|
+
getOas: () => Promise<Oas>
|
|
17
17
|
getSchemas: (options?: Pick<GetSchemasProps, 'includes'>) => Promise<Record<string, SchemaObject>>
|
|
18
18
|
getBaseURL: () => Promise<string | undefined>
|
|
19
19
|
contentType?: contentType
|
|
@@ -25,44 +25,42 @@ export type Options = {
|
|
|
25
25
|
* @default true
|
|
26
26
|
*/
|
|
27
27
|
validate?: boolean
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
* @default 'schemas'
|
|
34
|
-
*/
|
|
35
|
-
path: string
|
|
36
|
-
}
|
|
37
|
-
| false
|
|
28
|
+
/**
|
|
29
|
+
* Specify the export location for the files and define the behavior of the output
|
|
30
|
+
* @default { path: 'schemas', barrelType: 'named' }
|
|
31
|
+
*/
|
|
32
|
+
output?: Output
|
|
38
33
|
/**
|
|
39
34
|
* Which server to use from the array of `servers.url[serverIndex]`
|
|
40
35
|
* @example
|
|
41
36
|
* - `0` will return `http://petstore.swagger.io/api`
|
|
42
37
|
* - `1` will return `http://localhost:3000`
|
|
43
|
-
* @default 0
|
|
44
38
|
*/
|
|
45
39
|
serverIndex?: number
|
|
46
40
|
/**
|
|
47
41
|
* Define which contentType should be used.
|
|
48
|
-
* By default, this is set based on the
|
|
42
|
+
* By default, this is set based on the contentType being found.
|
|
49
43
|
*/
|
|
50
44
|
contentType?: contentType
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Override some behaviour of the Oas class instance, see '@kubb/oas'
|
|
47
|
+
*/
|
|
53
48
|
oasClass?: typeof Oas
|
|
49
|
+
/**
|
|
50
|
+
* Define some generators next to the JSON generation
|
|
51
|
+
*/
|
|
52
|
+
generators?: Array<Generator<PluginOas>>
|
|
54
53
|
}
|
|
55
54
|
|
|
56
55
|
/**
|
|
57
56
|
* `propertyName` is the ref name + resolved with the nameResolver
|
|
58
|
-
* @example
|
|
57
|
+
* @example import { Pet } from './Pet'
|
|
59
58
|
*
|
|
60
59
|
* `originalName` is the original name used(in PascalCase), only used to remove duplicates
|
|
61
60
|
*
|
|
62
61
|
* `pluginKey` can be used to override the current plugin being used, handy when you want to import a type/schema out of another plugin
|
|
63
|
-
* @example import a type(
|
|
62
|
+
* @example import a type(plugin-ts) for a mock file(swagger-faker)
|
|
64
63
|
*/
|
|
65
|
-
|
|
66
64
|
export type Ref = {
|
|
67
65
|
propertyName: string
|
|
68
66
|
originalName: string
|
|
@@ -90,7 +88,7 @@ export type OperationSchema = {
|
|
|
90
88
|
/**
|
|
91
89
|
* OperationName in PascalCase, only being used in OperationGenerator
|
|
92
90
|
*/
|
|
93
|
-
operationName
|
|
91
|
+
operationName: string
|
|
94
92
|
description?: string
|
|
95
93
|
statusCode?: number
|
|
96
94
|
keys?: string[]
|
|
@@ -104,6 +102,7 @@ export type OperationSchemas = {
|
|
|
104
102
|
headerParams?: OperationSchema & { keysToOmit?: never }
|
|
105
103
|
request?: OperationSchema
|
|
106
104
|
response: OperationSchema
|
|
105
|
+
responses: Array<OperationSchema>
|
|
107
106
|
statusCodes?: Array<OperationSchema>
|
|
108
107
|
errors?: Array<OperationSchema>
|
|
109
108
|
}
|
|
@@ -128,6 +127,11 @@ type ByMethod = {
|
|
|
128
127
|
type: 'method'
|
|
129
128
|
pattern: HttpMethod | RegExp
|
|
130
129
|
}
|
|
130
|
+
// TODO implement as alternative for ByMethod
|
|
131
|
+
type ByMethods = {
|
|
132
|
+
type: 'methods'
|
|
133
|
+
pattern: Array<HttpMethod>
|
|
134
|
+
}
|
|
131
135
|
|
|
132
136
|
type BySchemaName = {
|
|
133
137
|
type: 'schemaName'
|
|
@@ -141,10 +145,8 @@ export type Override<TOptions> = (ByTag | ByOperationId | ByPath | ByMethod | By
|
|
|
141
145
|
options: Partial<TOptions>
|
|
142
146
|
}
|
|
143
147
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
declare module '@kubb/core' {
|
|
147
|
-
export interface _Register {
|
|
148
|
-
['@kubb/plugin-oas']: PluginOas
|
|
149
|
-
}
|
|
148
|
+
type ResolvedOptions = Options & {
|
|
149
|
+
output: Output
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
export type PluginOas = PluginFactoryOptions<'plugin-oas', Options, ResolvedOptions, API, never>
|
package/src/utils/getParams.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { isParameterObject } from '@kubb/oas'
|
|
2
2
|
|
|
3
|
+
import { camelCase } from '@kubb/core/transformers'
|
|
3
4
|
import type { FunctionParamsAST } from '@kubb/core/utils'
|
|
4
5
|
import type { OasTypes } from '@kubb/oas'
|
|
5
|
-
import type { Params } from '@kubb/react'
|
|
6
|
+
import type { Params } from '@kubb/react/types'
|
|
6
7
|
import type { OperationSchema } from '../types.ts'
|
|
7
|
-
import { camelCase } from '@kubb/core/transformers'
|
|
8
8
|
/**
|
|
9
9
|
*
|
|
10
10
|
* @deprecated
|
|
@@ -26,7 +26,7 @@ export function getSchemaFactory<TWithRef extends boolean = false>(oas: Oas): (s
|
|
|
26
26
|
const version = isOpenApiV3_1Document(oas.api) ? '3.1' : '3.0'
|
|
27
27
|
|
|
28
28
|
return {
|
|
29
|
-
schema,
|
|
29
|
+
schema: oas.dereferenceWithRef(schema),
|
|
30
30
|
version,
|
|
31
31
|
} as SchemaResult<TWithRef>
|
|
32
32
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { getComments } from './getComments.ts'
|
|
2
|
-
export { getGroupedByTagFiles } from './getGroupedByTagFiles.ts'
|
|
3
2
|
export { getASTParams, getPathParams } from './getParams.ts'
|
|
4
3
|
export { getSchemaFactory } from './getSchemaFactory.ts'
|
|
5
4
|
export type { GetSchemasProps } from './getSchemas.ts'
|
|
6
5
|
export { getSchemas } from './getSchemas.ts'
|
|
7
|
-
export { refsSorter } from './refSorter.ts'
|
|
8
6
|
export { parseFromConfig } from './parseFromConfig.ts'
|
|
7
|
+
|
|
8
|
+
export { isOptional } from '@kubb/oas'
|
|
@@ -2,35 +2,35 @@ import { resolve } from 'node:path'
|
|
|
2
2
|
|
|
3
3
|
import { URLPath } from '@kubb/core/utils'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { parse } from '@kubb/oas/parser'
|
|
6
6
|
|
|
7
7
|
import type { Config } from '@kubb/core'
|
|
8
8
|
import { Oas, type OasTypes } from '@kubb/oas'
|
|
9
9
|
import yaml from '@stoplight/yaml'
|
|
10
10
|
|
|
11
|
-
export function parseFromConfig(config: Config,
|
|
11
|
+
export function parseFromConfig(config: Config, oasClass: typeof Oas = Oas): Promise<Oas> {
|
|
12
12
|
if ('data' in config.input) {
|
|
13
13
|
if (typeof config.input.data === 'object') {
|
|
14
14
|
const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument
|
|
15
|
-
return parse(api,
|
|
15
|
+
return parse(api, oasClass)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
19
|
const api: string = yaml.parse(config.input.data as string) as string
|
|
20
20
|
|
|
21
|
-
return parse(api,
|
|
21
|
+
return parse(api, oasClass)
|
|
22
22
|
} catch (e) {
|
|
23
23
|
/* empty */
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const api: OasTypes.OASDocument = JSON.parse(JSON.stringify(config.input.data)) as OasTypes.OASDocument
|
|
27
27
|
|
|
28
|
-
return parse(api,
|
|
28
|
+
return parse(api, oasClass)
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (new URLPath(config.input.path).isURL) {
|
|
32
|
-
return parse(config.input.path,
|
|
32
|
+
return parse(config.input.path, oasClass)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
return parse(resolve(config.root, config.input.path),
|
|
35
|
+
return parse(resolve(config.root, config.input.path), oasClass)
|
|
36
36
|
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { FileMetaBase, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
-
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
-
import { Operation, Oas, contentType } from '@kubb/oas';
|
|
4
|
-
import { g as OperationsByMethod, f as OperationSchemas, E as Exclude, I as Include, b as Override } from './types-Db0qp8u-.cjs';
|
|
5
|
-
|
|
6
|
-
type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
|
|
7
|
-
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
8
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
9
|
-
oas: Oas;
|
|
10
|
-
exclude: Array<Exclude> | undefined;
|
|
11
|
-
include: Array<Include> | undefined;
|
|
12
|
-
override: Array<Override<TOptions>> | undefined;
|
|
13
|
-
contentType: contentType | undefined;
|
|
14
|
-
pluginManager: PluginManager;
|
|
15
|
-
/**
|
|
16
|
-
* Current plugin
|
|
17
|
-
*/
|
|
18
|
-
plugin: Plugin<TPluginOptions>;
|
|
19
|
-
mode: KubbFile.Mode;
|
|
20
|
-
};
|
|
21
|
-
declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
22
|
-
#private;
|
|
23
|
-
get operationsByMethod(): OperationsByMethod;
|
|
24
|
-
set operationsByMethod(paths: OperationsByMethod);
|
|
25
|
-
getSchemas(operation: Operation, { forStatusCode, resolveName }?: {
|
|
26
|
-
forStatusCode?: string | number;
|
|
27
|
-
resolveName?: (name: string) => string;
|
|
28
|
-
}): OperationSchemas;
|
|
29
|
-
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
30
|
-
/**
|
|
31
|
-
* Operation
|
|
32
|
-
*/
|
|
33
|
-
operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
34
|
-
/**
|
|
35
|
-
* GET
|
|
36
|
-
*/
|
|
37
|
-
get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
38
|
-
/**
|
|
39
|
-
* POST
|
|
40
|
-
*/
|
|
41
|
-
post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
42
|
-
/**
|
|
43
|
-
* PATCH
|
|
44
|
-
*/
|
|
45
|
-
patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
46
|
-
/**
|
|
47
|
-
* PUT
|
|
48
|
-
*/
|
|
49
|
-
put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
50
|
-
/**
|
|
51
|
-
* DELETE
|
|
52
|
-
*/
|
|
53
|
-
delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
54
|
-
/**
|
|
55
|
-
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
56
|
-
*/
|
|
57
|
-
all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { FileMetaBase, PluginFactoryOptions, Generator, PluginManager, Plugin } from '@kubb/core';
|
|
2
|
-
import * as KubbFile from '@kubb/fs/types';
|
|
3
|
-
import { Operation, Oas, contentType } from '@kubb/oas';
|
|
4
|
-
import { g as OperationsByMethod, f as OperationSchemas, E as Exclude, I as Include, b as Override } from './types-Db0qp8u-.js';
|
|
5
|
-
|
|
6
|
-
type GetOperationGeneratorOptions<T extends OperationGenerator<any, any, any>> = T extends OperationGenerator<infer Options, any, any> ? Options : never;
|
|
7
|
-
type OperationMethodResult<TFileMeta extends FileMetaBase> = Promise<KubbFile.File<TFileMeta> | Array<KubbFile.File<TFileMeta>> | null>;
|
|
8
|
-
type Context<TOptions, TPluginOptions extends PluginFactoryOptions> = {
|
|
9
|
-
oas: Oas;
|
|
10
|
-
exclude: Array<Exclude> | undefined;
|
|
11
|
-
include: Array<Include> | undefined;
|
|
12
|
-
override: Array<Override<TOptions>> | undefined;
|
|
13
|
-
contentType: contentType | undefined;
|
|
14
|
-
pluginManager: PluginManager;
|
|
15
|
-
/**
|
|
16
|
-
* Current plugin
|
|
17
|
-
*/
|
|
18
|
-
plugin: Plugin<TPluginOptions>;
|
|
19
|
-
mode: KubbFile.Mode;
|
|
20
|
-
};
|
|
21
|
-
declare abstract class OperationGenerator<TOptions = unknown, TPluginOptions extends PluginFactoryOptions = PluginFactoryOptions, TFileMeta extends FileMetaBase = FileMetaBase> extends Generator<TOptions, Context<TOptions, TPluginOptions>> {
|
|
22
|
-
#private;
|
|
23
|
-
get operationsByMethod(): OperationsByMethod;
|
|
24
|
-
set operationsByMethod(paths: OperationsByMethod);
|
|
25
|
-
getSchemas(operation: Operation, { forStatusCode, resolveName }?: {
|
|
26
|
-
forStatusCode?: string | number;
|
|
27
|
-
resolveName?: (name: string) => string;
|
|
28
|
-
}): OperationSchemas;
|
|
29
|
-
build(): Promise<Array<KubbFile.File<TFileMeta>>>;
|
|
30
|
-
/**
|
|
31
|
-
* Operation
|
|
32
|
-
*/
|
|
33
|
-
operation(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
34
|
-
/**
|
|
35
|
-
* GET
|
|
36
|
-
*/
|
|
37
|
-
get(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
38
|
-
/**
|
|
39
|
-
* POST
|
|
40
|
-
*/
|
|
41
|
-
post(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
42
|
-
/**
|
|
43
|
-
* PATCH
|
|
44
|
-
*/
|
|
45
|
-
patch(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
46
|
-
/**
|
|
47
|
-
* PUT
|
|
48
|
-
*/
|
|
49
|
-
put(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
50
|
-
/**
|
|
51
|
-
* DELETE
|
|
52
|
-
*/
|
|
53
|
-
delete(operation: Operation, options: TOptions): OperationMethodResult<TFileMeta>;
|
|
54
|
-
/**
|
|
55
|
-
* Combination of GET, POST, PATCH, PUT, DELETE
|
|
56
|
-
*/
|
|
57
|
-
all(operations: Operation[], paths: OperationsByMethod): OperationMethodResult<TFileMeta>;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export { type GetOperationGeneratorOptions as G, type OperationMethodResult as O, OperationGenerator as a };
|