Skip to content

feat(openapi): document request bodies and real HTTP methods from handler schemas#159

Merged
filipeforattini merged 1 commit into
mainfrom
feat/openapi-magic-body-docs
Jun 26, 2026
Merged

feat(openapi): document request bodies and real HTTP methods from handler schemas#159
filipeforattini merged 1 commit into
mainfrom
feat/openapi-magic-body-docs

Conversation

@filipeforattini

Copy link
Copy Markdown
Member

Problema

Na doc renderizada, endpoints REST/handlers de criação não mostravam o body nem a validação do body, e descrições/tags definidas no handler não chegavam ao OpenAPI.

Mudanças (3 lacunas)

A — *.rest.ts alimenta o requestBody com o schema certo

  • RestExports ganhou inputSchema? e patchSchema?.
  • O loader resolve um write schema: usa o inputSchema exportado ou deriva de schema omitindo primaryKey + createdAt/updatedAt. Patch vira partial() quando não há patchSchema.
  • O requestBody para de vazar a entidade inteira (id/timestamps).

B — gerador respeita o método HTTP real

  • Deixou de chumbar tudo como POST; honra meta.httpMethod e só emite requestBody para post/put/patch.

C — summary/description/tags nos campos certos

  • discovery-utils agora propaga summary e tags (antes só description).
  • O gerador mapeia summary e description para campos OpenAPI distintos; tags preferem meta.tags.

Verificação

  • tsc --noEmit limpo.
  • Unit: 1285 passed. Int (docs/discovery/fs-routes/rest): 201 passed.
  • Ajustado 1 teste que codificava o comportamento antigo; cobertura nova no gerador (método HTTP, summary/description) e novo rest-loader-input-schema.unit.test.ts (4 casos).

Close three gaps that kept handler validation and metadata from
reaching the rendered OpenAPI docs:

- REST resources (*.rest.ts) now resolve a write-side schema for
  create/update/patch bodies from an exported inputSchema/patchSchema,
  or derive one from the entity schema by omitting the primary key and
  timestamp fields. The OpenAPI requestBody stops leaking id/timestamps.
- The procedure docs loop respected only POST and always attached a
  body. It now honours meta.httpMethod and only emits a requestBody for
  body-carrying verbs.
- meta.summary and meta.tags were dropped during fs-discovery and the
  generator reused meta.description as the summary. summary/description
  now map to their own OpenAPI fields and tags propagate end-to-end.

Adds rest-loader write-schema unit coverage and generator cases for
HTTP method and summary/description mapping.
@filipeforattini filipeforattini merged commit a84246d into main Jun 26, 2026
2 checks passed
@filipeforattini filipeforattini deleted the feat/openapi-magic-body-docs branch June 26, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant