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: siblings in parser-zod for better AST manipulation #1342

Merged

Conversation

ChilloManiac
Copy link
Contributor

This is an alternative to #1341 and #1292

I like this implementation better, but it might differ from the "usual" way plugins are structured in @kubb atm

Copy link

changeset-bot bot commented Oct 10, 2024

🦋 Changeset detected

Latest commit: 6071f37

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@kubb/plugin-zod Patch
@kubb/plugin-client Patch
@kubb/plugin-react-query Patch
@kubb/plugin-solid-query Patch
@kubb/plugin-svelte-query Patch
@kubb/plugin-swr Patch
@kubb/plugin-vue-query Patch
@kubb/cli Patch
@kubb/config-biome Patch
@kubb/config-ts Patch
@kubb/config-tsup Patch
@kubb/core Patch
@kubb/fs Patch
@kubb/oas Patch
@kubb/parser-ts Patch
@kubb/plugin-faker Patch
@kubb/plugin-msw Patch
@kubb/plugin-oas Patch
@kubb/plugin-redoc Patch
@kubb/plugin-ts Patch
@kubb/react Patch
@kubb/types Patch
kubb Patch
unplugin-kubb Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@ChilloManiac ChilloManiac force-pushed the feat--add-siblings-to-zod-parser branch 2 times, most recently from b611eca to bf4173e Compare October 10, 2024 08:34
@@ -171,7 +171,7 @@ type ParserOptions = {
coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }
}

export function parse(parent: Schema | undefined, current: Schema, options: ParserOptions): string | undefined {
export function parse(parent: Schema | undefined, current: Schema, options: ParserOptions, siblings: Schema[]): string | undefined {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably refactor this as follow:
(not sure about the name ParserAst)

type ParserAst=  {
   parent: Schema | undefined,
   current: Schema
   siblings: Schema[]
}
export function parse({ current, parent, siblings } : ParserAst , options: ParserOptions): string | undefined {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've given it a go, in the newest version here

@ChilloManiac ChilloManiac force-pushed the feat--add-siblings-to-zod-parser branch from bf4173e to 60478fe Compare October 11, 2024 06:56
@ChilloManiac
Copy link
Contributor Author

@stijnvanhulle I've made the refactor in this 😊 Feel free to either merge this or #1341 depending on your preference. The other should be closed afterwards 👌

@stijnvanhulle
Copy link
Collaborator

@ChilloManiac This looks better, I would prefer this kind of structure for the parser.

We only need to move this to the other parsers(zod, ts and faker plugin) so we have the same way of getting siblings and the parent(like you have done here).

@ChilloManiac
Copy link
Contributor Author

@stijnvanhulle will you do those changes? And will it be a part of this PR?

@stijnvanhulle
Copy link
Collaborator

@ChilloManiac You can already merge this one and then when I find some time this or next week I can also do the same for the other plugins that uses parsers.

@ChilloManiac
Copy link
Contributor Author

@ChilloManiac You can already merge this one and then when I find some time this or next week I can also do the same for the other plugins that uses parsers.

Sorry, but only those with write access to your repo can merge it, even if its approved 😅

@stijnvanhulle stijnvanhulle merged commit e8c2a7f into kubb-labs:main Oct 23, 2024
6 checks passed
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.

2 participants