Skip to content

[BUG] Generated OpenAPI spec omits all query parameters #416

@bburda

Description

@bburda

Bug report

The OpenAPI spec generated by the gateway contains zero query parameters, even though several handlers read query parameters at runtime via req.query_param(...). Clients generated from the spec therefore cannot pass these filters type-safely.

Steps to reproduce

  1. Run the gateway and fetch the spec: curl http://localhost:8080/api/v1/docs
  2. Count query parameters across all paths: ... | jq "[.paths[][]?.parameters[]? | select(.in==\"query\")] | length"
  3. Result is 0.

Expected behavior

Endpoints whose handlers read query parameters should declare them in the spec (in: query), so the generated TypeScript/Python clients expose them. Affected endpoints and the parameters their handlers read:

  • GET /faults, GET /{entity}/faults: status, include_muted, include_clusters
  • DELETE /faults: status
  • GET /{entity}/logs: severity, context
  • GET /updates: origin, target-version

Actual behavior

The spec declares only path parameters; every operation gets query?: never in the generated TypeScript types. The gateway runtime still reads the parameters (e.g. log_handlers.cpp reads severity/context; fault_handlers.cpp reads status/include_muted/include_clusters), so filtering works over raw HTTP but is invisible to any generated client.

Root cause: query parameters were read ad-hoc in handler bodies with no link to the route OpenAPI metadata, so the spec generator never saw them. Request and response bodies are derived from typed DTOs, but query parameters had no equivalent typed contract.

This was masked for a long time: an earlier published TypeScript client shipped without its generated types, so consumer types silently degraded to any and query usage was never type-checked. Once the client shipped real types, the gap surfaced.

Environment

  • ros2_medkit version: 0.5.0
  • ROS 2 distro: Jazzy / Humble / Rolling (spec generation is distro-independent)
  • OS: Ubuntu 24.04

Additional information

Fix approach: make query parameters a typed, descriptor-driven contract like request/response bodies. A query DTO whose dto_fields descriptor drives both the OpenAPI parameters and the handler typed query read, so the two cannot drift. A pre-commit guard bans raw query reads in handlers to keep the typed path the only way in.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions