Skip to content

Custom Validation for schema attributes #223

Answered by hauner
arvindand asked this question in Q&A
Discussion options

You must be logged in to vote

summarizing, it could work like this:

components:
  schemas:
    Foo:
      type: object
      properties:
        bar:
          type: string
          maxLength: 10
          x-constraints-1: "constraint"
          x-constraints-2:
            - "foo"
            - "bar"

and then map it to annotations with:

map:
  extensions:
    - x-constraints-1 @ some.custom.Constraint
    - x-constraints-2:
      - foo @ some.custom.FooConstraint
      - bar @ some.custom.BarConstraint

Replies: 4 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@arvindand
Comment options

@hauner
Comment options

Comment options

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

Answer selected by arvindand
Comment options

You must be logged in to vote
0 replies
Comment options

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