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

[Feature request] lower case schema names? #266

Open
kornysietsma opened this issue Jan 30, 2024 · 2 comments
Open

[Feature request] lower case schema names? #266

kornysietsma opened this issue Jan 30, 2024 · 2 comments

Comments

@kornysietsma
Copy link

Hi - we have a preferred convention of using lower case first letters for Zod schema, and keeping upper case for types:

export const fooBar = z.object(...);
export type FooBar = z.infer<typeof fooBar>;

Is there a way to generate code with these kinds of names?

@astahmer
Copy link
Owner

you can use a custom template for that
https://github.com/astahmer/openapi-zod-client?tab=readme-ov-file#customization

@kornysietsma
Copy link
Author

Hmm - I'm not sure I can see how to do that.
I could change the schema names in handlebars, by registering a helper function to rename the keys, something like

{{#each schemas}}
const {{#lowerCamel}}{{@key}}{{/lowerCamel}} = {{{this}}};
{{/each}}

but that wouldn't help where the {{{this}}} part of the schema referes to other schemas.

Anyway from looking through the openapi-zod-client it looks like it'd be fiddly; we can probably get by with a bit of post-generation conversion.

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

No branches or pull requests

2 participants