Skip to content

Issue with loopback controller @param.array #6750

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

Closed
Ricardope3 opened this issue Nov 7, 2020 · 5 comments
Closed

Issue with loopback controller @param.array #6750

Ricardope3 opened this issue Nov 7, 2020 · 5 comments

Comments

@Ricardope3
Copy link

There is another issue I noticed that if you only pass one value e.g. ?numberArray=123 then it throws the error with the code INVALID_PARAMETER_VALUE and in details with the message should be array, however ?numberArray=123&numberArray=12345 works just fine.

I also noticed that ?numberArray[]=123 works but thats different from how it used to work and also is not how the api explorer sends the values.

Seems like there is a general issue with the @param.array with parameter location query

Originally posted by @nflaig in #5793 (comment)

@Ricardope3
Copy link
Author

Having the same issue as @nflaig in #5793 (comment)

My code is like this

@param.array('skillNames', 'query', { type: 'string' }) skillNames: string[],

When I only add one element to the string array the following error is displayed

{
  "error": {
    "statusCode": 400,
    "name": "BadRequestError",
    "message": "Invalid data \"\" for parameter \"skillNames\".",
    "code": "INVALID_PARAMETER_VALUE",
    "details": [
      {
        "path": "",
        "code": "type",
        "message": "should be array",
        "info": {
          "type": "array"
        }
      }
    ]
  }
}

The url that is being sended looks like this

curl -X GET "http://[::1]:3000/skills/report/{skillNames}?skillNames=elemOne"

@Ricardope3
Copy link
Author

@bajtos @dhmlau

@Ricardope3 Ricardope3 changed the title There is another issue I noticed that if you only pass one value e.g. ?numberArray=123 then it throws the error with the code INVALID_PARAMETER_VALUE and in details with the message should be array, however ?numberArray=123&numberArray=12345 works just fine. Issue with loopback controller @param.array Nov 7, 2020
@mrmodise
Copy link
Contributor

mrmodise commented Nov 8, 2020

Thanks for raising the issue. However, the specific issue you are referring has been resolved by this pull request

@nflaig
Copy link
Member

nflaig commented Nov 8, 2020

@Ricardope3 I created an issue for this and it was fixed by @mrmodise.

A new version of @loopback/rest has been released and it should be fixed, see changelog.

@dhmlau
Copy link
Member

dhmlau commented Nov 11, 2020

Closing as resolved. Thanks!

@dhmlau dhmlau closed this as completed Nov 11, 2020
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

4 participants