aj-foster / open-api-generator

Open API code generator for Elixir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle default error response

aej opened this issue · comments

Hi, thanks for creating such a great library.

I came across a situation where an openapi schema contains a default response to cover all error cases. Quoting from here

You can use the default response to describe these errors collectively, not individually. “Default” means this response is used for all HTTP codes that are not covered individually for this operation.

I think it would be useful to support this in the generator as a special-case - so perhaps the operations.responses object could be in the form

[
  {200, {ResponseSchemaFoo, :t}},
  {:default, {ResponseSchemaBar, :t}}
]

That will allow users to handle the default in their Client library.

Hi @aej — thanks for taking the time to share this bit of OpenAPI. I wasn't aware you could do this, and it's very convenient.

Do you happen to have a test specification that you could use to validate if #5 fixes this behaviour?