Skip to content

fix(params): honour integer/number format for query & path parameters (#23)#24

Merged
lightsofapollo merged 2 commits into
mainfrom
worktree-fix-i32-param-format
Jul 11, 2026
Merged

fix(params): honour integer/number format for query & path parameters (#23)#24
lightsofapollo merged 2 commits into
mainfrom
worktree-fix-i32-param-format

Conversation

@lightsofapollo

Copy link
Copy Markdown
Contributor

Problem

Fixes #23.

Query and path parameters ignored the schema format. analyze_parameter in src/analysis.rs hardcoded the Rust type per OpenAPI type:

crate::openapi::SchemaType::Integer => "i64",
crate::openapi::SchemaType::Number  => "f64",

This bypassed TypeMapper, which the schema-property path already routes through. So an int32 field inside a body correctly became i32, but the same format: int32 on a query/path parameter always became i64. Because the mapper was never consulted, no [type_mappings] or [generator.types.strategies] config could override it either — matching the reporter's "whatever I do, I always get i64."

Fix

Route parameter integer/number types through TypeMapper::integer_format / number_format, identical to the property path:

  • int32 -> i32, int64 -> i64
  • float -> f32, double -> f64
  • formatless integer stays i64 (unchanged default)
  • [type_mappings] / strategy config now applies to parameters

Tests

tests/parameter_integer_format_test.rs asserts the generated client signature for query parameters: int32 -> i32, int64 -> i64, formatless integer -> i64, float -> f32, double -> f64.

Verification

  • cargo test --all-features — green
  • cargo clippy --all-features -- -D warnings — clean
  • cargo fmt --check — clean
  • scripts/spec-compile.sh anthropic openai — both PASS

🤖 Generated with Claude Code

`analyze_parameter` hardcoded `Integer => i64` and `Number => f64`,
ignoring the schema `format` and bypassing the `TypeMapper` that the
schema-property path already routes through. A `format: int32` query
parameter therefore always rendered as `i64`, and no
`[type_mappings]`/strategy config could override it because the mapper
was never consulted.

Route parameter integer/number types through
`TypeMapper::integer_format`/`number_format`, matching the property
path: `int32 -> i32`, `int64 -> i64`, `float -> f32`, `double -> f64`,
formatless integers stay `i64`, and config now applies to parameters.

Adds tests/parameter_integer_format_test.rs covering int32/int64/
formatless integer and float/double query parameters.

Fixes #23

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lightsofapollo lightsofapollo marked this pull request as ready for review July 11, 2026 03:25
@lightsofapollo lightsofapollo merged commit 07fe4eb into main Jul 11, 2026
5 checks passed
lightsofapollo added a commit that referenced this pull request Jul 11, 2026
Includes #24: query/path parameters now honour integer/number format
(int32 -> i32, float -> f32, etc.). Fixes #23.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lightsofapollo added a commit that referenced this pull request Jul 11, 2026
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i32 impossible to set

1 participant