@kubb/plugin-cypress 4.12.4 → 4.12.6
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/components-CKNcdnr_.js +101 -0
- package/dist/components-CKNcdnr_.js.map +1 -0
- package/dist/components-UBGR5HIj.cjs +107 -0
- package/dist/components-UBGR5HIj.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +23 -2
- package/dist/components.d.ts +23 -2
- package/dist/components.js +1 -1
- package/dist/{generators-Nkjg7hcp.cjs → generators-Ct9I-qNg.cjs} +7 -5
- package/dist/generators-Ct9I-qNg.cjs.map +1 -0
- package/dist/{generators-CnEpcL-m.js → generators-D_AameR6.js} +7 -5
- package/dist/generators-D_AameR6.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +6 -3
- 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 +6 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-BVMff21d.d.ts → types-By2wx7F-.d.ts} +23 -1
- package/dist/{types-DjLyok_a.d.cts → types-CYBedFjk.d.cts} +23 -1
- package/package.json +5 -5
- package/src/components/Request.tsx +104 -12
- package/src/generators/__snapshots__/createPet.ts +2 -2
- package/src/generators/__snapshots__/deletePet.ts +9 -5
- package/src/generators/__snapshots__/getPets.ts +4 -4
- package/src/generators/__snapshots__/getPetsWithTemplateString.ts +4 -4
- package/src/generators/__snapshots__/showPetById.ts +4 -5
- package/src/generators/__snapshots__/updatePet.ts +19 -0
- package/src/generators/cypressGenerator.tsx +5 -3
- package/src/plugin.ts +7 -0
- package/src/types.ts +22 -0
- package/dist/components-CNBoaPo0.cjs +0 -48
- package/dist/components-CNBoaPo0.cjs.map +0 -1
- package/dist/components-GZOhGVCA.js +0 -42
- package/dist/components-GZOhGVCA.js.map +0 -1
- package/dist/generators-CnEpcL-m.js.map +0 -1
- package/dist/generators-Nkjg7hcp.cjs.map +0 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { getPathParams } from "@kubb/plugin-oas/utils";
|
|
2
|
+
import { File, Function, FunctionParams } from "@kubb/react-fabric";
|
|
3
|
+
import { URLPath } from "@kubb/core/utils";
|
|
4
|
+
import { isOptional } from "@kubb/oas";
|
|
5
|
+
import { jsx } from "@kubb/react-fabric/jsx-runtime";
|
|
6
|
+
|
|
7
|
+
//#region src/components/Request.tsx
|
|
8
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
9
|
+
if (paramsType === "object") return FunctionParams.factory({
|
|
10
|
+
data: {
|
|
11
|
+
mode: "object",
|
|
12
|
+
children: {
|
|
13
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
14
|
+
typed: true,
|
|
15
|
+
casing: paramsCasing
|
|
16
|
+
}),
|
|
17
|
+
data: typeSchemas.request?.name ? {
|
|
18
|
+
type: typeSchemas.request?.name,
|
|
19
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
20
|
+
} : void 0,
|
|
21
|
+
params: typeSchemas.queryParams?.name ? {
|
|
22
|
+
type: typeSchemas.queryParams?.name,
|
|
23
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
24
|
+
} : void 0,
|
|
25
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
26
|
+
type: typeSchemas.headerParams?.name,
|
|
27
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
28
|
+
} : void 0
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
options: {
|
|
32
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
33
|
+
optional: true,
|
|
34
|
+
default: "{}"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return FunctionParams.factory({
|
|
38
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
39
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
40
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
41
|
+
typed: true,
|
|
42
|
+
casing: paramsCasing
|
|
43
|
+
}),
|
|
44
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
45
|
+
} : void 0,
|
|
46
|
+
data: typeSchemas.request?.name ? {
|
|
47
|
+
type: typeSchemas.request?.name,
|
|
48
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
49
|
+
} : void 0,
|
|
50
|
+
params: typeSchemas.queryParams?.name ? {
|
|
51
|
+
type: typeSchemas.queryParams?.name,
|
|
52
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
53
|
+
} : void 0,
|
|
54
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
55
|
+
type: typeSchemas.headerParams?.name,
|
|
56
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
57
|
+
} : void 0,
|
|
58
|
+
options: {
|
|
59
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
60
|
+
optional: true,
|
|
61
|
+
default: "{}"
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }) {
|
|
66
|
+
const path = new URLPath(url, { casing: paramsCasing });
|
|
67
|
+
const params = getParams({
|
|
68
|
+
paramsType,
|
|
69
|
+
paramsCasing,
|
|
70
|
+
pathParamsType,
|
|
71
|
+
typeSchemas
|
|
72
|
+
});
|
|
73
|
+
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`;
|
|
74
|
+
const urlTemplate = path.toTemplateString({ prefix: baseURL });
|
|
75
|
+
const requestOptions = [`method: '${method}'`, `url: ${urlTemplate}`];
|
|
76
|
+
if (typeSchemas.queryParams?.name) requestOptions.push("qs: params");
|
|
77
|
+
if (typeSchemas.headerParams?.name) requestOptions.push("headers");
|
|
78
|
+
if (typeSchemas.request?.name) requestOptions.push("body: data");
|
|
79
|
+
requestOptions.push("...options");
|
|
80
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
81
|
+
name,
|
|
82
|
+
isIndexable: true,
|
|
83
|
+
isExportable: true,
|
|
84
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
85
|
+
name,
|
|
86
|
+
export: true,
|
|
87
|
+
params: params.toConstructor(),
|
|
88
|
+
returnType,
|
|
89
|
+
children: dataReturnType === "data" ? `return cy.request<${typeSchemas.response.name}>({
|
|
90
|
+
${requestOptions.join(",\n ")}
|
|
91
|
+
}).then((res) => res.body)` : `return cy.request<${typeSchemas.response.name}>({
|
|
92
|
+
${requestOptions.join(",\n ")}
|
|
93
|
+
})`
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
Request.getParams = getParams;
|
|
98
|
+
|
|
99
|
+
//#endregion
|
|
100
|
+
export { Request as t };
|
|
101
|
+
//# sourceMappingURL=components-CKNcdnr_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-CKNcdnr_.js","names":["requestOptions: string[]"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n method: HttpMethod\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {\n const path = new URLPath(url, { casing: paramsCasing })\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n // Build the URL template string - this will convert /pets/:petId to /pets/${petId}\n const urlTemplate = path.toTemplateString({ prefix: baseURL })\n\n // Build request options object\n const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]\n\n // Add query params if they exist\n if (typeSchemas.queryParams?.name) {\n requestOptions.push('qs: params')\n }\n\n // Add headers if they exist\n if (typeSchemas.headerParams?.name) {\n requestOptions.push('headers')\n }\n\n // Add body if request schema exists\n if (typeSchemas.request?.name) {\n requestOptions.push('body: data')\n }\n\n // Spread additional Cypress options\n requestOptions.push('...options')\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data'\n ? `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n\nRequest.getParams = getParams\n"],"mappings":";;;;;;;AA8BA,SAAS,UAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAO,eAAe,QAAQ;EAC5B,MAAM;GACJ,MAAM;GACN,UAAU;IACR,GAAG,cAAc,YAAY,YAAY;KAAE,OAAO;KAAM,QAAQ;KAAc,CAAC;IAC/E,MAAM,YAAY,SAAS,OACvB;KACE,MAAM,YAAY,SAAS;KAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;KAClD,GACD;IACJ,QAAQ,YAAY,aAAa,OAC7B;KACE,MAAM,YAAY,aAAa;KAC/B,UAAU,WAAW,YAAY,aAAa,OAAO;KACtD,GACD;IACJ,SAAS,YAAY,cAAc,OAC/B;KACE,MAAM,YAAY,cAAc;KAChC,UAAU,WAAW,YAAY,cAAc,OAAO;KACvD,GACD;IACL;GACF;EACD,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;AAGJ,QAAO,eAAe,QAAQ;EAC5B,YAAY,YAAY,YAAY,OAChC;GACE,MAAM,mBAAmB,WAAW,WAAW;GAC/C,UAAU,cAAc,YAAY,YAAY;IAAE,OAAO;IAAM,QAAQ;IAAc,CAAC;GACtF,UAAU,WAAW,YAAY,YAAY,OAAO;GACrD,GACD;EACJ,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;GAClD,GACD;EACJ,QAAQ,YAAY,aAAa,OAC7B;GACE,MAAM,YAAY,aAAa;GAC/B,UAAU,WAAW,YAAY,aAAa,OAAO;GACtD,GACD;EACJ,SAAS,YAAY,cAAc,OAC/B;GACE,MAAM,YAAY,cAAc;GAChC,UAAU,WAAW,YAAY,cAAc,OAAO;GACvD,GACD;EACJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;;AAGJ,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,QAAQ,YAAY,cAAc,kBAAmC;CACnJ,MAAM,OAAO,IAAI,QAAQ,KAAK,EAAE,QAAQ,cAAc,CAAC;CAEvD,MAAM,SAAS,UAAU;EAAE;EAAY;EAAc;EAAgB;EAAa,CAAC;CAEnF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAGlJ,MAAM,cAAc,KAAK,iBAAiB,EAAE,QAAQ,SAAS,CAAC;CAG9D,MAAMA,iBAA2B,CAAC,YAAY,OAAO,IAAI,QAAQ,cAAc;AAG/E,KAAI,YAAY,aAAa,KAC3B,gBAAe,KAAK,aAAa;AAInC,KAAI,YAAY,cAAc,KAC5B,gBAAe,KAAK,UAAU;AAIhC,KAAI,YAAY,SAAS,KACvB,gBAAe,KAAK,aAAa;AAInC,gBAAe,KAAK,aAAa;AAEjC,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,oBAAC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;aACtE,mBAAmB,SAChB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;8BAErB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;;IAEhB;GACC;;AAIlB,QAAQ,YAAY"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const require_index = require('./index.cjs');
|
|
2
|
+
let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
3
|
+
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
4
|
+
let _kubb_core_utils = require("@kubb/core/utils");
|
|
5
|
+
let _kubb_oas = require("@kubb/oas");
|
|
6
|
+
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
7
|
+
|
|
8
|
+
//#region src/components/Request.tsx
|
|
9
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
10
|
+
if (paramsType === "object") return _kubb_react_fabric.FunctionParams.factory({
|
|
11
|
+
data: {
|
|
12
|
+
mode: "object",
|
|
13
|
+
children: {
|
|
14
|
+
...(0, _kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
15
|
+
typed: true,
|
|
16
|
+
casing: paramsCasing
|
|
17
|
+
}),
|
|
18
|
+
data: typeSchemas.request?.name ? {
|
|
19
|
+
type: typeSchemas.request?.name,
|
|
20
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
21
|
+
} : void 0,
|
|
22
|
+
params: typeSchemas.queryParams?.name ? {
|
|
23
|
+
type: typeSchemas.queryParams?.name,
|
|
24
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
25
|
+
} : void 0,
|
|
26
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
27
|
+
type: typeSchemas.headerParams?.name,
|
|
28
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
29
|
+
} : void 0
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
options: {
|
|
33
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
34
|
+
optional: true,
|
|
35
|
+
default: "{}"
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return _kubb_react_fabric.FunctionParams.factory({
|
|
39
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
40
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
41
|
+
children: (0, _kubb_plugin_oas_utils.getPathParams)(typeSchemas.pathParams, {
|
|
42
|
+
typed: true,
|
|
43
|
+
casing: paramsCasing
|
|
44
|
+
}),
|
|
45
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.pathParams?.schema)
|
|
46
|
+
} : void 0,
|
|
47
|
+
data: typeSchemas.request?.name ? {
|
|
48
|
+
type: typeSchemas.request?.name,
|
|
49
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
50
|
+
} : void 0,
|
|
51
|
+
params: typeSchemas.queryParams?.name ? {
|
|
52
|
+
type: typeSchemas.queryParams?.name,
|
|
53
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.queryParams?.schema)
|
|
54
|
+
} : void 0,
|
|
55
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
56
|
+
type: typeSchemas.headerParams?.name,
|
|
57
|
+
optional: (0, _kubb_oas.isOptional)(typeSchemas.headerParams?.schema)
|
|
58
|
+
} : void 0,
|
|
59
|
+
options: {
|
|
60
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
61
|
+
optional: true,
|
|
62
|
+
default: "{}"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }) {
|
|
67
|
+
const path = new _kubb_core_utils.URLPath(url, { casing: paramsCasing });
|
|
68
|
+
const params = getParams({
|
|
69
|
+
paramsType,
|
|
70
|
+
paramsCasing,
|
|
71
|
+
pathParamsType,
|
|
72
|
+
typeSchemas
|
|
73
|
+
});
|
|
74
|
+
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`;
|
|
75
|
+
const urlTemplate = path.toTemplateString({ prefix: baseURL });
|
|
76
|
+
const requestOptions = [`method: '${method}'`, `url: ${urlTemplate}`];
|
|
77
|
+
if (typeSchemas.queryParams?.name) requestOptions.push("qs: params");
|
|
78
|
+
if (typeSchemas.headerParams?.name) requestOptions.push("headers");
|
|
79
|
+
if (typeSchemas.request?.name) requestOptions.push("body: data");
|
|
80
|
+
requestOptions.push("...options");
|
|
81
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
82
|
+
name,
|
|
83
|
+
isIndexable: true,
|
|
84
|
+
isExportable: true,
|
|
85
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Function, {
|
|
86
|
+
name,
|
|
87
|
+
export: true,
|
|
88
|
+
params: params.toConstructor(),
|
|
89
|
+
returnType,
|
|
90
|
+
children: dataReturnType === "data" ? `return cy.request<${typeSchemas.response.name}>({
|
|
91
|
+
${requestOptions.join(",\n ")}
|
|
92
|
+
}).then((res) => res.body)` : `return cy.request<${typeSchemas.response.name}>({
|
|
93
|
+
${requestOptions.join(",\n ")}
|
|
94
|
+
})`
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
Request.getParams = getParams;
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
Object.defineProperty(exports, 'Request', {
|
|
102
|
+
enumerable: true,
|
|
103
|
+
get: function () {
|
|
104
|
+
return Request;
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
//# sourceMappingURL=components-UBGR5HIj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-UBGR5HIj.cjs","names":["FunctionParams","URLPath","requestOptions: string[]","File","Function"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n method: HttpMethod\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']\n paramsType: PluginCypress['resolvedOptions']['paramsType']\n pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {\n const path = new URLPath(url, { casing: paramsCasing })\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n // Build the URL template string - this will convert /pets/:petId to /pets/${petId}\n const urlTemplate = path.toTemplateString({ prefix: baseURL })\n\n // Build request options object\n const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]\n\n // Add query params if they exist\n if (typeSchemas.queryParams?.name) {\n requestOptions.push('qs: params')\n }\n\n // Add headers if they exist\n if (typeSchemas.headerParams?.name) {\n requestOptions.push('headers')\n }\n\n // Add body if request schema exists\n if (typeSchemas.request?.name) {\n requestOptions.push('body: data')\n }\n\n // Spread additional Cypress options\n requestOptions.push('...options')\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data'\n ? `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n}).then((res) => res.body)`\n : `return cy.request<${typeSchemas.response.name}>({\n ${requestOptions.join(',\\n ')}\n})`}\n </Function>\n </File.Source>\n )\n}\n\nRequest.getParams = getParams\n"],"mappings":";;;;;;;;AA8BA,SAAS,UAAU,EAAE,YAAY,cAAc,gBAAgB,eAA+B;AAC5F,KAAI,eAAe,SACjB,QAAOA,kCAAe,QAAQ;EAC5B,MAAM;GACJ,MAAM;GACN,UAAU;IACR,6CAAiB,YAAY,YAAY;KAAE,OAAO;KAAM,QAAQ;KAAc,CAAC;IAC/E,MAAM,YAAY,SAAS,OACvB;KACE,MAAM,YAAY,SAAS;KAC3B,oCAAqB,YAAY,SAAS,OAAO;KAClD,GACD;IACJ,QAAQ,YAAY,aAAa,OAC7B;KACE,MAAM,YAAY,aAAa;KAC/B,oCAAqB,YAAY,aAAa,OAAO;KACtD,GACD;IACJ,SAAS,YAAY,cAAc,OAC/B;KACE,MAAM,YAAY,cAAc;KAChC,oCAAqB,YAAY,cAAc,OAAO;KACvD,GACD;IACL;GACF;EACD,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;AAGJ,QAAOA,kCAAe,QAAQ;EAC5B,YAAY,YAAY,YAAY,OAChC;GACE,MAAM,mBAAmB,WAAW,WAAW;GAC/C,oDAAwB,YAAY,YAAY;IAAE,OAAO;IAAM,QAAQ;IAAc,CAAC;GACtF,oCAAqB,YAAY,YAAY,OAAO;GACrD,GACD;EACJ,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,oCAAqB,YAAY,SAAS,OAAO;GAClD,GACD;EACJ,QAAQ,YAAY,aAAa,OAC7B;GACE,MAAM,YAAY,aAAa;GAC/B,oCAAqB,YAAY,aAAa,OAAO;GACtD,GACD;EACJ,SAAS,YAAY,cAAc,OAC/B;GACE,MAAM,YAAY,cAAc;GAChC,oCAAqB,YAAY,cAAc,OAAO;GACvD,GACD;EACJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;;AAGJ,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,QAAQ,YAAY,cAAc,kBAAmC;CACnJ,MAAM,OAAO,IAAIC,yBAAQ,KAAK,EAAE,QAAQ,cAAc,CAAC;CAEvD,MAAM,SAAS,UAAU;EAAE;EAAY;EAAc;EAAgB;EAAa,CAAC;CAEnF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAGlJ,MAAM,cAAc,KAAK,iBAAiB,EAAE,QAAQ,SAAS,CAAC;CAG9D,MAAMC,iBAA2B,CAAC,YAAY,OAAO,IAAI,QAAQ,cAAc;AAG/E,KAAI,YAAY,aAAa,KAC3B,gBAAe,KAAK,aAAa;AAInC,KAAI,YAAY,cAAc,KAC5B,gBAAe,KAAK,UAAU;AAIhC,KAAI,YAAY,SAAS,KACvB,gBAAe,KAAK,aAAa;AAInC,gBAAe,KAAK,aAAa;AAEjC,QACE,wDAACC,wBAAK;EAAa;EAAM;EAAY;YACnC,wDAACC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;aACtE,mBAAmB,SAChB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;8BAErB,qBAAqB,YAAY,SAAS,KAAK;IACvD,eAAe,KAAK,QAAQ,CAAC;;IAEhB;GACC;;AAIlB,QAAQ,YAAY"}
|
package/dist/components.cjs
CHANGED
package/dist/components.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as OperationSchemas, n as PluginCypress, o as HttpMethod } from "./types-
|
|
1
|
+
import { i as OperationSchemas, n as PluginCypress, o as HttpMethod } from "./types-CYBedFjk.cjs";
|
|
2
|
+
import { FunctionParams } from "@kubb/react-fabric";
|
|
2
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
4
|
|
|
4
5
|
//#region src/components/Request.d.ts
|
|
@@ -11,16 +12,36 @@ type Props = {
|
|
|
11
12
|
url: string;
|
|
12
13
|
baseURL: string | undefined;
|
|
13
14
|
dataReturnType: PluginCypress['resolvedOptions']['dataReturnType'];
|
|
15
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
16
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
17
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
14
18
|
method: HttpMethod;
|
|
15
19
|
};
|
|
20
|
+
type GetParamsProps = {
|
|
21
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
22
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
23
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
24
|
+
typeSchemas: OperationSchemas;
|
|
25
|
+
};
|
|
16
26
|
declare function Request({
|
|
17
27
|
baseURL,
|
|
18
28
|
name,
|
|
19
29
|
dataReturnType,
|
|
20
30
|
typeSchemas,
|
|
21
31
|
url,
|
|
22
|
-
method
|
|
32
|
+
method,
|
|
33
|
+
paramsType,
|
|
34
|
+
paramsCasing,
|
|
35
|
+
pathParamsType
|
|
23
36
|
}: Props): KubbNode;
|
|
37
|
+
declare namespace Request {
|
|
38
|
+
var getParams: ({
|
|
39
|
+
paramsType,
|
|
40
|
+
paramsCasing,
|
|
41
|
+
pathParamsType,
|
|
42
|
+
typeSchemas
|
|
43
|
+
}: GetParamsProps) => FunctionParams;
|
|
44
|
+
}
|
|
24
45
|
//#endregion
|
|
25
46
|
export { Request };
|
|
26
47
|
//# sourceMappingURL=components.d.cts.map
|
package/dist/components.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { i as OperationSchemas, n as PluginCypress, o as HttpMethod } from "./types-
|
|
1
|
+
import { i as OperationSchemas, n as PluginCypress, o as HttpMethod } from "./types-By2wx7F-.js";
|
|
2
|
+
import { FunctionParams } from "@kubb/react-fabric";
|
|
2
3
|
import { KubbNode } from "@kubb/react-fabric/types";
|
|
3
4
|
|
|
4
5
|
//#region src/components/Request.d.ts
|
|
@@ -11,16 +12,36 @@ type Props = {
|
|
|
11
12
|
url: string;
|
|
12
13
|
baseURL: string | undefined;
|
|
13
14
|
dataReturnType: PluginCypress['resolvedOptions']['dataReturnType'];
|
|
15
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
16
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
17
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
14
18
|
method: HttpMethod;
|
|
15
19
|
};
|
|
20
|
+
type GetParamsProps = {
|
|
21
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing'];
|
|
22
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType'];
|
|
23
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType'];
|
|
24
|
+
typeSchemas: OperationSchemas;
|
|
25
|
+
};
|
|
16
26
|
declare function Request({
|
|
17
27
|
baseURL,
|
|
18
28
|
name,
|
|
19
29
|
dataReturnType,
|
|
20
30
|
typeSchemas,
|
|
21
31
|
url,
|
|
22
|
-
method
|
|
32
|
+
method,
|
|
33
|
+
paramsType,
|
|
34
|
+
paramsCasing,
|
|
35
|
+
pathParamsType
|
|
23
36
|
}: Props): KubbNode;
|
|
37
|
+
declare namespace Request {
|
|
38
|
+
var getParams: ({
|
|
39
|
+
paramsType,
|
|
40
|
+
paramsCasing,
|
|
41
|
+
pathParamsType,
|
|
42
|
+
typeSchemas
|
|
43
|
+
}: GetParamsProps) => FunctionParams;
|
|
44
|
+
}
|
|
24
45
|
//#endregion
|
|
25
46
|
export { Request };
|
|
26
47
|
//# sourceMappingURL=components.d.ts.map
|
package/dist/components.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-UBGR5HIj.cjs');
|
|
2
2
|
const require_index = require('./index.cjs');
|
|
3
3
|
let _kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
4
4
|
let _kubb_core_hooks = require("@kubb/core/hooks");
|
|
5
|
-
let _kubb_core_utils = require("@kubb/core/utils");
|
|
6
5
|
let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
7
6
|
let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
8
7
|
let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
@@ -13,7 +12,7 @@ let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
|
13
12
|
const cypressGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
14
13
|
name: "cypress",
|
|
15
14
|
Operation({ operation, generator, plugin }) {
|
|
16
|
-
const { options: { output, baseURL, dataReturnType } } = plugin;
|
|
15
|
+
const { options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType } } = plugin;
|
|
17
16
|
const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
|
|
18
17
|
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
19
18
|
const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
@@ -56,10 +55,13 @@ const cypressGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
56
55
|
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Request, {
|
|
57
56
|
name: request.name,
|
|
58
57
|
dataReturnType,
|
|
58
|
+
paramsCasing,
|
|
59
|
+
paramsType,
|
|
60
|
+
pathParamsType,
|
|
59
61
|
typeSchemas: type.schemas,
|
|
60
62
|
method: operation.method,
|
|
61
63
|
baseURL,
|
|
62
|
-
url:
|
|
64
|
+
url: operation.path
|
|
63
65
|
})]
|
|
64
66
|
});
|
|
65
67
|
}
|
|
@@ -72,4 +74,4 @@ Object.defineProperty(exports, 'cypressGenerator', {
|
|
|
72
74
|
return cypressGenerator;
|
|
73
75
|
}
|
|
74
76
|
});
|
|
75
|
-
//# sourceMappingURL=generators-
|
|
77
|
+
//# sourceMappingURL=generators-Ct9I-qNg.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-Ct9I-qNg.cjs","names":["pluginTsName","File","Request"],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={operation.path}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AASA,MAAa,yEAAuD;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,gBAAgB,cAAc,YAAY,qBACpE;EACJ,MAAM,wDAAkC;EAExC,MAAM,0CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,4DAAgC,UAAU;EAEvE,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,6BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,6BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,yDAACC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,8CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,8CAAkB;IAAE;IAAK;IAAQ,CAAC;cAElC,wDAACA,wBAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,wDAACC;IACC,MAAM,QAAQ;IACE;IACF;IACF;IACI;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,UAAU;KACf;IACG;;CAGZ,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as Request } from "./components-
|
|
1
|
+
import { t as Request } from "./components-CKNcdnr_.js";
|
|
2
2
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
3
3
|
import { usePluginManager } from "@kubb/core/hooks";
|
|
4
|
-
import { URLPath } from "@kubb/core/utils";
|
|
5
4
|
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
6
5
|
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
7
6
|
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
@@ -12,7 +11,7 @@ import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
|
12
11
|
const cypressGenerator = createReactGenerator({
|
|
13
12
|
name: "cypress",
|
|
14
13
|
Operation({ operation, generator, plugin }) {
|
|
15
|
-
const { options: { output, baseURL, dataReturnType } } = plugin;
|
|
14
|
+
const { options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType } } = plugin;
|
|
16
15
|
const pluginManager = usePluginManager();
|
|
17
16
|
const oas = useOas();
|
|
18
17
|
const { getSchemas, getName, getFile } = useOperationManager(generator);
|
|
@@ -55,10 +54,13 @@ const cypressGenerator = createReactGenerator({
|
|
|
55
54
|
}), /* @__PURE__ */ jsx(Request, {
|
|
56
55
|
name: request.name,
|
|
57
56
|
dataReturnType,
|
|
57
|
+
paramsCasing,
|
|
58
|
+
paramsType,
|
|
59
|
+
pathParamsType,
|
|
58
60
|
typeSchemas: type.schemas,
|
|
59
61
|
method: operation.method,
|
|
60
62
|
baseURL,
|
|
61
|
-
url:
|
|
63
|
+
url: operation.path
|
|
62
64
|
})]
|
|
63
65
|
});
|
|
64
66
|
}
|
|
@@ -66,4 +68,4 @@ const cypressGenerator = createReactGenerator({
|
|
|
66
68
|
|
|
67
69
|
//#endregion
|
|
68
70
|
export { cypressGenerator as t };
|
|
69
|
-
//# sourceMappingURL=generators-
|
|
71
|
+
//# sourceMappingURL=generators-D_AameR6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-D_AameR6.js","names":[],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n paramsCasing={paramsCasing}\n paramsType={paramsType}\n pathParamsType={pathParamsType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={operation.path}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;AASA,MAAa,mBAAmB,qBAAoC;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,gBAAgB,cAAc,YAAY,qBACpE;EACJ,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,oBAAoB,UAAU;EAEvE,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,qBAAC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;cAElC,oBAAC,KAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,oBAAC;IACC,MAAM,QAAQ;IACE;IACF;IACF;IACI;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,UAAU;KACf;IACG;;CAGZ,CAAC"}
|
package/dist/generators.cjs
CHANGED
package/dist/generators.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginCypress, r as ReactGenerator } from "./types-
|
|
1
|
+
import { n as PluginCypress, r as ReactGenerator } from "./types-CYBedFjk.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/cypressGenerator.d.ts
|
|
4
4
|
declare const cypressGenerator: ReactGenerator<PluginCypress>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PluginCypress, r as ReactGenerator } from "./types-
|
|
1
|
+
import { n as PluginCypress, r as ReactGenerator } from "./types-By2wx7F-.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generators/cypressGenerator.d.ts
|
|
4
4
|
declare const cypressGenerator: ReactGenerator<PluginCypress>;
|
package/dist/generators.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_generators = require('./generators-
|
|
28
|
+
const require_generators = require('./generators-Ct9I-qNg.cjs');
|
|
29
29
|
let node_path = require("node:path");
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
31
|
let _kubb_core = require("@kubb/core");
|
|
@@ -39,14 +39,17 @@ const pluginCypress = (0, _kubb_core.definePlugin)((options) => {
|
|
|
39
39
|
const { output = {
|
|
40
40
|
path: "cypress",
|
|
41
41
|
barrelType: "named"
|
|
42
|
-
}, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [require_generators.cypressGenerator].filter(Boolean), contentType, baseURL } = options;
|
|
42
|
+
}, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [require_generators.cypressGenerator].filter(Boolean), contentType, baseURL, paramsCasing = "camelcase", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline" } = options;
|
|
43
43
|
return {
|
|
44
44
|
name: pluginCypressName,
|
|
45
45
|
options: {
|
|
46
46
|
output,
|
|
47
47
|
dataReturnType,
|
|
48
48
|
group,
|
|
49
|
-
baseURL
|
|
49
|
+
baseURL,
|
|
50
|
+
paramsCasing,
|
|
51
|
+
paramsType,
|
|
52
|
+
pathParamsType
|
|
50
53
|
},
|
|
51
54
|
pre: [_kubb_plugin_oas.pluginOasName, _kubb_plugin_ts.pluginTsName].filter(Boolean),
|
|
52
55
|
resolvePath(baseName, pathMode, options$1) {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa,8CAA6C,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,oCAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["cypressGenerator","pluginOasName","pluginTsName","path","options","groupName: Group['name']","OperationGenerator"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n paramsCasing = 'camelcase',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n\n paramsCasing,\n paramsType,\n pathParamsType,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa,8CAA6C,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAACA,oCAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,SACA,eAAe,aACf,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,aAC9E;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GAEA;GACA;GACA;GACD;EACD,KAAK,CAACC,gCAAeC,6BAAa,CAAC,OAAO,QAAQ;EAClD,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAOC,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,oCAAoBA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAOA,kBAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUC,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,0CAAa,IAAI,MAAM,CAAC;;AAGrC,WAAOF,kBAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASC,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAOD,kBAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,sDAAyB,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAOA,kBAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,+BAAeA,kBAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,QAAQ,MAba,IAAIG,oCAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,qCAAqB,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-CYBedFjk.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginCypressName = "plugin-cypress";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-
|
|
1
|
+
import { a as UserPluginWithLifeCycle, n as PluginCypress, t as Options } from "./types-By2wx7F-.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin.d.ts
|
|
4
4
|
declare const pluginCypressName = "plugin-cypress";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as cypressGenerator } from "./generators-
|
|
1
|
+
import { t as cypressGenerator } from "./generators-D_AameR6.js";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
4
4
|
import { camelCase } from "@kubb/core/transformers";
|
|
@@ -11,14 +11,17 @@ const pluginCypress = definePlugin((options) => {
|
|
|
11
11
|
const { output = {
|
|
12
12
|
path: "cypress",
|
|
13
13
|
barrelType: "named"
|
|
14
|
-
}, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [cypressGenerator].filter(Boolean), contentType, baseURL } = options;
|
|
14
|
+
}, group, dataReturnType = "data", exclude = [], include, override = [], transformers = {}, generators = [cypressGenerator].filter(Boolean), contentType, baseURL, paramsCasing = "camelcase", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline" } = options;
|
|
15
15
|
return {
|
|
16
16
|
name: pluginCypressName,
|
|
17
17
|
options: {
|
|
18
18
|
output,
|
|
19
19
|
dataReturnType,
|
|
20
20
|
group,
|
|
21
|
-
baseURL
|
|
21
|
+
baseURL,
|
|
22
|
+
paramsCasing,
|
|
23
|
+
paramsType,
|
|
24
|
+
pathParamsType
|
|
22
25
|
},
|
|
23
26
|
pre: [pluginOasName, pluginTsName].filter(Boolean),
|
|
24
27
|
resolvePath(baseName, pathMode, options$1) {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa,gBAAgB,cAA6B,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAAC,iBAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,
|
|
1
|
+
{"version":3,"file":"index.js","names":["options","groupName: Group['name']"],"sources":["../src/plugin.ts"],"sourcesContent":["import path from 'node:path'\nimport { definePlugin, type Group, getBarrelFiles, getMode } from '@kubb/core'\nimport { camelCase } from '@kubb/core/transformers'\nimport { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { cypressGenerator } from './generators'\nimport type { PluginCypress } from './types.ts'\n\nexport const pluginCypressName = 'plugin-cypress' satisfies PluginCypress['name']\n\nexport const pluginCypress = definePlugin<PluginCypress>((options) => {\n const {\n output = { path: 'cypress', barrelType: 'named' },\n group,\n dataReturnType = 'data',\n exclude = [],\n include,\n override = [],\n transformers = {},\n generators = [cypressGenerator].filter(Boolean),\n contentType,\n baseURL,\n paramsCasing = 'camelcase',\n paramsType = 'inline',\n pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',\n } = options\n\n return {\n name: pluginCypressName,\n options: {\n output,\n dataReturnType,\n group,\n baseURL,\n\n paramsCasing,\n paramsType,\n pathParamsType,\n },\n pre: [pluginOasName, pluginTsName].filter(Boolean),\n resolvePath(baseName, pathMode, options) {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = pathMode ?? getMode(path.resolve(root, output.path))\n\n if (mode === 'single') {\n /**\n * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend\n * Other plugins then need to call addOrAppend instead of just add from the fileManager class\n */\n return path.resolve(root, output.path)\n }\n\n if (group && (options?.group?.path || options?.group?.tag)) {\n const groupName: Group['name'] = group?.name\n ? group.name\n : (ctx) => {\n if (group?.type === 'path') {\n return `${ctx.group.split('/')[1]}`\n }\n return `${camelCase(ctx.group)}Requests`\n }\n\n return path.resolve(\n root,\n output.path,\n groupName({\n group: group.type === 'path' ? options.group.path! : options.group.tag!,\n }),\n baseName,\n )\n }\n\n return path.resolve(root, output.path, baseName)\n },\n resolveName(name, type) {\n const resolvedName = camelCase(name, {\n isFile: type === 'file',\n })\n\n if (type) {\n return transformers?.name?.(resolvedName, type) || resolvedName\n }\n\n return resolvedName\n },\n async install() {\n const root = path.resolve(this.config.root, this.config.output.path)\n const mode = getMode(path.resolve(root, output.path))\n const oas = await this.getOas()\n\n const operationGenerator = new OperationGenerator(this.plugin.options, {\n fabric: this.fabric,\n oas,\n pluginManager: this.pluginManager,\n events: this.events,\n plugin: this.plugin,\n contentType,\n exclude,\n include,\n override,\n mode,\n })\n\n const files = await operationGenerator.build(...generators)\n await this.upsertFile(...files)\n\n const barrelFiles = await getBarrelFiles(this.fabric.files, {\n type: output.barrelType ?? 'named',\n root,\n output,\n meta: {\n pluginKey: this.plugin.key,\n },\n })\n\n await this.upsertFile(...barrelFiles)\n },\n }\n})\n"],"mappings":";;;;;;;;AAQA,MAAa,oBAAoB;AAEjC,MAAa,gBAAgB,cAA6B,YAAY;CACpE,MAAM,EACJ,SAAS;EAAE,MAAM;EAAW,YAAY;EAAS,EACjD,OACA,iBAAiB,QACjB,UAAU,EAAE,EACZ,SACA,WAAW,EAAE,EACb,eAAe,EAAE,EACjB,aAAa,CAAC,iBAAiB,CAAC,OAAO,QAAQ,EAC/C,aACA,SACA,eAAe,aACf,aAAa,UACb,iBAAiB,eAAe,WAAW,WAAW,QAAQ,kBAAkB,aAC9E;AAEJ,QAAO;EACL,MAAM;EACN,SAAS;GACP;GACA;GACA;GACA;GAEA;GACA;GACA;GACD;EACD,KAAK,CAAC,eAAe,aAAa,CAAC,OAAO,QAAQ;EAClD,YAAY,UAAU,UAAU,WAAS;GACvC,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;AAGpE,QAFa,YAAY,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC,MAEpD;;;;;AAKX,UAAO,KAAK,QAAQ,MAAM,OAAO,KAAK;AAGxC,OAAI,UAAUA,WAAS,OAAO,QAAQA,WAAS,OAAO,MAAM;IAC1D,MAAMC,YAA2B,OAAO,OACpC,MAAM,QACL,QAAQ;AACP,SAAI,OAAO,SAAS,OAClB,QAAO,GAAG,IAAI,MAAM,MAAM,IAAI,CAAC;AAEjC,YAAO,GAAG,UAAU,IAAI,MAAM,CAAC;;AAGrC,WAAO,KAAK,QACV,MACA,OAAO,MACP,UAAU,EACR,OAAO,MAAM,SAAS,SAASD,UAAQ,MAAM,OAAQA,UAAQ,MAAM,KACpE,CAAC,EACF,SACD;;AAGH,UAAO,KAAK,QAAQ,MAAM,OAAO,MAAM,SAAS;;EAElD,YAAY,MAAM,MAAM;GACtB,MAAM,eAAe,UAAU,MAAM,EACnC,QAAQ,SAAS,QAClB,CAAC;AAEF,OAAI,KACF,QAAO,cAAc,OAAO,cAAc,KAAK,IAAI;AAGrD,UAAO;;EAET,MAAM,UAAU;GACd,MAAM,OAAO,KAAK,QAAQ,KAAK,OAAO,MAAM,KAAK,OAAO,OAAO,KAAK;GACpE,MAAM,OAAO,QAAQ,KAAK,QAAQ,MAAM,OAAO,KAAK,CAAC;GACrD,MAAM,MAAM,MAAM,KAAK,QAAQ;GAe/B,MAAM,QAAQ,MAba,IAAI,mBAAmB,KAAK,OAAO,SAAS;IACrE,QAAQ,KAAK;IACb;IACA,eAAe,KAAK;IACpB,QAAQ,KAAK;IACb,QAAQ,KAAK;IACb;IACA;IACA;IACA;IACA;IACD,CAAC,CAEqC,MAAM,GAAG,WAAW;AAC3D,SAAM,KAAK,WAAW,GAAG,MAAM;GAE/B,MAAM,cAAc,MAAM,eAAe,KAAK,OAAO,OAAO;IAC1D,MAAM,OAAO,cAAc;IAC3B;IACA;IACA,MAAM,EACJ,WAAW,KAAK,OAAO,KACxB;IACF,CAAC;AAEF,SAAM,KAAK,WAAW,GAAG,YAAY;;EAExC;EACD"}
|
|
@@ -1170,6 +1170,25 @@ type Options = {
|
|
|
1170
1170
|
* @default 'data'
|
|
1171
1171
|
*/
|
|
1172
1172
|
dataReturnType?: 'data' | 'full';
|
|
1173
|
+
/**
|
|
1174
|
+
* How to style your params, by default no casing is applied
|
|
1175
|
+
* - 'camelcase' will use camelcase for the params names
|
|
1176
|
+
*/
|
|
1177
|
+
paramsCasing?: 'camelcase';
|
|
1178
|
+
/**
|
|
1179
|
+
* How to pass your params
|
|
1180
|
+
* - 'object' will return the params and pathParams as an object.
|
|
1181
|
+
* - 'inline' will return the params as comma separated params.
|
|
1182
|
+
* @default 'inline'
|
|
1183
|
+
*/
|
|
1184
|
+
paramsType?: 'object' | 'inline';
|
|
1185
|
+
/**
|
|
1186
|
+
* How to pass your pathParams.
|
|
1187
|
+
* - 'object' will return the pathParams as an object.
|
|
1188
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
1189
|
+
* @default 'inline'
|
|
1190
|
+
*/
|
|
1191
|
+
pathParamsType?: 'object' | 'inline';
|
|
1173
1192
|
baseURL?: string;
|
|
1174
1193
|
/**
|
|
1175
1194
|
* Group the Cypress requests based on the provided name.
|
|
@@ -1203,8 +1222,11 @@ type ResolvedOptions = {
|
|
|
1203
1222
|
group: Options['group'];
|
|
1204
1223
|
baseURL: Options['baseURL'] | undefined;
|
|
1205
1224
|
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
1225
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
1226
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
1227
|
+
paramsCasing: Options['paramsCasing'];
|
|
1206
1228
|
};
|
|
1207
1229
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1208
1230
|
//#endregion
|
|
1209
1231
|
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginCypress as n, HttpMethod as o, ReactGenerator as r, Options as t };
|
|
1210
|
-
//# sourceMappingURL=types-
|
|
1232
|
+
//# sourceMappingURL=types-By2wx7F-.d.ts.map
|
|
@@ -1170,6 +1170,25 @@ type Options = {
|
|
|
1170
1170
|
* @default 'data'
|
|
1171
1171
|
*/
|
|
1172
1172
|
dataReturnType?: 'data' | 'full';
|
|
1173
|
+
/**
|
|
1174
|
+
* How to style your params, by default no casing is applied
|
|
1175
|
+
* - 'camelcase' will use camelcase for the params names
|
|
1176
|
+
*/
|
|
1177
|
+
paramsCasing?: 'camelcase';
|
|
1178
|
+
/**
|
|
1179
|
+
* How to pass your params
|
|
1180
|
+
* - 'object' will return the params and pathParams as an object.
|
|
1181
|
+
* - 'inline' will return the params as comma separated params.
|
|
1182
|
+
* @default 'inline'
|
|
1183
|
+
*/
|
|
1184
|
+
paramsType?: 'object' | 'inline';
|
|
1185
|
+
/**
|
|
1186
|
+
* How to pass your pathParams.
|
|
1187
|
+
* - 'object' will return the pathParams as an object.
|
|
1188
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
1189
|
+
* @default 'inline'
|
|
1190
|
+
*/
|
|
1191
|
+
pathParamsType?: 'object' | 'inline';
|
|
1173
1192
|
baseURL?: string;
|
|
1174
1193
|
/**
|
|
1175
1194
|
* Group the Cypress requests based on the provided name.
|
|
@@ -1203,8 +1222,11 @@ type ResolvedOptions = {
|
|
|
1203
1222
|
group: Options['group'];
|
|
1204
1223
|
baseURL: Options['baseURL'] | undefined;
|
|
1205
1224
|
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
1225
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
1226
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
1227
|
+
paramsCasing: Options['paramsCasing'];
|
|
1206
1228
|
};
|
|
1207
1229
|
type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
1208
1230
|
//#endregion
|
|
1209
1231
|
export { UserPluginWithLifeCycle as a, OperationSchemas as i, PluginCypress as n, HttpMethod as o, ReactGenerator as r, Options as t };
|
|
1210
|
-
//# sourceMappingURL=types-
|
|
1232
|
+
//# sourceMappingURL=types-CYBedFjk.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-cypress",
|
|
3
|
-
"version": "4.12.
|
|
3
|
+
"version": "4.12.6",
|
|
4
4
|
"description": "Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cypress",
|
|
@@ -75,10 +75,10 @@
|
|
|
75
75
|
],
|
|
76
76
|
"dependencies": {
|
|
77
77
|
"@kubb/react-fabric": "0.7.1",
|
|
78
|
-
"@kubb/core": "4.12.
|
|
79
|
-
"@kubb/oas": "4.12.
|
|
80
|
-
"@kubb/plugin-oas": "4.12.
|
|
81
|
-
"@kubb/plugin-ts": "4.12.
|
|
78
|
+
"@kubb/core": "4.12.6",
|
|
79
|
+
"@kubb/oas": "4.12.6",
|
|
80
|
+
"@kubb/plugin-oas": "4.12.6",
|
|
81
|
+
"@kubb/plugin-ts": "4.12.6"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": ">=20"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { URLPath } from '@kubb/core/utils'
|
|
2
2
|
import { type HttpMethod, isOptional } from '@kubb/oas'
|
|
3
3
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
|
+
import { getPathParams } from '@kubb/plugin-oas/utils'
|
|
4
5
|
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
5
6
|
import type { KubbNode } from '@kubb/react-fabric/types'
|
|
6
7
|
import type { PluginCypress } from '../types.ts'
|
|
@@ -14,42 +15,133 @@ type Props = {
|
|
|
14
15
|
url: string
|
|
15
16
|
baseURL: string | undefined
|
|
16
17
|
dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']
|
|
18
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']
|
|
19
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType']
|
|
20
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']
|
|
17
21
|
method: HttpMethod
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
type GetParamsProps = {
|
|
25
|
+
paramsCasing: PluginCypress['resolvedOptions']['paramsCasing']
|
|
26
|
+
paramsType: PluginCypress['resolvedOptions']['paramsType']
|
|
27
|
+
pathParamsType: PluginCypress['resolvedOptions']['pathParamsType']
|
|
28
|
+
typeSchemas: OperationSchemas
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
32
|
+
if (paramsType === 'object') {
|
|
33
|
+
return FunctionParams.factory({
|
|
34
|
+
data: {
|
|
35
|
+
mode: 'object',
|
|
36
|
+
children: {
|
|
37
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
38
|
+
data: typeSchemas.request?.name
|
|
39
|
+
? {
|
|
40
|
+
type: typeSchemas.request?.name,
|
|
41
|
+
optional: isOptional(typeSchemas.request?.schema),
|
|
42
|
+
}
|
|
43
|
+
: undefined,
|
|
44
|
+
params: typeSchemas.queryParams?.name
|
|
45
|
+
? {
|
|
46
|
+
type: typeSchemas.queryParams?.name,
|
|
47
|
+
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
48
|
+
}
|
|
49
|
+
: undefined,
|
|
50
|
+
headers: typeSchemas.headerParams?.name
|
|
51
|
+
? {
|
|
52
|
+
type: typeSchemas.headerParams?.name,
|
|
53
|
+
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
54
|
+
}
|
|
55
|
+
: undefined,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
options: {
|
|
59
|
+
type: 'Partial<Cypress.RequestOptions>',
|
|
60
|
+
optional: true,
|
|
61
|
+
default: '{}',
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return FunctionParams.factory({
|
|
67
|
+
pathParams: typeSchemas.pathParams?.name
|
|
68
|
+
? {
|
|
69
|
+
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
70
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
71
|
+
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
72
|
+
}
|
|
73
|
+
: undefined,
|
|
22
74
|
data: typeSchemas.request?.name
|
|
23
75
|
? {
|
|
24
76
|
type: typeSchemas.request?.name,
|
|
25
77
|
optional: isOptional(typeSchemas.request?.schema),
|
|
26
78
|
}
|
|
27
79
|
: undefined,
|
|
28
|
-
|
|
80
|
+
params: typeSchemas.queryParams?.name
|
|
81
|
+
? {
|
|
82
|
+
type: typeSchemas.queryParams?.name,
|
|
83
|
+
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
84
|
+
}
|
|
85
|
+
: undefined,
|
|
86
|
+
headers: typeSchemas.headerParams?.name
|
|
87
|
+
? {
|
|
88
|
+
type: typeSchemas.headerParams?.name,
|
|
89
|
+
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
90
|
+
}
|
|
91
|
+
: undefined,
|
|
29
92
|
options: {
|
|
30
93
|
type: 'Partial<Cypress.RequestOptions>',
|
|
31
94
|
optional: true,
|
|
32
95
|
default: '{}',
|
|
33
96
|
},
|
|
34
97
|
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }: Props): KubbNode {
|
|
101
|
+
const path = new URLPath(url, { casing: paramsCasing })
|
|
102
|
+
|
|
103
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
35
104
|
|
|
36
105
|
const returnType =
|
|
37
106
|
dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`
|
|
38
107
|
|
|
39
|
-
|
|
108
|
+
// Build the URL template string - this will convert /pets/:petId to /pets/${petId}
|
|
109
|
+
const urlTemplate = path.toTemplateString({ prefix: baseURL })
|
|
110
|
+
|
|
111
|
+
// Build request options object
|
|
112
|
+
const requestOptions: string[] = [`method: '${method}'`, `url: ${urlTemplate}`]
|
|
113
|
+
|
|
114
|
+
// Add query params if they exist
|
|
115
|
+
if (typeSchemas.queryParams?.name) {
|
|
116
|
+
requestOptions.push('qs: params')
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Add headers if they exist
|
|
120
|
+
if (typeSchemas.headerParams?.name) {
|
|
121
|
+
requestOptions.push('headers')
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Add body if request schema exists
|
|
125
|
+
if (typeSchemas.request?.name) {
|
|
126
|
+
requestOptions.push('body: data')
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Spread additional Cypress options
|
|
130
|
+
requestOptions.push('...options')
|
|
40
131
|
|
|
41
132
|
return (
|
|
42
133
|
<File.Source name={name} isIndexable isExportable>
|
|
43
134
|
<Function name={name} export params={params.toConstructor()} returnType={returnType}>
|
|
44
|
-
{dataReturnType === 'data'
|
|
45
|
-
`return cy.request({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}
|
|
135
|
+
{dataReturnType === 'data'
|
|
136
|
+
? `return cy.request<${typeSchemas.response.name}>({
|
|
137
|
+
${requestOptions.join(',\n ')}
|
|
138
|
+
}).then((res) => res.body)`
|
|
139
|
+
: `return cy.request<${typeSchemas.response.name}>({
|
|
140
|
+
${requestOptions.join(',\n ')}
|
|
141
|
+
})`}
|
|
52
142
|
</Function>
|
|
53
143
|
</File.Source>
|
|
54
144
|
)
|
|
55
145
|
}
|
|
146
|
+
|
|
147
|
+
Request.getParams = getParams
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
export function createPets(data: CreatePetsMutationRequest, options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<CreatePetsMutationResponse> {
|
|
7
7
|
return cy
|
|
8
|
-
.request({
|
|
8
|
+
.request<CreatePetsMutationResponse>({
|
|
9
9
|
method: 'post',
|
|
10
10
|
url: `/pets`,
|
|
11
11
|
body: data,
|
|
12
12
|
...options,
|
|
13
13
|
})
|
|
14
|
-
.then((res
|
|
14
|
+
.then((res) => res.body)
|
|
15
15
|
}
|
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function
|
|
6
|
+
export function deletePet(
|
|
7
|
+
petId: DeletePetPathParams['petId'],
|
|
8
|
+
headers?: DeletePetHeaderParams,
|
|
9
|
+
options?: Partial<Cypress.RequestOptions>,
|
|
10
|
+
): Cypress.Chainable<DeletePetMutationResponse> {
|
|
7
11
|
return cy
|
|
8
|
-
.request({
|
|
12
|
+
.request<DeletePetMutationResponse>({
|
|
9
13
|
method: 'delete',
|
|
10
|
-
url: `/pets
|
|
11
|
-
|
|
14
|
+
url: `/pets/${petId}`,
|
|
15
|
+
headers,
|
|
12
16
|
...options,
|
|
13
17
|
})
|
|
14
|
-
.then((res
|
|
18
|
+
.then((res) => res.body)
|
|
15
19
|
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function listPets(options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<ListPetsQueryResponse> {
|
|
6
|
+
export function listPets(params?: ListPetsQueryParams, options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<ListPetsQueryResponse> {
|
|
7
7
|
return cy
|
|
8
|
-
.request({
|
|
8
|
+
.request<ListPetsQueryResponse>({
|
|
9
9
|
method: 'get',
|
|
10
10
|
url: `/pets`,
|
|
11
|
-
|
|
11
|
+
qs: params,
|
|
12
12
|
...options,
|
|
13
13
|
})
|
|
14
|
-
.then((res
|
|
14
|
+
.then((res) => res.body)
|
|
15
15
|
}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function listPets(options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<ListPetsQueryResponse> {
|
|
6
|
+
export function listPets(params?: ListPetsQueryParams, options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<ListPetsQueryResponse> {
|
|
7
7
|
return cy
|
|
8
|
-
.request({
|
|
8
|
+
.request<ListPetsQueryResponse>({
|
|
9
9
|
method: 'get',
|
|
10
10
|
url: `${123456}/pets`,
|
|
11
|
-
|
|
11
|
+
qs: params,
|
|
12
12
|
...options,
|
|
13
13
|
})
|
|
14
|
-
.then((res
|
|
14
|
+
.then((res) => res.body)
|
|
15
15
|
}
|
|
@@ -3,13 +3,12 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
export function showPetById(options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<ShowPetByIdQueryResponse> {
|
|
6
|
+
export function showPetById(petId: ShowPetByIdPathParams['petId'], options?: Partial<Cypress.RequestOptions>): Cypress.Chainable<ShowPetByIdQueryResponse> {
|
|
7
7
|
return cy
|
|
8
|
-
.request({
|
|
8
|
+
.request<ShowPetByIdQueryResponse>({
|
|
9
9
|
method: 'get',
|
|
10
|
-
url: `/pets
|
|
11
|
-
body: undefined,
|
|
10
|
+
url: `/pets/${petId}`,
|
|
12
11
|
...options,
|
|
13
12
|
})
|
|
14
|
-
.then((res
|
|
13
|
+
.then((res) => res.body)
|
|
15
14
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export function updatePet(
|
|
7
|
+
petId: UpdatePetPathParams['petId'],
|
|
8
|
+
data: UpdatePetMutationRequest,
|
|
9
|
+
options?: Partial<Cypress.RequestOptions>,
|
|
10
|
+
): Cypress.Chainable<UpdatePetMutationResponse> {
|
|
11
|
+
return cy
|
|
12
|
+
.request<UpdatePetMutationResponse>({
|
|
13
|
+
method: 'put',
|
|
14
|
+
url: `/pets/${petId}`,
|
|
15
|
+
body: data,
|
|
16
|
+
...options,
|
|
17
|
+
})
|
|
18
|
+
.then((res) => res.body)
|
|
19
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { usePluginManager } from '@kubb/core/hooks'
|
|
2
|
-
import { URLPath } from '@kubb/core/utils'
|
|
3
2
|
import { createReactGenerator } from '@kubb/plugin-oas/generators'
|
|
4
3
|
import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
5
4
|
import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
|
|
@@ -12,7 +11,7 @@ export const cypressGenerator = createReactGenerator<PluginCypress>({
|
|
|
12
11
|
name: 'cypress',
|
|
13
12
|
Operation({ operation, generator, plugin }) {
|
|
14
13
|
const {
|
|
15
|
-
options: { output, baseURL, dataReturnType },
|
|
14
|
+
options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType },
|
|
16
15
|
} = plugin
|
|
17
16
|
const pluginManager = usePluginManager()
|
|
18
17
|
|
|
@@ -53,10 +52,13 @@ export const cypressGenerator = createReactGenerator<PluginCypress>({
|
|
|
53
52
|
<Request
|
|
54
53
|
name={request.name}
|
|
55
54
|
dataReturnType={dataReturnType}
|
|
55
|
+
paramsCasing={paramsCasing}
|
|
56
|
+
paramsType={paramsType}
|
|
57
|
+
pathParamsType={pathParamsType}
|
|
56
58
|
typeSchemas={type.schemas}
|
|
57
59
|
method={operation.method}
|
|
58
60
|
baseURL={baseURL}
|
|
59
|
-
url={
|
|
61
|
+
url={operation.path}
|
|
60
62
|
/>
|
|
61
63
|
</File>
|
|
62
64
|
)
|
package/src/plugin.ts
CHANGED
|
@@ -20,6 +20,9 @@ export const pluginCypress = definePlugin<PluginCypress>((options) => {
|
|
|
20
20
|
generators = [cypressGenerator].filter(Boolean),
|
|
21
21
|
contentType,
|
|
22
22
|
baseURL,
|
|
23
|
+
paramsCasing = 'camelcase',
|
|
24
|
+
paramsType = 'inline',
|
|
25
|
+
pathParamsType = paramsType === 'object' ? 'object' : options.pathParamsType || 'inline',
|
|
23
26
|
} = options
|
|
24
27
|
|
|
25
28
|
return {
|
|
@@ -29,6 +32,10 @@ export const pluginCypress = definePlugin<PluginCypress>((options) => {
|
|
|
29
32
|
dataReturnType,
|
|
30
33
|
group,
|
|
31
34
|
baseURL,
|
|
35
|
+
|
|
36
|
+
paramsCasing,
|
|
37
|
+
paramsType,
|
|
38
|
+
pathParamsType,
|
|
32
39
|
},
|
|
33
40
|
pre: [pluginOasName, pluginTsName].filter(Boolean),
|
|
34
41
|
resolvePath(baseName, pathMode, options) {
|
package/src/types.ts
CHANGED
|
@@ -22,6 +22,25 @@ export type Options = {
|
|
|
22
22
|
* @default 'data'
|
|
23
23
|
*/
|
|
24
24
|
dataReturnType?: 'data' | 'full'
|
|
25
|
+
/**
|
|
26
|
+
* How to style your params, by default no casing is applied
|
|
27
|
+
* - 'camelcase' will use camelcase for the params names
|
|
28
|
+
*/
|
|
29
|
+
paramsCasing?: 'camelcase'
|
|
30
|
+
/**
|
|
31
|
+
* How to pass your params
|
|
32
|
+
* - 'object' will return the params and pathParams as an object.
|
|
33
|
+
* - 'inline' will return the params as comma separated params.
|
|
34
|
+
* @default 'inline'
|
|
35
|
+
*/
|
|
36
|
+
paramsType?: 'object' | 'inline'
|
|
37
|
+
/**
|
|
38
|
+
* How to pass your pathParams.
|
|
39
|
+
* - 'object' will return the pathParams as an object.
|
|
40
|
+
* - 'inline' will return the pathParams as comma separated params.
|
|
41
|
+
* @default 'inline'
|
|
42
|
+
*/
|
|
43
|
+
pathParamsType?: 'object' | 'inline'
|
|
25
44
|
baseURL?: string
|
|
26
45
|
/**
|
|
27
46
|
* Group the Cypress requests based on the provided name.
|
|
@@ -56,6 +75,9 @@ type ResolvedOptions = {
|
|
|
56
75
|
group: Options['group']
|
|
57
76
|
baseURL: Options['baseURL'] | undefined
|
|
58
77
|
dataReturnType: NonNullable<Options['dataReturnType']>
|
|
78
|
+
pathParamsType: NonNullable<Options['pathParamsType']>
|
|
79
|
+
paramsType: NonNullable<Options['paramsType']>
|
|
80
|
+
paramsCasing: Options['paramsCasing']
|
|
59
81
|
}
|
|
60
82
|
|
|
61
83
|
export type PluginCypress = PluginFactoryOptions<'plugin-cypress', Options, ResolvedOptions, never, ResolvePathOptions>
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const require_index = require('./index.cjs');
|
|
2
|
-
let _kubb_core_utils = require("@kubb/core/utils");
|
|
3
|
-
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
4
|
-
let _kubb_oas = require("@kubb/oas");
|
|
5
|
-
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
6
|
-
|
|
7
|
-
//#region src/components/Request.tsx
|
|
8
|
-
function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method }) {
|
|
9
|
-
const params = _kubb_react_fabric.FunctionParams.factory({
|
|
10
|
-
data: typeSchemas.request?.name ? {
|
|
11
|
-
type: typeSchemas.request?.name,
|
|
12
|
-
optional: (0, _kubb_oas.isOptional)(typeSchemas.request?.schema)
|
|
13
|
-
} : void 0,
|
|
14
|
-
options: {
|
|
15
|
-
type: "Partial<Cypress.RequestOptions>",
|
|
16
|
-
optional: true,
|
|
17
|
-
default: "{}"
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`;
|
|
21
|
-
const body = typeSchemas.request?.name ? "data" : void 0;
|
|
22
|
-
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
23
|
-
name,
|
|
24
|
-
isIndexable: true,
|
|
25
|
-
isExportable: true,
|
|
26
|
-
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.Function, {
|
|
27
|
-
name,
|
|
28
|
-
export: true,
|
|
29
|
-
params: params.toConstructor(),
|
|
30
|
-
returnType,
|
|
31
|
-
children: [dataReturnType === "data" && `return cy.request({
|
|
32
|
-
method: '${method}',
|
|
33
|
-
url: \`${baseURL ?? ""}${new _kubb_core_utils.URLPath(url).toURLPath().replace(/([^/]):/g, "$1\\\\:")}\`,
|
|
34
|
-
body: ${body},
|
|
35
|
-
...options,
|
|
36
|
-
}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`, dataReturnType === "full" && `return cy.request('${method}', '${new _kubb_core_utils.URLPath(`${baseURL ?? ""}${url}`).toURLPath()}', ${body})`]
|
|
37
|
-
})
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
Object.defineProperty(exports, 'Request', {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return Request;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=components-CNBoaPo0.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-CNBoaPo0.cjs","names":["FunctionParams","File","Function","URLPath"],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n method: HttpMethod\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props): KubbNode {\n const params = FunctionParams.factory({\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n const body = typeSchemas.request?.name ? 'data' : undefined\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data' &&\n `return cy.request({\n method: '${method}', \n url: \\`${baseURL ?? ''}${new URLPath(url).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')}\\`, \n body: ${body},\n ...options,\n }).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`}\n {dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;AAmBA,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,UAA2B;CACzG,MAAM,SAASA,kCAAe,QAAQ;EACpC,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,oCAAqB,YAAY,SAAS,OAAO;GAClD,GACD;EAEJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;CAEF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAElJ,MAAM,OAAO,YAAY,SAAS,OAAO,SAAS;AAElD,QACE,wDAACC,wBAAK;EAAa;EAAM;EAAY;YACnC,yDAACC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;cACtE,mBAAmB,UAClB;uBACa,OAAO;qBACT,WAAW,KAAK,IAAIC,yBAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU,CAAC;oBAC7E,KAAK;;2CAEkB,YAAY,SAAS,KAAK,kBAC5D,mBAAmB,UAAU,sBAAsB,OAAO,MAAM,IAAIA,yBAAQ,GAAG,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,KAAK;IACpH;GACC"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { URLPath } from "@kubb/core/utils";
|
|
2
|
-
import { File, Function, FunctionParams } from "@kubb/react-fabric";
|
|
3
|
-
import { isOptional } from "@kubb/oas";
|
|
4
|
-
import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
5
|
-
|
|
6
|
-
//#region src/components/Request.tsx
|
|
7
|
-
function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method }) {
|
|
8
|
-
const params = FunctionParams.factory({
|
|
9
|
-
data: typeSchemas.request?.name ? {
|
|
10
|
-
type: typeSchemas.request?.name,
|
|
11
|
-
optional: isOptional(typeSchemas.request?.schema)
|
|
12
|
-
} : void 0,
|
|
13
|
-
options: {
|
|
14
|
-
type: "Partial<Cypress.RequestOptions>",
|
|
15
|
-
optional: true,
|
|
16
|
-
default: "{}"
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`;
|
|
20
|
-
const body = typeSchemas.request?.name ? "data" : void 0;
|
|
21
|
-
return /* @__PURE__ */ jsx(File.Source, {
|
|
22
|
-
name,
|
|
23
|
-
isIndexable: true,
|
|
24
|
-
isExportable: true,
|
|
25
|
-
children: /* @__PURE__ */ jsxs(Function, {
|
|
26
|
-
name,
|
|
27
|
-
export: true,
|
|
28
|
-
params: params.toConstructor(),
|
|
29
|
-
returnType,
|
|
30
|
-
children: [dataReturnType === "data" && `return cy.request({
|
|
31
|
-
method: '${method}',
|
|
32
|
-
url: \`${baseURL ?? ""}${new URLPath(url).toURLPath().replace(/([^/]):/g, "$1\\\\:")}\`,
|
|
33
|
-
body: ${body},
|
|
34
|
-
...options,
|
|
35
|
-
}).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`, dataReturnType === "full" && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ""}${url}`).toURLPath()}', ${body})`]
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { Request as t };
|
|
42
|
-
//# sourceMappingURL=components-GZOhGVCA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-GZOhGVCA.js","names":[],"sources":["../src/components/Request.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { type HttpMethod, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginCypress } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeSchemas: OperationSchemas\n url: string\n baseURL: string | undefined\n dataReturnType: PluginCypress['resolvedOptions']['dataReturnType']\n method: HttpMethod\n}\n\nexport function Request({ baseURL = '', name, dataReturnType, typeSchemas, url, method }: Props): KubbNode {\n const params = FunctionParams.factory({\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n\n options: {\n type: 'Partial<Cypress.RequestOptions>',\n optional: true,\n default: '{}',\n },\n })\n\n const returnType =\n dataReturnType === 'data' ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`\n\n const body = typeSchemas.request?.name ? 'data' : undefined\n\n return (\n <File.Source name={name} isIndexable isExportable>\n <Function name={name} export params={params.toConstructor()} returnType={returnType}>\n {dataReturnType === 'data' &&\n `return cy.request({\n method: '${method}', \n url: \\`${baseURL ?? ''}${new URLPath(url).toURLPath().replace(/([^/]):/g, '$1\\\\\\\\:')}\\`, \n body: ${body},\n ...options,\n }).then((res: Cypress.Response<${typeSchemas.response.name}>) => res.body)`}\n {dataReturnType === 'full' && `return cy.request('${method}', '${new URLPath(`${baseURL ?? ''}${url}`).toURLPath()}', ${body})`}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;AAmBA,SAAgB,QAAQ,EAAE,UAAU,IAAI,MAAM,gBAAgB,aAAa,KAAK,UAA2B;CACzG,MAAM,SAAS,eAAe,QAAQ;EACpC,MAAM,YAAY,SAAS,OACvB;GACE,MAAM,YAAY,SAAS;GAC3B,UAAU,WAAW,YAAY,SAAS,OAAO;GAClD,GACD;EAEJ,SAAS;GACP,MAAM;GACN,UAAU;GACV,SAAS;GACV;EACF,CAAC;CAEF,MAAM,aACJ,mBAAmB,SAAS,qBAAqB,YAAY,SAAS,KAAK,KAAK,sCAAsC,YAAY,SAAS,KAAK;CAElJ,MAAM,OAAO,YAAY,SAAS,OAAO,SAAS;AAElD,QACE,oBAAC,KAAK;EAAa;EAAM;EAAY;YACnC,qBAAC;GAAe;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAc;cACtE,mBAAmB,UAClB;uBACa,OAAO;qBACT,WAAW,KAAK,IAAI,QAAQ,IAAI,CAAC,WAAW,CAAC,QAAQ,YAAY,UAAU,CAAC;oBAC7E,KAAK;;2CAEkB,YAAY,SAAS,KAAK,kBAC5D,mBAAmB,UAAU,sBAAsB,OAAO,MAAM,IAAI,QAAQ,GAAG,WAAW,KAAK,MAAM,CAAC,WAAW,CAAC,KAAK,KAAK;IACpH;GACC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-CnEpcL-m.js","names":[],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, baseURL, dataReturnType },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,mBAAmB,qBAAoC;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,qBAC1B;EACJ,MAAM,gBAAgB,kBAAkB;EAExC,MAAM,MAAM,QAAQ;EACpB,MAAM,EAAE,YAAY,SAAS,YAAY,oBAAoB,UAAU;EAEvE,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAAC,aAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAAC,aAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,qBAAC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,QAAQ,UAAU;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,QAAQ,UAAU;IAAE;IAAK;IAAQ,CAAC;cAElC,oBAAC,KAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,oBAAC;IACC,MAAM,QAAQ;IACE;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAI,QAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-Nkjg7hcp.cjs","names":["pluginTsName","File","Request","URLPath"],"sources":["../src/generators/cypressGenerator.tsx"],"sourcesContent":["import { usePluginManager } from '@kubb/core/hooks'\nimport { URLPath } from '@kubb/core/utils'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File } from '@kubb/react-fabric'\nimport { Request } from '../components'\nimport type { PluginCypress } from '../types'\n\nexport const cypressGenerator = createReactGenerator<PluginCypress>({\n name: 'cypress',\n Operation({ operation, generator, plugin }) {\n const {\n options: { output, baseURL, dataReturnType },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const request = {\n name: getName(operation, { type: 'function' }),\n file: getFile(operation),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n return (\n <File\n baseName={request.file.baseName}\n path={request.file.path}\n meta={request.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={request.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <Request\n name={request.name}\n dataReturnType={dataReturnType}\n typeSchemas={type.schemas}\n method={operation.method}\n baseURL={baseURL}\n url={new URLPath(operation.path).toURLPath()}\n />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;AAUA,MAAa,yEAAuD;CAClE,MAAM;CACN,UAAU,EAAE,WAAW,WAAW,UAAU;EAC1C,MAAM,EACJ,SAAS,EAAE,QAAQ,SAAS,qBAC1B;EACJ,MAAM,wDAAkC;EAExC,MAAM,0CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,4DAAgC,UAAU;EAEvE,MAAM,UAAU;GACd,MAAM,QAAQ,WAAW,EAAE,MAAM,YAAY,CAAC;GAC9C,MAAM,QAAQ,UAAU;GACzB;EAED,MAAM,OAAO;GACX,MAAM,QAAQ,WAAW,EAAE,WAAW,CAACA,6BAAa,EAAE,CAAC;GACvD,SAAS,WAAW,WAAW;IAAE,WAAW,CAACA,6BAAa;IAAE,MAAM;IAAQ,CAAC;GAC5E;AAED,SACE,yDAACC;GACC,UAAU,QAAQ,KAAK;GACvB,MAAM,QAAQ,KAAK;GACnB,MAAM,QAAQ,KAAK;GACnB,8CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,8CAAkB;IAAE;IAAK;IAAQ,CAAC;cAElC,wDAACA,wBAAK;IACJ,MAAM;KACJ,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,SAAS;KACtB,KAAK,QAAQ,YAAY;KACzB,KAAK,QAAQ,aAAa;KAC1B,KAAK,QAAQ,cAAc;KAC3B,GAAI,KAAK,QAAQ,aAAa,KAAK,SAAS,KAAK,KAAK,IAAI,EAAE;KAC7D,CAAC,OAAO,QAAQ;IACjB,MAAM,QAAQ,KAAK;IACnB,MAAM,KAAK,KAAK;IAChB;KACA,EACF,wDAACC;IACC,MAAM,QAAQ;IACE;IAChB,aAAa,KAAK;IAClB,QAAQ,UAAU;IACT;IACT,KAAK,IAAIC,yBAAQ,UAAU,KAAK,CAAC,WAAW;KAC5C;IACG;;CAGZ,CAAC"}
|