Skip to content

Commit 307c0e3

Browse files
authored
feat: handle large specs (#301)
1 parent a65bc67 commit 307c0e3

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

cli/src/core/getOpenAPISourceFile.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,32 +58,23 @@ export const getOpenAPISourceFile = async (
5858
`https://api.github.com/repos/${options.owner}/${options.repository}/contents/${options.specPath}?ref=${options.ref}`,
5959
{
6060
headers: {
61-
"content-type": "application/json",
61+
accept: "application/vnd.github.raw+json",
6262
"user-agent": "openapi-codegen",
6363
authorization: `bearer ${token}`,
6464
},
6565
}
66-
).json<{
67-
content: string;
68-
encoding: string | null;
69-
}>();
66+
).text();
7067

71-
if (!raw.content) {
68+
if (!raw) {
7269
throw new UsageError(`No content found at "${options.specPath}"`);
7370
}
7471

75-
const encoding: BufferEncoding =
76-
(raw.encoding as BufferEncoding) || "base64";
77-
const textContent = Buffer.from(raw.content, encoding).toString(
78-
"utf-8"
79-
);
80-
8172
let format: OpenAPISourceFile["format"] = "yaml";
8273
if (options.specPath.toLowerCase().endsWith("json")) {
8374
format = "json";
8475
}
8576

86-
return { text: textContent, format };
77+
return { text: raw, format };
8778
} catch (e) {
8879
if (
8980
e instanceof HTTPError &&

0 commit comments

Comments
 (0)