Tapir custom http code in successful response

I'm using Tapir library for endpoint definition but I need to provide custom http code in a successful response (not to map error to error code). I've found something in the documentation but it's not really useful to me. Could somebody give me simple code example?


  • If you want to always provide a given status code in case of a successful response, adding the following output should work:

    import sttp.model.StatusCode

    Alternatively, you can add a dynamic status code output:

    import sttp.model.StatusCode

    Then you'll need to provide the StatusCode value as part of the business logic.