softwaremill / softwaremill/tapir
Validation error response - lack of access to the name of the invalid field
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 1.5k
- Forks
- 468
- Avg merge
- 5h 37m
- Merged PRs (30d)
- 34
Description
I want to return the following response on the validation error:
{
"errors":{
"fieldName": [
"field error"
]
}
}
(like in https://realworld-docs.netlify.app/docs/specs/backend-specs/error-handling#errors-and-status-codes)
I've tried to modify the response handler here: https://github.com/softwaremill/tapir/blob/master/server/core/src/main/scala/sttp/tapir/server/interceptor/decodefailure/DecodeFailureHandler.scala#L33
But the response handler doesn't have access to the field name (only to status code, headers, and error message - (StatusCode, List[Header], String) => ValuedEndpointOutput[_].
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with server/core/src/main/scala/sttp/tapir/server/interceptor/decodefailure/DecodeFailureHandler.scala around line 33, where the response handler receives only the status code, headers, and error message. Trace how validation failures reach this handler and where the invalid field name is lost. Done means the handler can produce the requested field-keyed validation error response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- scala
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100