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

Zod: readonly fields appears in *CreateBody #1548

Closed
JargeZ opened this issue Jul 31, 2024 · 0 comments · Fixed by #1625
Closed

Zod: readonly fields appears in *CreateBody #1548

JargeZ opened this issue Jul 31, 2024 · 0 comments · Fixed by #1625
Labels
zod Zod related issue
Milestone

Comments

@JargeZ
Copy link

JargeZ commented Jul 31, 2024

What are the steps to reproduce this issue?

Shema entity example

    LegalEntity:
      type: object
      properties:
        id:
          type: string
          format: uuid
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
        name:
          type: string
          maxLength: 255
      required:
      - created_at
      - id
      - name
      - updated_at

What happens?

Generated zod schema for create body have all the fields that marked as readOnly

export const v1OrgstructureLegalEntitiesCreateBody = zod.object({
  "id": zod.string().uuid(),
  "created_at": zod.string().datetime(),
  "updated_at": zod.string().datetime(),
  "name": zod.string().max(v1OrgstructureLegalEntitiesCreateBodyNameMax),
})

What were you expecting to happen?

readonly fields appears only in get-like actions and responses

so it means that CreateBody expected to be

export const v1OrgstructureLegalEntitiesCreateBody = zod.object({
  "name": zod.string().max(v1OrgstructureLegalEntitiesCreateBodyNameMax),
})

What versions are you using?

"orval": "^6.31.0",
"zod": "^3.23.8"

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

Successfully merging a pull request may close this issue.

2 participants