OpenAPITools / OpenAPITools/openapi-generator

[BUG] [rust-server] Can't build library with conversion feature and special variable names

Open
#13,867 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

https://gist.githubusercontent.com/N-Schaef/fe8d962016e2d495e99d49aee09b53bb/raw/e10ddda48422d29b084832f52297e937da180da7/specification.json

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.