MunifTanjim / node-bitbucket

Bitbucket API client for Browser and Node.js
https://bitbucketjs.netlify.app
MIT License
106 stars 28 forks source link

Chore/get all pullrequests #44

Open adelkahomolova opened 4 years ago

adelkahomolova commented 4 years ago

I created this PR as I need to have a possibility to get all pull requests from Bitbucket in my open-source app (which scan your repo to recommend you the best practices to use). Here is my PR, where I have a getPullRequests() method with filtering by state. https://github.com/DXHeroes/dx-scanner/pull/164/files#diff-f600166eb00e146bad20364a8e1fa783R82

My proposal is based on Bitbucket API doc By default only open pull requests are returned. This can be controlled using the state query parameter. To retrieve pull requests that are in one of multiple states, repeat the state parameter for each individual state.

https://developer.atlassian.com/bitbucket/api/2/reference/resource/pullrequests/%7Btarget_user%7D

MunifTanjim commented 4 years ago

@adelkahomolova Thanks for the PR!

But it'll be a bit more complicated to implement it. Your implementation will work, of course.

But this library uses the official specification file. And then runs a bunch of scripts to make everything work. And for fixing the official specification file, an override file is used.

The problem is that, the next time (before publishing a new version) the scripts will run, all your changes will be removed by them. So, we will need to come up with a different approach, because all these files are generated dynamically: scripts/type-defs.json, specification/definitions.json, src/routes/routes.json.

prokopsimek commented 4 years ago

@MunifTanjim Hi, can I ask you how it is possible to propose an update in this official specification file? It's quite clever to use the official specification, but the quality of the Bitbucket SDK is quite poor against any other SDKs (e.g. Github's Octokit). Would be possible to have the official specification just for testing purposes (just to validate the app quality?).

We're using the node-bitbucket lib in our DX Scanner library and it's quite hard to use it. E.g. the worse experience is that all body parameters are optional - how could have the API optional all returning parameters?

MunifTanjim commented 4 years ago

can I ask you how it is possible to propose an update in this official specification file?

I've tried to contact them in the past. But it didn't work. So, probably not gonna happen...

@prokopsimek Have you tried the v2-beta? Internally it uses an approach similar to the Octokit library.

I'm not sure, but I think we can expose some of its internals to make it easier to override the behavior of individual endpoints in runtime.

prokopsimek commented 4 years ago

@MunifTanjim We haven't tried it. I will take a look at it.

Would be possible to override these type definitions e.g. with DeepRequired in responses?