OpenAPITools / OpenAPITools/openapi-generator
[BUG] [rust-server] Can't build library with conversion feature and special variable names
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Specifications with reserved rust/openapi keywords (e.g.: "type") do not work with the conversion feature.
When compiling the generated library with the features server and conversion errors are thrown during compile time.
For every model containing these names the following error is thrown:
error[E0412]: cannot find type `uc_` in module `frunk_core::labelled::chars`
--> src/models.rs:8:43
|
8 | #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
| ^^^^^^^^^^^^^^^^^^^^^^ not found in `frunk_core::labelled::chars`
|
= note: this error originates in the derive macro `frunk::LabelledGeneric` (in Nightly builds, run with -Z macro-backtrace for more info)
In newer versions of the openAPI generator these types are renamed to r#<oldname> and frunk can't work with # in variable names.
openapi-generator version
latest and latest-release
Last working in versions 5.x.x
OpenAPI declaration file content or url
Generation Details
Using official docker image
Steps to reproduce
mkdir ~/tmp
cd ~/tmp
docker run --rm -v $(pwd):/local openapitools/openapi-generator-cli:latest generate -i https://gist.githubusercontent.com/N-Schaef/fe8d962016e2d495e99d49aee09b53bb/raw/e10ddda48422d29b084832f52297e937da180da7/specification.json -g rust-server -o /local
cargo build -F server -F conversion
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue from the linked OpenAPI declaration using the documented Docker command, then inspect the generated src/models.rs for reserved names and the conversion feature. Run cargo build -F server -F conversion; done means the generated rust-server library compiles successfully with models using those names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, rust
- Domain
- api, backend, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100