Skip to content

Commit 17696f6

Browse files
fix: add additional types to binary body endpoints (#481)
Fixes octokit/octokit.js#2904 * remove GHES 3.19 for now It needs to be manually published, since OIDC is still in it's infancy and needs to be declared per package. Which means that new packages cannot be published from CI --------- Co-authored-by: wolfy1339 <webmaster@wolfy1339.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 16bf67a commit 17696f6

10 files changed

Lines changed: 32 additions & 22 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
"license": "MIT",
99
"type": "module",
1010
"scripts": {
11-
"download": "node scripts/download",
12-
"generate-types": "node scripts/generate-types",
13-
"update-package": "node scripts/update-package",
11+
"download": "node scripts/download.js",
12+
"generate-types": "node scripts/generate-types.js",
13+
"update-package": "node scripts/update-package.js",
1414
"lint": "prettier --check '*.{md,json}' 'scripts/*.js' 'packages/**/*.{ts,md,json,d.ts}'",
1515
"lint:fix": "prettier --write '*.{md,json}' 'scripts/*.js' 'packages/**/*.{ts,md,json,d.ts}'"
1616
},
@@ -19,7 +19,7 @@
1919
"@octokit/plugin-paginate-rest": "^13.0.0",
2020
"github-enterprise-server-versions": "^3.0.0",
2121
"openapi-typescript": "^6.2.1",
22-
"prettier": "3.6.2"
22+
"prettier": "3.7.4"
2323
},
2424
"prettier": {},
2525
"release": {
@@ -72,12 +72,6 @@
7272
{
7373
"pkgRoot": "packages/openapi-types-ghes-3.18"
7474
}
75-
],
76-
[
77-
"@semantic-release/npm",
78-
{
79-
"pkgRoot": "packages/openapi-types-ghes-3.19"
80-
}
8175
]
8276
]
8377
}

packages/openapi-types-ghec/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126712,7 +126712,7 @@ export interface operations {
126712126712
};
126713126713
requestBody?: {
126714126714
content: {
126715-
"application/octet-stream": string;
126715+
"application/octet-stream": string | File | Uint8Array | Blob;
126716126716
};
126717126717
};
126718126718
responses: {

packages/openapi-types-ghes-3.14/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104703,7 +104703,7 @@ export interface operations {
104703104703
};
104704104704
requestBody?: {
104705104705
content: {
104706-
"application/octet-stream": string;
104706+
"application/octet-stream": string | File | Uint8Array | Blob;
104707104707
};
104708104708
};
104709104709
responses: {

packages/openapi-types-ghes-3.15/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105466,7 +105466,7 @@ export interface operations {
105466105466
};
105467105467
requestBody?: {
105468105468
content: {
105469-
"application/octet-stream": string;
105469+
"application/octet-stream": string | File | Uint8Array | Blob;
105470105470
};
105471105471
};
105472105472
responses: {

packages/openapi-types-ghes-3.16/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106937,7 +106937,7 @@ export interface operations {
106937106937
};
106938106938
requestBody?: {
106939106939
content: {
106940-
"application/octet-stream": string;
106940+
"application/octet-stream": string | File | Uint8Array | Blob;
106941106941
};
106942106942
};
106943106943
responses: {

packages/openapi-types-ghes-3.17/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106213,7 +106213,7 @@ export interface operations {
106213106213
};
106214106214
requestBody?: {
106215106215
content: {
106216-
"application/octet-stream": string;
106216+
"application/octet-stream": string | File | Uint8Array | Blob;
106217106217
};
106218106218
};
106219106219
responses: {

packages/openapi-types-ghes-3.18/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107310,7 +107310,7 @@ export interface operations {
107310107310
};
107311107311
requestBody?: {
107312107312
content: {
107313-
"application/octet-stream": string;
107313+
"application/octet-stream": string | File | Uint8Array | Blob;
107314107314
};
107315107315
};
107316107316
responses: {

packages/openapi-types/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115641,7 +115641,7 @@ export interface operations {
115641115641
};
115642115642
requestBody?: {
115643115643
content: {
115644-
"application/octet-stream": string;
115644+
"application/octet-stream": string | File | Uint8Array | Blob;
115645115645
};
115646115646
};
115647115647
responses: {

scripts/generate-types.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,25 @@ type Repository = components["schemas"]["full-repository"]
8585

8686
await copyFile("LICENSE", `packages/${packageName}/LICENSE`);
8787

88+
const schemaTS = await openapiTS(`cache/${name}.json`, {
89+
transform(schemaObject, metadata) {
90+
if (
91+
schemaObject.format === "binary" &&
92+
metadata.path.endsWith("application/octet-stream")
93+
) {
94+
// Make sure that file upload endpoints don't use 'string' type for binary data
95+
// Use some common types that can represent binary data in various environments
96+
return schemaObject.nullable
97+
? "string | File | Uint8Array | Blob | null"
98+
: "string | File | Uint8Array | Blob";
99+
}
100+
return undefined;
101+
},
102+
});
103+
88104
await writeFile(
89105
`packages/${packageName}/types.d.ts`,
90-
await prettier.format(await openapiTS(`cache/${name}.json`), {
106+
await prettier.format(schemaTS, {
91107
parser: "typescript",
92108
}),
93109
);

0 commit comments

Comments
 (0)