Answers, envelopes and errors
Nothing the generated code runs touches an answer, so the types say what the client returns:
- Envelope. If the document’s answer is
{ result, code, message, data }and the client is@mrzr/api-client, which takes thedataof such an answer itself, the types and calls speak only ofdata:allOf: [EnvelopeBase, { data: T }]becomesApiEnvelope<T>inmodels.ts. With axios or Angular the answer is delivered whole, so its type is the whole schema (an envelope is an ordinary model there); withfetchyou read theResponseyourself. Aresult: falseis the client’s to judge — a200withresult: falseis returned as it is. For a custom transport that unwraps on its own,runtime.envelopedescribes the shape (falsefor none). - Paged lists. A
{ count, list }payload becomesApiListData<T>only when the document marks both fieldsrequired; otherwise it keeps its own type with optional fields, becauseApiListDatapromises both are there. An API that always sends both can say so withruntime: { list: { assumeRequired: true } };runtime.list: falseturns it off. - Errors. A failed status is the client’s own: an
AxiosError, anHttpErrorResponse, anApiError.fetchresolves on any status, so a failed one is aResponsewithok: false. - Infinite lists are written for a paged read whose answer is
{ count, list }. When the answer is wrapped (an envelope with a client that does not unwrap it) the hook cannot be typed, so none is written and the run says so.