File tree Expand file tree Collapse file tree 5 files changed +68
-1
lines changed Expand file tree Collapse file tree 5 files changed +68
-1
lines changed Original file line number Diff line number Diff line change 11import type { Client , ClientOptions } from "openapi-fetch"
22import 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}.
Original file line number Diff line number Diff line change 11export * from "./client.ts"
2+ export type * from "./interfaces/index.ts"
23export type * as OpenApi from "./openapi/index.ts"
Original file line number Diff line number Diff line change 1+ export type * from "./paths.ts"
Original file line number Diff line number Diff line change 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+ } )
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments