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
12 changes: 6 additions & 6 deletions __tests__/fixtures/docker/.openapi-codegen-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/docker/commands.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/docker/enums.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/docker/hono.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/docker/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/docker/valibot.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions __tests__/fixtures/openai/.openapi-codegen-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/openai/commands.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/openai/enums.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/openai/hono.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/openai/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/openai/valibot.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions __tests__/fixtures/petstore/.openapi-codegen-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/petstore/hono.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions __tests__/fixtures/test1/.openapi-codegen-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion __tests__/fixtures/test1/hono.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions __tests__/lint-directives.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ async function buildIntoTempDir(parent: string, source: object = document) {

return {
dir,
valibot: await readFile(path.join(dir, "valibot.ts"), "utf8"),
main: await readFile(path.join(dir, "main.ts"), "utf8"),
valibot: await readFile(path.join(dir, "valibot.ts"), "utf-8"),
main: await readFile(path.join(dir, "main.ts"), "utf-8"),
};
}

Expand Down Expand Up @@ -148,7 +148,7 @@ test("a header schema is bracketed and an open body object still errors", async
test("a regeneration writes directives the recorded files lack", async () => {
const { dir } = await buildIntoTempDir(import.meta.dirname);
const manifestPath = path.join(dir, ".openapi-codegen-manifest.json");
const manifestText = await readFile(manifestPath, "utf8");
const manifestText = await readFile(manifestPath, "utf-8");
const manifest: unknown = JSON.parse(manifestText);

assert(typeof manifest === "object" && manifest !== null);
Expand All @@ -157,7 +157,7 @@ test("a regeneration writes directives the recorded files lack", async () => {
const names = entries.filter((name) => name.endsWith(".ts"));
const revisions = await Promise.all(
names.map(async (name) => {
const text = await readFile(path.join(dir, name), "utf8");
const text = await readFile(path.join(dir, name), "utf-8");
const bare = text.replace(/^\/\/ oxlint-disable .*\n\n/mu, "");

await writeFile(path.join(dir, name), bare);
Expand All @@ -175,7 +175,7 @@ test("a regeneration writes directives the recorded files lack", async () => {
);
await build(path.join(dir, "document.json"), dir);

const valibot = await readFile(path.join(dir, "valibot.ts"), "utf8");
const valibot = await readFile(path.join(dir, "valibot.ts"), "utf-8");

await rm(dir, { recursive: true });

Expand All @@ -191,7 +191,7 @@ test("no fixture directive names snake-case-wire-keys", async () => {
const modules = entries.filter((entry) => entry.endsWith(".ts"));
const directives = await Promise.all(
modules.map(async (entry) => {
const text = await readFile(path.join(fixtures, entry), "utf8");
const text = await readFile(path.join(fixtures, entry), "utf-8");

const directive = text.match(/^\/\/ oxlint-disable .*$/mu);

Expand Down
6 changes: 3 additions & 3 deletions __tests__/manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function buildOnce() {
}

async function readManifest(outputDir: string) {
const text = await readFile(path.join(outputDir, MANIFEST), "utf8");
const text = await readFile(path.join(outputDir, MANIFEST), "utf-8");

// oxlint-disable-next-line typescript/no-unsafe-type-assertion -- JSON.parse is typed any, and this reads back a manifest the build under test just wrote
return JSON.parse(text) as Record<string, string>;
Expand All @@ -61,7 +61,7 @@ test("a matching emitter revision leaves an unchanged file alone", async () => {
await writeFile(target, "// edited by hand\n");
await build(input, outputDir);

await expect(readFile(target, "utf8")).resolves.toBe("// edited by hand\n");
await expect(readFile(target, "utf-8")).resolves.toBe("// edited by hand\n");
});

// Guards a run that overlaps an edit, which stamps a manifest newer than
Expand All @@ -80,5 +80,5 @@ test("a stale emitter revision rewrites every file", async () => {

await build(input, outputDir);

await expect(readFile(target, "utf8")).resolves.toContain("@generated");
await expect(readFile(target, "utf-8")).resolves.toContain("@generated");
});
4 changes: 2 additions & 2 deletions lib/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function isOpenApiDocument(value: unknown): value is oas32.OpenAPIObject {
const MANIFEST = ".openapi-codegen-manifest.json";

async function readManifest(manifestPath: string) {
const text = await readFile(manifestPath, "utf8").catch(() => {});
const text = await readFile(manifestPath, "utf-8").catch(() => {});

if (text === undefined) {
return {};
Expand Down Expand Up @@ -152,7 +152,7 @@ export async function build(
// the blank line detaches the banner from the first import, which
// oxfmt would otherwise move with that import when it sorts them
const contents = `${BANNER}\n\n${file.getFullText()}`;
const original = await readFile(file.getFilePath(), "utf8").catch(
const original = await readFile(file.getFilePath(), "utf-8").catch(
() => {},
);

Expand Down
2 changes: 1 addition & 1 deletion lib/oxlint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const exemptRules = [
"block65/no-placeholder-comment",
"block65/no-banned-comment-words",
"block65/no-comment-list",
"block65/no-comment-punctuation",
"block65/max-comment-colons-and-semicolons",
"block65/no-trailing-comment-punctuation",
"block65/no-file-reference-in-comment",
"block65/no-file-header-comment",
Expand Down
7 changes: 6 additions & 1 deletion lib/process-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,11 @@ function resolveSchema(refs: Refs, operationId: string, schema: SchemaNode) {

// itemSchema arrived in OAS 3.2
function canStateItemSchema(openapiVersion: string) {
const [major = 0, minor = 0] = openapiVersion.split(".").map(Number);
const [major, minor] = openapiVersion.split(".").map(Number);

if (major === undefined || minor === undefined) {
return false;
}

return major > 3 || (major === 3 && minor >= 2);
}
Expand Down Expand Up @@ -1507,6 +1511,7 @@ function sequentialContent(
(variant !== itemSchema && (variant.oneOf || variant.anyOf))
) {
throw new Error(
// oxlint-disable-next-line typescript/no-open-string-fallback -- without a content property the variant is the payload, so the message names it generically
`${operationId}: each itemSchema variant needs its own ${contentProperty ?? "content"} schema`,
);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/process-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ function objectType(
);

return {
// oxlint-disable-next-line typescript/no-open-string-fallback -- `JsonValue` is the type of a record value the schema leaves unconstrained
type: recordType(value.type ?? "JsonValue"),
isReadonly: !!schemaObject.readOnly,
};
Expand All @@ -529,6 +530,7 @@ function stringType(schemaObject: SchemaObject) {

const temporal = temporalStringType(schemaObject.format);

// oxlint-disable-next-line typescript/no-open-string-fallback -- `string` is the type of a string schema without a temporal format
return temporal ?? "string";
}

Expand Down Expand Up @@ -865,6 +867,7 @@ export function registerTypesFromSchema(
// inline one of the same shape agree. It also spells the value type
// in TypeScript, since JSON Schema names such as `integer` differ
register(
// oxlint-disable-next-line typescript/no-open-string-fallback -- an object schema with no type of its own is an open record
schemaToType(typesAndInterfaces, {}, schemaName, schemaObject).type ??
"Record<string, JsonValue>",
schemaObject.description,
Expand Down
9 changes: 7 additions & 2 deletions lib/valibot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ const lazilyTyped = new WeakMap<Map<string, ValidatorEntry>, Set<string>>();
// oxlint groups integer digits in threes once a literal reaches five digits
function numericLiteral(value: number) {
const text = String(value);
const [integer = "", ...fraction] = text.split(".");
const [integer, ...fraction] = text.split(".");

if (integer === undefined) {
return text;
}

const digits = integer.replace("-", "");

if (digits.length < 5 || /\D/u.test(digits)) {
Expand Down Expand Up @@ -90,7 +95,7 @@ function vcall(
if (typeof item === "function") {
item(writer);
} else {
writer.write(item?.toString() ?? "undefined");
writer.write(String(item));
}
if (itemIndex < arg.length - 1) {
writer.write(", ");
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"@block65/rest-client": "^16.0.0",
"@block65/shared-config": "^0.7.0",
"@block65/shared-config": "^0.13.0",
"@block65/tsconfig": "^0.3.1",
"@hono/standard-validator": "^0.4.0",
"@types/node": "^26.6.3",
Expand All @@ -39,8 +39,8 @@
"js-yaml": "^5.4.2",
"openapi3-ts": "^4.6.1",
"oxfmt": "^0.70.0",
"oxlint": "^1.83.0",
"oxlint-tsgolint": "^7.0.2003",
"oxlint": "^1.93.0",
"oxlint-tsgolint": "^7.0.2006",
"type-fest": "^5.10.0",
"typescript": "^7.0.2",
"undici": "^8.11.2",
Expand Down
Loading
Loading