Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Recognition of API path in Tapir version 10.4.1 #3702

Open
morvaridmf opened this issue Apr 19, 2024 · 5 comments
Open

Issue with Recognition of API path in Tapir version 10.4.1 #3702

morvaridmf opened this issue Apr 19, 2024 · 5 comments

Comments

@morvaridmf
Copy link

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.

@morvaridmf morvaridmf changed the title Issue with Recognition of API path in Tapir version 10.4.1 [BUG] Issue with Recognition of API path in Tapir version 10.4.1 Apr 19, 2024
@adamw
Copy link
Member

adamw commented Apr 19, 2024

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?

@morvaridmf
Copy link
Author

morvaridmf commented Apr 19, 2024

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")

@adamw
Copy link
Member

adamw commented Apr 19, 2024

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)

@morvaridmf
Copy link
Author

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.

@adamw
Copy link
Member

adamw commented Apr 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants