MunifTanjim / node-bitbucket

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

Bitbucket API and Typescript Type Mismatch #128

Open forcebewithyou opened 1 year ago

forcebewithyou commented 1 year ago

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
MunifTanjim commented 1 year ago

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

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

forcebewithyou commented 1 year ago

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.

MunifTanjim commented 1 year ago

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.

forcebewithyou commented 1 year ago

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