Schema minimum exceeds its maximum

Keep minimum numeric values, string lengths and array sizes within their corresponding maximums.

Description

If minimum exceeds maximum, no number can satisfy the schema.

Potential impact

Clients and servers that use the schema can reject every value for the field.

Remediation

Set both bounds to the range your API accepts. Equal bounds allow exactly one number if both endpoints are inclusive. Check exclusiveMinimum and exclusiveMaximum when the bounds match. Check the order of minLength and maxLength for strings and minItems and maxItems for arrays.

Examples

In the first excerpt, code must be at least 3 and at most 1.

Before

json
{
  "openapi": "3.0.0",
  "components": {
    "schemas": {
      "GeneralError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "minimum": 3,
            "maximum": 1
          }
        }
      }
    }
  }
}

After

json
{
  "openapi": "3.0.0",
  "components": {
    "schemas": {
      "GeneralError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "minimum": 0,
            "maximum": 50
          }
        }
      }
    }
  }
}

The revised field accepts integers from 0 through 50.

References