MunifTanjim / node-bitbucket

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

TS issue: type field should not be required for POST/PUT APIs #87

Open yaronya opened 3 years ago

yaronya commented 3 years ago

It looks like the type field is configured as required under the Object type (in bitbucket.d.ts) so it also requires it for every PUT/POST method params type of the client. When adding that excess field, bitbucket fails the requests with a Bad Request validation error:

{
  type: 'error',
  error: {
    fields: { type: 'extra keys not allowed' },
    message: 'Bad request'
  }
}
MunifTanjim commented 3 years ago

Can you proved some more infomation? Which methods are affected by this?

Btw, those types come directly from Bitbucket's API specification. If this is new a new issue, then they've probably changed something.

michaelw85 commented 3 years ago

According to the bitbucket API this is the definition for type:

Base type for most resource objects. It defines the common type element that identifies an object's type. It also identifies the element as Swagger's discriminator.

Looking at some examples for creating repo's this is a simple as a repository has type repository branch has branch. Hope this helps. I'm just starting out with this package and the "type" immediately confused me.

Here's an example I just tested an works:

        await bitbucket.repositories.create({
            workspace: 'xyz',
            repo_slug: 'test',
            _body: {
                type: 'repository',
                fork_policy: 'no_forks',
                is_private: true,
                scm: 'git',
            },
        });