Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 26db646

Browse files
🏷️ Override Bitbucket Cloud's schema to create new branches (#41)
* 🏷️ Override Bitbucket Cloud's schema to create new branches * 🔥 Remove test accidentally left in
1 parent 9a7ae79 commit 26db646

File tree

5 files changed

+68
-1
lines changed

5 files changed

+68
-1
lines changed

‎src/cloud/client.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Client, ClientOptions } from "openapi-fetch"
22
import createClient from "openapi-fetch"
3-
import type { paths } from "./openapi/index.ts"
3+
import type { paths } from "./interfaces/paths.ts"
44

55
/**
66
* Creates an `openapi-fetch` client using {@link createClient}.

‎src/cloud/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./client.ts"
2+
export type * from "./interfaces/index.ts"
23
export type * as OpenApi from "./openapi/index.ts"

‎src/cloud/interfaces/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type * from "./paths.ts"

‎src/cloud/interfaces/paths.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { test } from "vitest"
2+
import { createBitbucketCloudClient } from "../client.js"
3+
import type { CreateBranchRequest } from "./paths.ts"
4+
5+
async function fetch() {
6+
const response = new Response(JSON.stringify({}), { status: 200 })
7+
return Promise.resolve(response)
8+
}
9+
10+
const client = createBitbucketCloudClient({
11+
baseUrl: "https://api.bitbucket.org/2.0",
12+
fetch,
13+
})
14+
15+
test("CreateBranchRequest", async ({ expect }) => {
16+
const example: CreateBranchRequest = {
17+
name: "smf/create-feature",
18+
target: { hash: "default" },
19+
}
20+
21+
const { response } = await client.POST(
22+
"/repositories/{workspace}/{repo_slug}/refs/branches",
23+
{
24+
params: { path: { repo_slug: "repo_slug", workspace: "workspace" } },
25+
body: example,
26+
},
27+
)
28+
29+
expect(response.status).toBe(200)
30+
})

‎src/cloud/interfaces/paths.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import type { paths as openapi } from "../openapi/openapi-typescript.ts"
2+
3+
/**
4+
* Overrides Bitbucket Cloud's OpenAPI schema.
5+
*/
6+
export interface paths
7+
extends Omit<openapi, "/repositories/{workspace}/{repo_slug}/refs/branches"> {
8+
readonly "/repositories/{workspace}/{repo_slug}/refs/branches": Omit<
9+
openapi["/repositories/{workspace}/{repo_slug}/refs/branches"],
10+
"post"
11+
> & {
12+
readonly post: Omit<
13+
openapi["/repositories/{workspace}/{repo_slug}/refs/branches"]["post"],
14+
"requestBody"
15+
> & {
16+
readonly requestBody: {
17+
readonly content: {
18+
readonly "application/json": CreateBranchRequest
19+
}
20+
}
21+
}
22+
}
23+
}
24+
25+
/** Request to create a branch. */
26+
export interface CreateBranchRequest {
27+
/** Name of the new branch */
28+
readonly name: string
29+
/** Where to point the new branch to */
30+
readonly target: Target
31+
}
32+
33+
export interface Target {
34+
readonly hash: string
35+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /