Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ This client is auto-generated by [openapi-typescript](https://github.com/openapi
## Usage

```sh
pnpm i @coderabbitai/bitbucket
pnpm add @coderabbitai/bitbucket
```

### Cloud

You can use the native `openapi-fetch` client or the `BitbucketCloudClient` class.

```ts
import { createBitbucketCloudClient } from "@coderabbitai/bitbucket/cloud"
import { toBase64 } from "@coderabbitai/bitbucket"
Expand All @@ -36,13 +38,51 @@ const client = createBitbucketCloudClient({
})
```

The `BitbucketCloudClient` wraps `openapi-fetch` requests by using the schema's `operationId` as method names.

```ts
import { BitbucketCloudClient } from "@coderabbitai/bitbucket/cloud"
import { toBase64 } from "@coderabbitai/bitbucket"
import {
BITBUCKET_CLOUD_APP_PASSWORD,
BITBUCKET_CLOUD_URL,
BITBUCKET_CLOUD_USERNAME,
} from "./env.js"

const basic = toBase64(
BITBUCKET_CLOUD_USERNAME + ":" + BITBUCKET_CLOUD_APP_PASSWORD,
)

const client = new BitbucketCloudClient({
baseUrl: BITBUCKET_CLOUD_URL.toString(),
headers: { Accept: "application/json", Authorization: `Basic ${basic}` },
})
```

### Server

You can use the native `openapi-fetch` client or the `BitbucketServerClient` class.

```ts
import { createBitbucketServerClient } from "@coderabbitai/bitbucket/server"
import { BITBUCKET_SERVER_TOKEN, BITBUCKET_SERVER_URL } from "./env.js"

const server = createBitbucketServerClient({
const client = createBitbucketServerClient({
baseUrl: BITBUCKET_SERVER_URL,
headers: {
Accept: "application/json",
Authorization: `Bearer ${BITBUCKET_SERVER_TOKEN}`,
},
})
```

The `BitbucketServerClient` wraps `openapi-fetch` requests by using the schema's `operationId` as method names.

```ts
import { BitbucketServerClient } from "@coderabbitai/bitbucket/server"
import { BITBUCKET_SERVER_TOKEN, BITBUCKET_SERVER_URL } from "./env.js"

const client = new BitbucketServerClient({
baseUrl: BITBUCKET_SERVER_URL,
headers: {
Accept: "application/json",
Expand Down
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@
"start": "node dist/main.js",
"test": "vitest run",
"test:watch": "vitest",
"openapi-typescript": "pnpm run openapi-typescript:cloud && pnpm run openapi-typescript:server",
"preopenapi-typescript:cloud": "curl --output ./src/cloud/openapi/swagger.v3.json https://dac-static.atlassian.com/cloud/bitbucket/swagger.v3.json",
"openapi-typescript:cloud": "openapi-typescript ./src/cloud/openapi/swagger.v3.json --output ./src/cloud/openapi/openapi-typescript.ts --immutable --empty-objects-unknown --alphabetize --root-types",
"postopenapi-typescript:cloud": "ts-autofix ./src/cloud/openapi && pnpm run lint:fix",
"preopenapi-typescript:server": "curl --output ./src/server/openapi/swagger.v3.json https://dac-static.atlassian.com/server/bitbucket/9.2.swagger.v3.json",
"openapi-typescript:server": "openapi-typescript ./src/server/openapi/swagger.v3.json --output ./src/server/openapi/openapi-typescript.ts --immutable --empty-objects-unknown --alphabetize --root-types",
"postopenapi-typescript:server": "ts-autofix ./src/server/openapi && pnpm run lint:fix"
"openapi": "./scripts/openapi.sh"
},
"dependencies": {
"openapi-fetch": "~0.17.0"
Expand All @@ -64,6 +58,7 @@
"jiti": "^2.7.0",
"markdownlint-cli2": "^0.22.1",
"openapi-typescript": "^7.13.0",
"openapi-typescript-helpers": "^0.1.0",
"prettier": "^3.8.4",
"ts-autofix": "^1.0.0",
"typedoc": "^0.28.19",
Expand Down
86 changes: 47 additions & 39 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading