Allow HttpApiEndpoint to override HttpApiDecodeError response
What version of Effect is running?
3.14.5
What steps can reproduce the bug?
Create an endpoint and set success and error. In this case, I just want 400 Bad Request to be the empty response, not the HttpApiDecodeError. I don't see a method that allows me to remove the default error response, so defining my own just adds to the HttpApiDecodeError response (as is consistent with adding multiple error types).
As an aside, given that this endpoint doesn't defined a request payload or path/query params, it seems odd that the api should define a decode error response at all.
const api = HttpApi.make('api')
.add(HttpApiGroup.make('devices')
.add(HttpApiEndpoint.get('listDevices')`/devices`
.addSuccess(DeviceListSchema)
.addError(HttpApiError.BadRequest)
.addError(HttpApiError.Unauthorized)
.addError(HttpApiError.InternalServerError)
)
)
paths:
/devices:
get:
tags:
- devices
operationId: devices.listDevices
parameters: []
security: []
responses:
'200':
description: A list of Device entities with pagination information
content:
application/json:
schema:
$ref: '#/components/schemas/DeviceList'
'400':
description: The request did not match the expected schema
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/HttpApiDecodeError'
- $ref: '#/components/schemas/BadRequest'
'401':
description: Unauthorized
'500':
description: InternalServerError
Note that in the yaml (generated by using OpenApi.fromApi and the converting to YAML) under the 400 response, it now shows a union of response schema. HttpApiDecodeError does not match the desired response format for this type of error, and in the implementation I would want to catch this error and produce my own (empty in this example, but could be another response schema that suits my application).
In my case, I am going to use the OpenApi spec to generate AWS Api Gateway infrastructure, and so I don't need an Effect implementation, as I will inject the necessary AWS extensions into the OpenApi spec to add my Lambda handlers. I will intend to publish the OpenApi spec as output by @effect/platform as a way of documenting the API for consumers.
What is the expected behavior?
'400':
description: The request did not match the expected schema
content:
application/json:
schema:
$ref: '#/components/schemas/BadRequest'
What do you see instead?
'400':
description: The request did not match the expected schema
content:
application/json:
schema:
anyOf:
- $ref: '#/components/schemas/HttpApiDecodeError'
- $ref: '#/components/schemas/BadRequest'
Additional information
No response