blomqma / next-rest-framework

Type-safe, self-documenting APIs for Next.js
https://next-rest-framework.vercel.app
Other
134 stars 18 forks source link

Missing 400 response body structure #170

Open markedwards opened 3 months ago

markedwards commented 3 months ago

The generated OpenAPI spec describes 400 error responses as having this structure:

{
  "type": "object",
  "properties": { "message": { "type": "string" } },
  "required": ["message"],
  "additionalProperties": false
}

They actually include error output from zod:

{
  "message": "Invalid request body.",
  "errors": [
    {
      "code": "invalid_string",
      "validation": "datetime",
      "message": "Invalid datetime",
      "path": [
        "foo"
      ]
    }
  ]
}

Ideally the OpenAPI spec should include this so generated clients can access the errors.