OpenAPI path/query parameters nested structure serialization

Short answer: It’s undefined behavior.

Most OpenAPI serialization styles are based on RFC 6570, which provides guidance only for:

  • primitive values,
  • arrays of primitives,
  • simple non-nested objects (with primitive properties).

In case of other types of values (nested objects, objects containing arrays, nested arrays, arrays of objects) the behavior is undefined.

Similarly, OpenAPI’s own deepObject style is currently defined only for simple objects but not for arrays or nested objects. Here are some related comments from the OpenAPI Specification authors/maintainers:

By the way, is there a reason we couldn’t have deepObject work for arrays too? […]

Darrel: Supporting arrays as you describe was my intent. I was supposed to find some canonical implementation to use as a guideline for the behavior, but didn’t get around to it.

Ron: If we end up supporting the exploded array notation, it needs to be clear that the first index is 0 (or 1, or -1, or whatever).

(source)

Ron: when we defined deepObject in the spec, we explicitly chose to not mention what happens when the object has several levels in it, but in our conversations we went with ‘not supported’. ​

(source)

There’s an existing feature request to extend deepObject to support arrays and nested structures:
Support deep objects for query parameters with deepObject style

Leave a Comment