openapi-codegen
openapi-codegen copied to clipboard
feat: Added config formatFilename to allow more custom formatting of filenames
I have a special need where I want to add .gen at the end of the files that are always regenerated by the codegen.
Instead of baking that logic into this lib, I thought that allowing to provide a custom formatter would be generic enough and I can do a mapping on my side like this
const formatFilename = (filename: string) => {
filename = _.kebabCase(filename);
const needsDotGen = [
`${filenamePrefix}-components`,
`${filenamePrefix}-request-bodies`,
`${filenamePrefix}-schemas`,
`${filenamePrefix}-parametersF`,
`${filenamePrefix}-responses`,
].includes(filename);
return `${filename}${needsDotGen ? ".gen" : ""}`;
};
const { schemasFiles } = await generateSchemaTypes(context, {
filenamePrefix,
formatFilename,
});
await generateReactQueryComponents(context, {
schemasFiles,
filenamePrefix,
formatFilename,
});