File tree Expand file tree Collapse file tree 2 files changed +30
-2
lines changed
Expand file tree Collapse file tree 2 files changed +30
-2
lines changed Original file line number Diff line number Diff line change 11import { safeParse } from "fast-content-type-parse" ;
2- import { JSONParse } from "json-with-bigint" ;
2+ import { JSONParse , JSONStringify } from "json-with-bigint" ;
33import { isPlainObject } from "./is-plain-object.js" ;
44import { RequestError } from "@octokit/request-error" ;
55import type { EndpointInterface , OctokitResponse } from "@octokit/types" ;
@@ -27,7 +27,7 @@ export default async function fetchWrapper(
2727
2828 const body =
2929 isPlainObject ( requestOptions . body ) || Array . isArray ( requestOptions . body )
30- ? JSON . stringify ( requestOptions . body )
30+ ? JSONStringify ( requestOptions . body )
3131 : requestOptions . body ;
3232
3333 // Header values must be `string`
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import type {
1414} from "@octokit/types" ;
1515
1616import { request } from "../src/index.ts" ;
17+ import { JSONStringify } from "json-with-bigint" ;
1718
1819const userAgent = `octokit-request.js/0.0.0-development ${ getUserAgent ( ) } ` ;
1920const __filename = new URL ( import . meta. url ) ;
@@ -1365,4 +1366,31 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
13651366 expect ( response . status ) . toEqual ( 200 ) ;
13661367 expect ( response . data [ 0 ] . id ) . toEqual ( BigInt ( Number . MAX_SAFE_INTEGER ) + 9n ) ;
13671368 } ) ;
1369+
1370+ it ( "properly serialises request bodies that contain int64 (BigInt)" , async ( ) => {
1371+ expect . assertions ( 2 ) ;
1372+
1373+ const id = BigInt ( Number . MAX_SAFE_INTEGER ) + 9n ;
1374+ const mock = fetchMock . createInstance ( ) ;
1375+ mock . get ( "https://api.github.com/app/hook/deliveries" , {
1376+ status : 200 ,
1377+ headers : {
1378+ "Content-Type" : "application/json; charset=utf-8" ,
1379+ } ,
1380+ body : JSONStringify ( {
1381+ id : id ,
1382+ } ) ,
1383+ } ) ;
1384+
1385+ const response = await request ( "GET /app/hook/deliveries/{delivery_id}" , {
1386+ // @ts -expect-error The types won't allw BigInt until https://github.com/octokit/openapi-types.ts/pull/489 is merged and released
1387+ delivery_id : id ,
1388+ request : {
1389+ fetch : mock . fetchHandler ,
1390+ } ,
1391+ } ) ;
1392+
1393+ expect ( response . status ) . toEqual ( 200 ) ;
1394+ expect ( response . data . id ) . toEqual ( id ) ;
1395+ } ) ;
13681396} ) ;
You can’t perform that action at this time.
0 commit comments