tapir
tapir copied to clipboard
Issue with Recognition of API path in Tapir version 10.4.1
We encountered an issue recognizing our endpoint named 'import-jobs' after updating to the latest Tapir version. As a result, all tests for this endpoint consistently fail and return a 405 error. We have questions to find out why Tapir is unable to recognize this endpoint following the update.
I think we'll need more detail to understand what's the problem :)
From what version to which one did you update? What's the endpoint's definition? And what is an example failing request?
It has been quite a while since we last updated the version. Specifically, we were using version 0.19.4 before updating to the latest release.
the issue is we have two end points (importJobs) and (import-jobs), before updating the version both 2 end points were working fine, but after updating all the test related to (import-jobs) end point failed. I changed the (import-jobs) to (import-job) and that worked fine, so I am wondering what can be the issue?
here is the piece of code I'm referring val importJobsOld: EndpointTypeAuthInQuery[Unit, Set[ImportJob]] = .in("importJobs") .name("getImportJobsOld") .summary("Get Import Jobs") .get .out(jsonBody[Set[ImportJob]].addOKDes()) .description("Get a list of all import jobs")
val importJobs: EndpointTypeAuthInQuery[Unit, Set[ImportJob]] = .in("import-jobs") .name("getImportJobs") .summary("Get Import Jobs") .get .out(jsonBody[Set[ImportJob]].addOKDes()) .description("Get a list of all import jobs")
I tested an endpoint using an "import-jobs" path and everything worked correctly. A response code 405 indicates that the wrong HTTP method is used. Are you issuing GET requests as described by the endpoint defition? (which seems incomplete)
would you please try it with having 2 endpoints at the same time, import-jobs and importJobs?
the issue that we are facing is when we use 2 endpoints with the names I mentioned above.
Sure, works fine:
import sttp.tapir.*
import sttp.tapir.server.netty.sync.{Id, NettySyncServer}
object HelloWorldNettySyncServer extends App:
val e1 = endpoint.get
.in("import-jobs")
.out(stringBody)
.serverLogicSuccess[Id](_ => "1")
val e2 = endpoint.get
.in("importJobs")
.out(stringBody)
.serverLogicSuccess[Id](_ => "2")
NettySyncServer().addEndpoint(e1).addEndpoint(e2).startAndWait()
test:
[~]% curl http://localhost:8080/import-jobs
1
[~]% curl http://localhost:8080/importJobs
2