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

fix(opapi): create a deepcopy of the schema before setting openapi properties #288

Merged
merged 3 commits into from
May 6, 2024

Conversation

franklevasseur
Copy link
Member

No description provided.

@franklevasseur franklevasseur requested review from michaelmass and a team as code owners May 3, 2024 23:49
schemaObject?: AnatineSchemaObject & { $ref?: string },
): T => {
const This = (schema as any).constructor
const copy = new This(schema._def) as T
Copy link
Member Author

@franklevasseur franklevasseur May 3, 2024

Choose a reason for hiding this comment

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

Other approaches i've considered to clone the zod object:

const copy = _.cloneDeep(schema) // this works

const copy = z.object(schema.shape) // this would only work for objects...

I'm not sure which is better

@franklevasseur franklevasseur merged commit 8479609 into master May 6, 2024
1 check passed
@franklevasseur franklevasseur deleted the fl_opapi_fix_schema branch May 6, 2024 18:20
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