Skip to content

Comments

Fix output.header config not applied to bundled client files#3438

Merged
mrlubos merged 5 commits intomainfrom
copilot/fix-output-header-config
Feb 23, 2026
Merged

Fix output.header config not applied to bundled client files#3438
mrlubos merged 5 commits intomainfrom
copilot/fix-output-header-config

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

  • Identify the bug: replaceImports in generate/client.ts used a hardcoded header instead of the configured output.header for bundled client files (when using bundle: true with @hey-api/client-* plugins)
  • Add outputHeaderToPrefix helper function to convert OutputHeader to a string prefix
  • Update replaceImports to accept and use the configured header parameter (without hardcoded fallback — default flows from getOutput)
  • Update generateClientBundle to accept header: OutputHeader and pass it to replaceImports
  • Update generate/output.ts to pass config.output.header to generateClientBundle
  • Add 6 tests for outputHeaderToPrefix logic in openapi-ts
  • Remove hardcoded fallback in openapi-ts/generate/client.ts — fully depend on output.header value from config
  • Apply the same outputHeaderToPrefix + header parameter pattern to openapi-python/generate/client.ts
  • Update openapi-python/generate/output.ts to pass config.output.header to generateClientBundle
  • Add 6 tests for outputHeaderToPrefix logic in openapi-python
  • Fix typecheck error: Array.isArray() doesn't narrow away ReadonlyArray<string> in the false branch; use typeof header === 'string' instead for proper type narrowing
  • All 590 tests pass; typecheck clean for both packages
Original prompt

This section details on the original issue you should resolve

<issue_title>output header does not seem to follow openapi-ts.config</issue_title>
<issue_description>### Description

Trying to add @ts-nocheck to the file header of each generated file, it doesn't seem to work. Below is my config

`import { defineConfig } from "@hey-api/openapi-ts";

export default defineConfig({
input: "./openapi.json",
output: {
header: [
"// This file is auto-generated by @hey-api/openapi-ts",
"// @ts-nocheck",
],
path: "src/references2",
},
plugins: [
"@hey-api/client-axios",
"@hey-api/schemas",
{
dates: true,
name: "@hey-api/transformers",
},
{
enums: "javascript",
name: "@hey-api/typescript",
},
{
name: "@hey-api/sdk",
transformer: true,
},
],
parser: {
transforms: {
enums: true,
},
}
});
`

Reproducible example or configuration

https://stackblitz.com/edit/hey-api-client-fetch-example

OpenAPI specification (optional)

No response

System information (optional)

No response</issue_description>

Comments on the Issue (you are @copilot in this section)

@mrlubos Please add a reproducible example! @mrlubos @SukkaW That sounds about right, will investigate

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hey-api-docs Ready Ready Preview, Comment Feb 23, 2026 7:12pm

Request Review

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: c66d565

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@hey-api/openapi-ts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix output header not including @ts-nocheck annotation Fix output.header config not applied to bundled client files Feb 23, 2026
Copilot AI requested a review from mrlubos February 23, 2026 18:14
@mrlubos
Copy link
Member

mrlubos commented Feb 23, 2026

@copilot remove the hard-coded default value altogether and fully depend on the output.header value flowing from the configuration. Add the same functionality to openapi-python if not already present.

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot remove the hard-coded default value altogether and fully depend on the output.header value flowing from the configuration. Add the same functionality to openapi-python if not already present.

Done in 077adc6. Removed the hardcoded fallback from replaceImports in openapi-ts — it now uses header ?? '' so the default flows entirely from output.header config (which defaults to '// This file is auto-generated by @hey-api/openapi-ts' in getOutput). Applied the same outputHeaderToPrefix + header parameter pattern to openapi-python/generate/client.ts and openapi-python/generate/output.ts.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 23, 2026
@mrlubos mrlubos marked this pull request as ready for review February 23, 2026 18:55
@pullfrog
Copy link

pullfrog bot commented Feb 23, 2026

Leaping into action...

Pullfrog  | View workflow run | Using OpenCode | Triggered by Pullfrogpullfrog.com𝕏

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. bug 🔥 Broken or incorrect behavior. labels Feb 23, 2026
@mrlubos
Copy link
Member

mrlubos commented Feb 23, 2026

@copilot Typecheck fails, can't use split on readonly array

… for ReadonlyArray

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 23, 2026

@copilot Typecheck fails, can't use split on readonly array

Fixed in c66d565. Array.isArray() has the signature (arg: any) => arg is any[] and doesn't narrow away ReadonlyArray<string> in the false branch, so TypeScript still saw string | ReadonlyArray<string> where .split() was called. Changed to typeof header === 'string' which correctly narrows to string / ReadonlyArray<string> in both branches.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 23, 2026

Open in StackBlitz

@hey-api/codegen-core

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/codegen-core@3438

@hey-api/json-schema-ref-parser

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/json-schema-ref-parser@3438

@hey-api/nuxt

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/nuxt@3438

@hey-api/openapi-ts

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/openapi-ts@3438

@hey-api/shared

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/shared@3438

@hey-api/types

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/types@3438

@hey-api/vite-plugin

npm i https://pkg.pr.new/hey-api/openapi-ts/@hey-api/vite-plugin@3438

commit: c66d565

@mrlubos mrlubos merged commit 14f2894 into main Feb 23, 2026
11 of 16 checks passed
@mrlubos mrlubos deleted the copilot/fix-output-header-config branch February 23, 2026 20:14
@hey-api hey-api bot mentioned this pull request Feb 23, 2026
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.09%. Comparing base (2faab85) to head (c66d565).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
packages/openapi-ts/src/generate/client.ts 0.00% 6 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3438      +/-   ##
==========================================
- Coverage   40.11%   40.09%   -0.02%     
==========================================
  Files         476      476              
  Lines       17459    17467       +8     
  Branches     5287     5293       +6     
==========================================
  Hits         7004     7004              
- Misses       8414     8418       +4     
- Partials     2041     2045       +4     
Flag Coverage Δ
unittests 40.09% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Broken or incorrect behavior. lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

output header does not seem to follow openapi-ts.config

2 participants