Skip to content

Commit c462822

Browse files
committed
✨ openapi-typescript
1 parent d5821cf commit c462822

26 files changed

+152913
-41
lines changed

.env

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
BITBUCKET_CLOUD_URL=https://api.bitbucket.org/2.0
2+
BITBUCKET_CLOUD_USERNAME=
3+
BITBUCKET_CLOUD_APP_PASSWORD=
4+
5+
BITBUCKET_SERVER_URL=
6+
BITBUCKET_SERVER_TOKEN=

.markdownlint.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
default: true
22
line-length: false
33
no-inline-html: false
4+
no-hard-tabs:
5+
code_blocks: false
6+
spaces_per_tab: 2

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,49 @@
33
[![Node.js CI](https://github.com/coderabbitai/bitbucket/actions/workflows/node.js.yaml/badge.svg)](https://github.com/coderabbitai/bitbucket/actions/workflows/node.js.yaml) [![Dependabot Updates](https://github.com/coderabbitai/bitbucket/actions/workflows/dependabot/dependabot-updates/badge.svg)](https://github.com/coderabbitai/bitbucket/actions/workflows/dependabot/dependabot-updates) [![GitHub Pages](https://github.com/coderabbitai/bitbucket/actions/workflows/github-pages.yaml/badge.svg)](https://github.com/coderabbitai/bitbucket/actions/workflows/github-pages.yaml)
44

55
CodeRabbit's TypeScript API client for connecting to Bitbucket Cloud and Bitbucker Data Center.
6+
7+
- Bitbucket Cloud API docs: <https://developer.atlassian.com/cloud/bitbucket/rest>
8+
- Bitbucket Data Center API docs: <https://developer.atlassian.com/server/bitbucket/rest>
9+
10+
This client is auto-generated by [https://github.com/openapi-ts/openapi-typescript](https://github.com/openapi-ts/openapi-typescript/tree/main/packages/openapi-typescript) using the OpenAPI schema from the documentation above.
11+
12+
## Usage
13+
14+
```sh
15+
pnpm i @coderabbitai/bitbucket
16+
```
17+
18+
### Cloud
19+
20+
```ts
21+
import { createBitbucketCloudClient } from "@coderabbitai/bitbucket"
22+
import {
23+
BITBUCKET_CLOUD_APP_PASSWORD,
24+
BITBUCKET_CLOUD_URL,
25+
BITBUCKET_CLOUD_USERNAME,
26+
} from "./env.js"
27+
28+
const basic = Buffer.from(
29+
BITBUCKET_CLOUD_USERNAME + ":" + BITBUCKET_CLOUD_APP_PASSWORD,
30+
).toString("base64")
31+
32+
export const cloud = createBitbucketCloudClient({
33+
baseUrl: BITBUCKET_CLOUD_URL,
34+
headers: { Accept: "application/json", Authorization: `Basic ${basic}` },
35+
})
36+
```
37+
38+
### Server
39+
40+
```ts
41+
import { createBitbucketServerClient } from "@coderabbitai/bitbucket"
42+
import { BITBUCKET_SERVER_TOKEN, BITBUCKET_SERVER_URL } from "./env.js"
43+
44+
export const server = createBitbucketServerClient({
45+
baseUrl: BITBUCKET_SERVER_URL,
46+
headers: {
47+
Accept: "application/json",
48+
Authorization: `Bearer ${BITBUCKET_SERVER_TOKEN}`,
49+
},
50+
})
51+
```

package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@
3636
"lint": "eslint . && markdownlint-cli2 \"**/*.md\" && prettier --check .",
3737
"lint:fix": "eslint --fix --quiet .; markdownlint-cli2 \"**/*.md\" --fix; prettier --list-different --write .",
3838
"start": "node dist/main.js",
39-
"test": "vitest"
39+
"test": "vitest",
40+
"openapi-typescript": "pnpm run openapi-typescript:cloud && pnpm run openapi-typescript:server",
41+
"preopenapi-typescript:cloud": "curl --output ./src/cloud/openapi/swagger.v3.json https://dac-static.atlassian.com/cloud/bitbucket/swagger.v3.json",
42+
"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",
43+
"postopenapi-typescript:cloud": "ts-autofix ./src/cloud/openapi && pnpm run lint:fix",
44+
"preopenapi-typescript:server": "curl --output ./src/server/openapi/swagger.v3.json https://dac-static.atlassian.com/server/bitbucket/9.1.swagger.v3.json",
45+
"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",
46+
"postopenapi-typescript:server": "ts-autofix ./src/server/openapi && pnpm run lint:fix"
4047
},
4148
"devDependencies": {
4249
"@eslint/js": "^9.10.0",
@@ -46,6 +53,7 @@
4653
"eslint-config-prettier": "^9.1.0",
4754
"globals": "^15.9.0",
4855
"markdownlint-cli2": "^0.14.0",
56+
"openapi-typescript": "^7.4.0",
4957
"prettier": "^3.3.3",
5058
"tsx": "^4.19.1",
5159
"typedoc": "^0.26.7",
@@ -61,5 +69,8 @@
6169
}
6270
},
6371
"types": "dist/index.d.ts",
64-
"module": "dist/index.js"
72+
"module": "dist/index.js",
73+
"dependencies": {
74+
"openapi-fetch": "^0.12.0"
75+
}
6576
}

0 commit comments

Comments
 (0)