Skip to content

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

@N-Schaef

Description

@N-Schaef

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions