10BC0 Route response schema, how can I support multiple schemas? · fastify fastify · Discussion #6156 · GitHub
[go: up one dir, main page]

Skip to content
Discussion options

You must be logged in to vote

Using Zod I opted to define a base schema for each response. The base schema defines a subset of fields that are always required in the response. The remaining fields are optional, sent in response based on user access level.

Provided documentation for each endpoint describing the required versus fields returned based on permissions.

This idea comes from Claude 4

components:
  schemas:
    Account:
      type: object
      description: |
        🔒 **Field visibility depends on user permissions.**
        📋 [See Permission Matrix](https://docs.yourapi.com/permissions)
      properties:
        id: { type: string }
        handle: { type: string }
        email: { type: string }
        status

Replies: 4 comments 1 reply

F440
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@jbeckton
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by jbeckton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
0