From 1454346168297b08a949f41333946e0318879379 Mon Sep 17 00:00:00 2001 From: Dheeraj Panyam Date: Mon, 20 Jul 2026 17:34:45 +0530 Subject: [PATCH 1/2] feat(openapi-typescript): add --no-lint flag to skip Redocly linting --- .changeset/forty-parks-double.md | 5 +++++ docs/cli.md | 1 + packages/openapi-typescript/bin/cli.js | 2 ++ packages/openapi-typescript/src/index.ts | 1 + packages/openapi-typescript/src/lib/redoc.ts | 15 +++++++++------ packages/openapi-typescript/src/types.ts | 2 ++ packages/openapi-typescript/test/cli.test.ts | 10 ++++++++++ 7 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 .changeset/forty-parks-double.md diff --git a/.changeset/forty-parks-double.md b/.changeset/forty-parks-double.md new file mode 100644 index 000000000..e145e45b5 --- /dev/null +++ b/.changeset/forty-parks-double.md @@ -0,0 +1,5 @@ +--- +"openapi-typescript": minor +--- + +Add --no-lint flag to skip Redocly styleguide linting diff --git a/docs/cli.md b/docs/cli.md index 475f68da5..5b078f77b 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -127,6 +127,7 @@ The following flags are supported in the CLI: | `--make-paths-enum` | | `false` | Generate ApiPaths enum for all paths | | `--generate-path-params` | | `false` | Generate path parameters for all paths where they are undefined by schema | | `--read-write-markers` | | `false` | Generate `$Read`/`$Write` markers for readOnly/writeOnly properties | +| `--no-lint` | | `false` | Skip Redocly styleguide linting | ### pathParamsAsTypes diff --git a/packages/openapi-typescript/bin/cli.js b/packages/openapi-typescript/bin/cli.js index 31be6e795..4d8ffffea 100755 --- a/packages/openapi-typescript/bin/cli.js +++ b/packages/openapi-typescript/bin/cli.js @@ -38,6 +38,7 @@ Options --root-types-keep-casing Keep casing of root types (should only be used with --root-types) --make-paths-enum Generate ApiPaths enum for all paths --read-write-markers Generate $Read/$Write markers for readOnly/writeOnly properties + --no-lint Generate the types without linting `; const OUTPUT_FILE = "FILE"; @@ -96,6 +97,7 @@ const BOOLEAN_FLAGS = [ "rootTypes", "rootTypesKeepCasing", "rootTypesNoSchemaPrefix", + "lint", ]; const flags = parser(args, { diff --git a/packages/openapi-typescript/src/index.ts b/packages/openapi-typescript/src/index.ts index d042b81e4..cd7393ce2 100644 --- a/packages/openapi-typescript/src/index.ts +++ b/packages/openapi-typescript/src/index.ts @@ -64,6 +64,7 @@ export default async function openapiTS( redoc, cwd: options.cwd instanceof URL ? options.cwd : new URL(`file://${options.cwd ?? process.cwd()}/`), silent: options.silent ?? false, + lint: options.lint ?? true, }); const ctx: GlobalContext = { diff --git a/packages/openapi-typescript/src/lib/redoc.ts b/packages/openapi-typescript/src/lib/redoc.ts index 455695243..040a1164e 100644 --- a/packages/openapi-typescript/src/lib/redoc.ts +++ b/packages/openapi-typescript/src/lib/redoc.ts @@ -19,6 +19,7 @@ export interface ValidateAndBundleOptions { redoc: RedoclyConfig; silent: boolean; cwd?: URL; + lint?: boolean; } interface ParseSchemaOptions { @@ -142,12 +143,14 @@ export async function validateAndBundle( // 2. lint const redocLintT = performance.now(); - const problems = await lintDocument({ - document, - config: options.redoc.styleguide, - externalRefResolver: resolver, - }); - _processProblems(problems, options); + if (options.lint !== false) { + const problems = await lintDocument({ + document, + config: options.redoc.styleguide, + externalRefResolver: resolver, + }); + _processProblems(problems, options); + } debug("Linted schema", "lint", performance.now() - redocLintT); // 3. bundle diff --git a/packages/openapi-typescript/src/types.ts b/packages/openapi-typescript/src/types.ts index d19185cc6..998c59b28 100644 --- a/packages/openapi-typescript/src/types.ts +++ b/packages/openapi-typescript/src/types.ts @@ -623,6 +623,8 @@ export type SecurityRequirementObject = { }; export interface OpenAPITSOptions { + /** Run Redocly styleguide linting (default: true) */ + lint?: boolean; /** Treat all objects as if they have `additionalProperties: true` by default (default: false) */ additionalProperties?: boolean; /** Alphabetize all keys? (default: false) */ diff --git a/packages/openapi-typescript/test/cli.test.ts b/packages/openapi-typescript/test/cli.test.ts index b61aed0d5..620b64068 100644 --- a/packages/openapi-typescript/test/cli.test.ts +++ b/packages/openapi-typescript/test/cli.test.ts @@ -136,6 +136,16 @@ describe("CLI", () => { }); describe("Redocly config", () => { + test("--no-lint skips styleguide errors", async () => { + const fixtureDir = new URL("./fixtures/redocly-lint-error/", import.meta.url); + const outputFile = new URL("./output/openapi.ts", fixtureDir); + fs.rmSync(outputFile, { force: true }); + await execa(cmd, ["--redocly", "test/fixtures/redocly-lint-error/redocly.yaml", "--no-lint"], { + cwd, + }); + expect(fs.existsSync(outputFile)).toBe(true); + expect(fs.readFileSync(outputFile, "utf8")).toContain("export interface paths"); + }); test.skipIf(os.platform() === "win32")("automatic config", async () => { const cwd = new URL("./fixtures/redocly/", import.meta.url); From 32b9b7314408e9dc07ac3217564e7bf9c63a9a12 Mon Sep 17 00:00:00 2001 From: Dheeraj Panyam Date: Mon, 20 Jul 2026 23:52:38 +0530 Subject: [PATCH 2/2] ci: retrigger checks