|
| 1 | +# Validation And How It Deviates From OpenAPI Specification |
| 2 | +This page documents where validation deviates from the OpenAPI Specification. |
| 3 | + |
| 4 | +## Stricter Requirements |
| 5 | +It is stricter when it comes to providing an unambiguous specification. |
| 6 | +This helps to avoid confusion as well as simplify development for other OpenAPI tools. |
| 7 | + |
| 8 | +### OperationId Is Required |
| 9 | + |
| 10 | +Operations MUST have an [operationId](https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/versions/3.0.3.md#fixed-fields-8). |
| 11 | + |
| 12 | +`operationId` is a unique string used to identify an operation. |
| 13 | +By making it required, it serves as a _reliable_ method of identification. |
| 14 | + |
| 15 | +### Query Strings Must Be Unambiguous |
| 16 | + |
| 17 | +Operations MUST NOT use more than one _ambiguous parameter_. |
| 18 | + |
| 19 | +In this context, an _ambiguous parameter_ is defined as being `in:query` with one of the following combinations: |
| 20 | +- `type:object` with `style:form` and `explode:true` |
| 21 | +- `type:object` or `type:array` with `style:spaceDelimited` |
| 22 | +- `type:object` or `type:array` with `style:pipeDelimited` |
| 23 | + |
| 24 | +If everything else can be identified; then through a process of elimination, the ambiguous segment belongs to the _ambiguous parameter_ |
| 25 | + |
| 26 | +If an operation contains two or more _ambiguous parameters_, then there are multiple ways of interpreting the ambiguous segment. |
| 27 | +This ambiguity means the query string cannot be resolved deterministically. |
| 28 | +As such, it is not allowed. |
| 29 | + |
| 30 | +## Looser Requirements |
| 31 | + |
| 32 | +These requirements are looser than the OpenAPI Specification. |
| 33 | +Where the OpenAPI Specification would be invalid, the reader will add a warning to the `Validated` object. |
| 34 | + |
| 35 | +### MultipleOf Can Be Negative |
| 36 | + |
| 37 | +Normally `multipleOf` MUST be a positive non-zero number. |
| 38 | + |
| 39 | +The Reader allows `multipleOf` to be any non-zero number. |
| 40 | +A multiple of a negative number is also a multiple of its absolute value. |
| 41 | +It's more confusing, but what is expressed is identical. |
| 42 | + |
| 43 | +Therefore, if a negative value is given: |
| 44 | +- You will receive a Warning |
| 45 | +- The absolute value will be used |
| 46 | + |
| 47 | +### AllOf, AnyOf and OneOf Can Be Empty |
| 48 | + |
| 49 | +Normally, `allOf`, `anyOf` and `oneOf` MUST be non-empty. |
| 50 | + |
| 51 | +The Reader allows them to be empty. |
| 52 | + |
| 53 | +[] and null express basically the same thing, no value. |
| 54 | +By replacing null with [], we can narrow the typehint from `array|null` to `array`. |
| 55 | +Simplifies code using it. |
| 56 | + |
| 57 | +### Required Can Be Empty |
| 58 | + |
| 59 | +OpenAPI 3.0 states `required` MUST be non-empty. |
| 60 | +OpenAPI 3.1 allows `required` to be empty and defaults to empty if omitted. |
| 61 | + |
| 62 | +The Reader always allows `required` to be empty and defaults to empty if omitted. |
| 63 | +This allows us to narrow the typehint for `required` to always being an array. |
| 64 | + |
| 65 | +If an empty array is given: |
| 66 | +- If your API is using 3.0, you will receive a Warning |
| 67 | +- An empty array will be used |
| 68 | + |
| 69 | +### Required Can Contain Duplicates |
| 70 | + |
| 71 | +Normally `required` MUST contain unique values. |
| 72 | + |
| 73 | +The Reader allows `required` to contain duplicates. |
| 74 | + |
| 75 | +If a duplicate item is found: |
| 76 | +- You will receive a Warning |
| 77 | +- The duplicate will be removed. |
0 commit comments