fix: apply integer type fitting for Rust params#22853
fix: apply integer type fitting for Rust params#22853wing328 merged 1 commit intoOpenAPITools:masterfrom
Conversation
|
thanks for the PR please review the build failure when you've time |
|
cc @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) @dsteeley (2025/07) |
|
Code changes LGTM. Tests need resolving. |
We already have logic in postProcessModelProperty to fit integer parameters into the correct Rust primitives. However, this doesn't apply to other kinds of parameters so integer-typed parameters which end up in function calls for Api traits in lib.rs are always i32, even when this is improper. This commit refactors integer type fitting so that we can run it on both processParam and model post-processing.
a8fe886 to
cbc71d7
Compare
|
Thanks both - I did update the samples, so turns out the bug was functional rather than in the tests; we don't apply processing on Applying parameter processing there and updating the samples again should fix the issue, although now it looks like my CI is failing on circleCI but I don't really understand what the problem is; looks like a setup failure, are the tests flaky at all? |
|
circleci failure not related to this change |
We already have logic in postProcessModelProperty to fit integer parameters into the correct Rust primitives. However, this doesn't apply to other kinds of parameters so integer-typed parameters which end up in function calls for Api traits in lib.rs are always i32, even when this is improper.
This commit refactors integer type fitting so that we can run it on both processParam and model post-processing.
Testing
I've included a new
RustServerCodegenTestfile and aninteger-params.yamltest case to cover the new function (and also checked this locally against the API definition which prompted me to contribute this).PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Fixes integer parameter types in the Rust server generator so API trait, client, and server signatures use the correct Rust integer size and signedness instead of defaulting to i32. Applies integer fitting based on format and min/max to both parameters and model properties, and updates samples.
Bug Fixes
Refactors
Written for commit a8fe886. Summary will update on new commits.