node-bitbucket icon indicating copy to clipboard operation
node-bitbucket copied to clipboard

Support for repeatable parameter for list pull request

Open chalenge opened this issue 5 years ago • 1 comments

The state parameter in pullrequests - list can be repeated such as /repositories/{workspace}/{repo_slug}/pullrequests?state=MERGED&state=OPEN

Is there a way this can be supported using in the client. Currently only specifying one parameter is supported

chalenge avatar Oct 06 '20 06:10 chalenge

See the discussion on #44 to know about why this isn't properly supported. (TLDR: Bitbucket's API Specification: https://api.bitbucket.org/swagger.json is incorrect)

With that said, here's a dirty hack that you can do to make this work. (requires: v2.4.2+)

// @ts-ignore
bitbucket.repositories.listPullRequests = bitbucket.repositories.listPullRequests.defaults(
  {
    request: {
      validate: {
        state: {
          enum: undefined,
          type: 'array',
          items: {
            enum: ['OPEN', 'DECLINED', 'MERGED', 'SUPERSEDED'],
            type: 'string',
          },
        },
      },
    },
  }
)

bitbucket.repositories.listPullRequests({
  workspace: '<workspace>',
  repo_slug: '<repo_slug>',
  // @ts-ignore
  state: ['OPEN', 'DECLINED'],
})

MunifTanjim avatar Oct 14 '20 15:10 MunifTanjim