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

httpPut returns an error if the endpoint has no URL parameters #420

Open
jplassala-cocos opened this issue Jan 17, 2025 · 0 comments
Open

Comments

@jplassala-cocos
Copy link

jplassala-cocos commented Jan 17, 2025

On "inversify-express-utils": "^6.4.9",

When I create a PUT endpoint without any parameters, like this:

@controller("/controller")
export class TestController extends BaseHttpController {

@httpPut("/test")
  async updateTest(
    @request()
    req: PutRequest<{ test: string }, void>
  ) {
    console.log(`Test: ${req.body.test}`);
    return this.ok({ message: "Endpoint returned" });
  }

}

it returns this error:

{
    "messages": [
        "\"value\" must be of type object"
    ]
}

But, it I add any kind of parameter, like this:

  @httpPut("/test/:test")
  async updateTest(
    @request()
    req: PutRequest<{ test: string }, { test: string}>
  ) {
    console.log(`Test: ${req.body.test}`);

    return this.ok({ message: "Endpoint returned" });
  }

It works correctly.
Looks like httpPut() assumes that some parameter will be passed, and fails otherwise.

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