Skip to content

resolveLaravelResponses

reference
1 min readUpdated

Kind: Function

Source: atloria-monorepo/libs/parser-core/src/techdocs/cross-file-routes.ts

Document what a Laravel action returns, as the framework actually sends it.

Three facts live in three files and only mean something together: the action names a resource class (return new ArticleResource($article)), the resource states its keys in toArray(), and the columns those keys read are in database/migrations. On top of that sits a framework rule that is invisible in all three — a resource response is WRAPPED, so the body is {"article": {…}} and not {…}. Documenting the payload alone would describe a body no caller ever receives.

A resource whose toArray() is not a literal array, an action returning a class the parse never saw, an array_merge(parent::toArray(…)) whose parent is missing: all of them end with the endpoint documenting no response rather than a partial one.

Signature

ts
function resolveLaravelResponses(entities: Entity[]): number

Parameters

NameType
entitiesEntity[]

Returns: number

Was this page helpful?

Download as PDF