IPA-115: Envelope Object
Some clients might not be able to access the HTTP response headers and/or status code. In that case, clients can request that the response include an "envelope," which is simply an extra layer of information in the JSON document and contains any relevant details that would normally be in the response headers.
Guidance
Resources may support a boolean
envelopequery parameter.envelopemust default to false.parameters:
- name: envelope
in: query
schema:
type: boolean
default: falseWhy:The
envelopeparameter declaresdefault: false, so a client that omits it receives the unwrapped response.If
envelopeis set totruefor individual resources, the response must include the fieldstatusas the HTTP status code and the fieldcontentas the requested resource.{
"status": 200,
"content": {
"id": "5f1b...",
"name": "Cluster0"
}
}Why:With
envelope=true, the response wraps the requested resource undercontentand surfaces the HTTP status code understatus, so a client that cannot read response headers still has both.Call the individual resource operation with
envelope=true.Confirm the response body includes a
statusfield carrying the HTTP status code.Confirm the requested resource is nested under the
contentfield.
If
envelopeis set totruefor Paginated resources the existing response must include the fieldstatusas the HTTP status code.{
"status": 200,
"results": [],
"totalCount": 0
}Why:For a paginated resource, the existing response shape is preserved and only a
statusfield is added carrying the HTTP status code, so the envelope does not reshape the pagination response.Call the paginated resource operation with
envelope=true.Confirm the existing paginated response body is preserved and a
statusfield carrying the HTTP status code is added.
Generated API Clients
Generated clients must not support envelope.
- Conditionally changing the shape of a response is not supported by code generation tools
Why:Generated clients expect a single, stable response shape per operation. Because the envelope conditionally changes that shape, code generation tools cannot represent it, so generated clients must not support envelope.
Identify which clients are produced by code generation tools.
Confirm those generated clients do not expose or set the
envelopeparameter, since it conditionally changes the response shape.