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

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

Open yaronya opened this issue 4 years ago • 2 comments

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'
  }
}

yaronya avatar Mar 30 '21 15:03 yaronya

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.

MunifTanjim avatar Apr 02 '21 19:04 MunifTanjim

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',
            },
        });

michaelw85 avatar May 05 '21 06:05 michaelw85