@kubb/plugin-cypress
Version:
Cypress test generator plugin for Kubb, creating end-to-end tests from OpenAPI specifications for automated API testing.
77 lines (75 loc) • 2.72 kB
JavaScript
const require_components = require('./components-CEpexuad.cjs');
const require_index = require('./index.cjs');
let _kubb_plugin_ts = require("@kubb/plugin-ts");
let _kubb_core_hooks = require("@kubb/core/hooks");
let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
let _kubb_react_fabric = require("@kubb/react-fabric");
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
//#region src/generators/cypressGenerator.tsx
const cypressGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
name: "cypress",
Operation({ operation, generator, plugin }) {
const { options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType } } = plugin;
const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
const request = {
name: getName(operation, { type: "function" }),
file: getFile(operation)
};
const type = {
file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
schemas: getSchemas(operation, {
pluginKey: [_kubb_plugin_ts.pluginTsName],
type: "type"
})
};
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
baseName: request.file.baseName,
path: request.file.path,
meta: request.file.meta,
banner: (0, _kubb_plugin_oas_utils.getBanner)({
oas,
output,
config: pluginManager.config
}),
footer: (0, _kubb_plugin_oas_utils.getFooter)({
oas,
output
}),
children: [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
name: [
type.schemas.request?.name,
type.schemas.response.name,
type.schemas.pathParams?.name,
type.schemas.queryParams?.name,
type.schemas.headerParams?.name,
...type.schemas.statusCodes?.map((item) => item.name) || []
].filter(Boolean),
root: request.file.path,
path: type.file.path,
isTypeOnly: true
}), /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Request, {
name: request.name,
dataReturnType,
paramsCasing,
paramsType,
pathParamsType,
typeSchemas: type.schemas,
method: operation.method,
baseURL,
url: operation.path
})]
});
}
});
//#endregion
Object.defineProperty(exports, 'cypressGenerator', {
enumerable: true,
get: function () {
return cypressGenerator;
}
});
//# sourceMappingURL=generators-FDNmST6B.cjs.map