0

Problem: Need to add validation to only allow min < max. Can this be done using OpenAPIV3 schema validation? Appreciate your help, could not figure this out reading the documentation.

Range can be provided using minimum and maximum, but how do i refer the value of an existing property?

openAPIV3Schema:
  type: object
  required:
  - min
  - max
  properties:
    min:
      type: integer
      format: int32
    max: 
      type: integer
      format: int32

1 Answer 1

2

Short answer: It is not possible with atleast the current version(v3.0.3).

Explanation:

Since minimum and maximum properties in the OpenAPI Specification are taken from JSON Schema Validation, you can refer to this stackoverflow question where it is mentioned that this is currently not possible.

The answer also mentions that there was a proposal that introduces $data but that also seems to be rejected now. As a side note, even though there is no official support for $data, some non-standard JSON Schema validator implementations like AJV have support for $data.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.