-
-
Notifications
You must be signed in to change notification settings - Fork 395
Open
Labels
enhancementNew feature or requestNew feature or request
Description
What is the problem this feature would solve?
I have an existing API that I want to create API specs for using the HttpApi
module, before gradually implementing it using the HttpApiBuilder
, phasing out its old implementation.
The API specs can be fully customised in what each endpoint responds with by using addSuccess
and addError
, except for one thing: The HttpApiDecodeError
.
This means I'm unable to create an API spec to fully cover my existing API.
I posted this on Discord a while ago, but never got a response.
What is the feature you are proposing to solve the problem?
A setDecodeError
method that takes a Schema<HttpApiDecodeError, T>
so I can customize how those are encoded:
const HttpApiDecodeErrorFromMyWeirdValidationError =
Schema.transform(
MyWeirdValidationError,
HttpApi.HttpApiDecodeErrorSchema, // <--- exposure of default schema
{ encode: (yours) => ({...}), decode: (mine) => ({...}) }
)
export default HttpApi.make('myApi')
.add(MyApiGroup)
.setDecodeError(HttpApiDecodeErrorFromMyWeirdValidationError) // <--- override
.addError(MyWeirdInternalServerError, { status: 500 })
What alternatives have you considered?
Hacking the response with a middleware, and the OpenAPI specs: #5367 (comment)
silranucci and linrium
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request