Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"license": "MIT",
"type": "module",
"scripts": {
"download": "node scripts/download",
"generate-types": "node scripts/generate-types",
"update-package": "node scripts/update-package",
"download": "node scripts/download.js",
"generate-types": "node scripts/generate-types.js",
"update-package": "node scripts/update-package.js",
"lint": "prettier --check '*.{md,json}' 'scripts/*.js' 'packages/**/*.{ts,md,json,d.ts}'",
"lint:fix": "prettier --write '*.{md,json}' 'scripts/*.js' 'packages/**/*.{ts,md,json,d.ts}'"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types-ghec/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126354,7 +126354,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types-ghes-3.14/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104161,7 +104161,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types-ghes-3.15/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104990,7 +104990,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types-ghes-3.16/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106446,7 +106446,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types-ghes-3.17/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106730,7 +106730,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types-ghes-3.18/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107812,7 +107812,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
2 changes: 1 addition & 1 deletion packages/openapi-types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114946,7 +114946,7 @@ export interface operations {
};
requestBody?: {
content: {
"application/octet-stream": string;
"application/octet-stream": string | File | Uint8Array | Blob;
};
};
responses: {
Expand Down
18 changes: 17 additions & 1 deletion scripts/generate-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,25 @@ type Repository = components["schemas"]["full-repository"]

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

const schemaTS = await openapiTS(`cache/${name}.json`, {
transform(schemaObject, metadata) {
if (
schemaObject.format === "binary" &&
metadata.path.endsWith("application/octet-stream")
) {
// Make sure that file upload endpoints don't use 'string' type for binary data
// Use some common types that can represent binary data in various environments
return schemaObject.nullable
? "string | File | Uint8Array | Blob | null"
: "string | File | Uint8Array | Blob";
}
return undefined;
},
});

await writeFile(
`packages/${packageName}/types.d.ts`,
await prettier.format(await openapiTS(`cache/${name}.json`), {
await prettier.format(schemaTS, {
parser: "typescript",
}),
);
Expand Down