Skip to content

Commit 8c07ad9

Browse files
maxholmanclaude
andcommitted
fix: emit stringish types for HTTP header parameters
Header parameters now emit \`${number}\` and 'true'|'false' literal types instead of native number/boolean, matching how query and path parameters already work. HTTP headers are strings on the wire, and rest-client's Command<...> defaults its CommandHeaders generic to Record<string, string>. A generated header type containing a number-typed field could not satisfy that constraint, breaking command construction at the call site. The coerced valibot schema already accepts string|number on parse, so runtime behaviour is unchanged — only the user-facing input type widens. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 6dab841 commit 8c07ad9

3 files changed

Lines changed: 6 additions & 8 deletions

File tree

__tests__/__snapshots__/nullables.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ exports[`header parameters 1`] = `
2626
"export type UploadStatus = "pending" | "complete";
2727
export type UploadDataCommandHeader = {
2828
"content-type": "application/json" | "text/csv" | "application/xml";
29-
"content-length": number;
29+
"content-length": \`\${number}\`;
3030
"x-idempotency-key"?: string;
3131
};
3232
export type UploadDataCommandParams = {
@@ -135,7 +135,7 @@ export type ListFilesCommandQuery = {
135135
limit?: \`\${number}\` | undefined;
136136
};
137137
export type ListFilesCommandHeader = {
138-
"x-rate-limit": number;
138+
"x-rate-limit": \`\${number}\`;
139139
};
140140
export type ListFilesCommandInput = ListFilesCommandQuery;
141141
"

__tests__/fixtures/test1/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* WARN: Do not edit directly.
55
*
6-
* Generated on 2026-05-09T08:13:13.582Z
6+
* Generated on 2026-05-09T08:17:30.691Z
77
*
88
*/
99
import type { Jsonifiable, Jsonify } from "type-fest";
@@ -221,7 +221,7 @@ export type LongRunningOperation =
221221
| LongRunningOperationSuccess;
222222
export type ImportBillingDataCommandHeader = {
223223
"content-type": "application/json" | "text/csv" | "application/xml";
224-
"content-length": number;
224+
"content-length": `${number}`;
225225
"x-idempotency-key"?: string;
226226
};
227227
type ImportBillingDataCommandBodyApplicationOctetStream = NonNullable<

lib/process-document.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,8 @@ export async function processOpenApiDocument(
549549
name,
550550
hp.schema,
551551
{
552-
// headers are strings on the wire but
553-
// valibot parses them to native types
554-
booleanAsStringish: false,
555-
integerAsStringish: false,
552+
booleanAsStringish: true,
553+
integerAsStringish: true,
556554
},
557555
);
558556

0 commit comments

Comments
 (0)