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

@PathParam on non-http methods throws invalid http method #128

Open
lesmo opened this issue Mar 29, 2020 · 0 comments
Open

@PathParam on non-http methods throws invalid http method #128

lesmo opened this issue Mar 29, 2020 · 0 comments

Comments

@lesmo
Copy link

lesmo commented Mar 29, 2020

Hi!

First of all, awesome lib. I've been using it in a couple of projects that already reached production and so far it's been delightful.

I noticed an error during a little refactoring I was doing (due to an issue on typescript-rest-swagger to be honest) that killed my entire API (local unit testing, of course):

When using @PathParam (an presumably other decorators) on class methods that do not have an http method decorator, ServerContainer.buildServices() would try to include those methods as part of the API... resulting in an error (somewhat expected) because the method does not have the proper declaration as an http method:

@Path('/some')
class SomeController {
  private someHelper(@PathParam('oops') oops: string) {
    return `we throw invalid http method ${oops}`;
  }

  @GET
  public get() {
    return 'what do you know?';
  }
}

While the problem here is kinda obvious to me now, the error thrown at runtime didn't help much:

Error: Invalid http method for service [/some]

Reading this make you think "well, let's check out SomeController.get() to see if somethings' wrong" and stare at it without much idea about what's wrong, because in fact nothing's wrong in the particular method that should process GET requests.

I'm not pretty sure what would be a good way to improve this experience.

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

1 participant