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

Bitbucket API and Typescript Type Mismatch

Open forcebewithyou opened this issue 3 years ago • 4 comments

I am fairly new to node and typescript, so it might very well be a developer error :)

Issue am facing is that I am forced to include "type" as a required attribute in my requests which bitbucket api is complaining.

I believe its due to "object" being included as base extension and definition of "object" has "type" as required attribute.

image

And interface object has type as required attribute

image

forcebewithyou avatar Sep 09 '22 00:09 forcebewithyou

The types are auto generated from BitBucket's API Specification:

  • https://api.bitbucket.org/swagger.json
  • https://github.com/MunifTanjim/node-bitbucket/blob/dba6ff4/scripts/generate-types.js

What problem are you facing, btw? Are you having trouble calling any API? Is TypeScript complaining when you try to call the endpoint method?

MunifTanjim avatar Sep 09 '22 05:09 MunifTanjim

Am trying to post a comment to PR inline image

Typescript is complaining that "type" is a required attribute.

error TS2322: Type '{ content: { raw: string; }; inline: { path: string; to: number; }; }' is not assignable to type 'PullrequestComment'. Property 'type' is missing in type '{ content: { raw: string; }; inline: { path: string; to: number; }; }' but required in type 'Object'.

Now when I add type attribute image

Bitbucket API complain bad request.

When I update schema and make Type as optional and send the request without it, voila.. it works.

forcebewithyou avatar Sep 09 '22 13:09 forcebewithyou

Yeah, those specification are definitely wrong. BitBucket's API specification has way too many incorrect info.

Since this whole library is auto-generated from those specification, it's affected by it. It's very hard for me to know which part of the speification is correct and which part is wrong, so it's not possible for me to patch definitions for each endpoint.

Unless BitBucket fixes those, I'm afraid I can't be of much help here.

MunifTanjim avatar Sep 09 '22 17:09 MunifTanjim

I understand, thank you for prompt responses, went ahead with direct integration using node-fetch.

forcebewithyou avatar Sep 15 '22 23:09 forcebewithyou