Skip to content

Combining decorators #1850

Answered by NielsCo
eddyashton asked this question in Q&A
Discussion options

You must be logged in to vote

You can use a custom scalar that then will be referenced. Like this:

@format("hex")
@pattern("^[a-f0-9]{64}$")
scalar MyScalar extends string;

model User {
  @key
  userId: MyScalar;
}

model Member {
  @key
  memberId: MyScalar;
}

model Proposal {
  @key
  proposalId: MyScalar;
}

But be aware that it will be referenced in the openAPI output. Like this:

components:
  schemas:
    Member:
      type: object
      properties:
        memberId:
          $ref: '#/components/schemas/MyScalar'
      required:
        - memberId
    MyScalar:
      type: string
      format: hex
      pattern: ^[a-f0-9]{64}$
    Proposal:
      type: object
      properties:
        proposalId:
          $re…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eddyashton
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