Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added config formatFilename to allow more custom formatting of filenames #231

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Cellule
Copy link

@Cellule Cellule commented Mar 14, 2024

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,
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant