Skip to content

[BUG] scala-sttp string interpolation with backticks compiler error  #6883

@novakov-alexey-zz

Description

@novakov-alexey-zz

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • [ 5.0.0-beta] What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

If REST API method parameter is called type with backticks, then Scala compiler fails with:

nifi-client/target/generated-sources/openapi/src/gen/scala/main/org/openapitools/client/api/FlowApi.scala:569: error: invalid string interpolation $`, expected: $$, $identifier or ${expression}
[ERROR]       .method(Method.GET, uri"$baseUrl/flow/processor-types?bundleGroupFilter=$bundleGroupFilter&bundleArtifactFilter=$bundleArtifactFilter&type=$`type`")

Example is taken from NiFi REST API: https://nifi.apache.org/docs/nifi-docs/rest-api/index.html

Expected behavior: code compiles without an y error.

openapi-generator version
OpenAPI declaration file content or url
Command line used for generation

mvn clean install

Steps to reproduce
  1. Use Maven plugin:
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.0.0-beta</version>
  1. Specify generator as:
<generatorName>scala-sttp</generatorName>
  1. Specify NiFi swagger JSON file
  2. Run mvn clean install
Related issues/PRs
Suggest a fix

Possible solution: wrap Scala keyword like name, i.e. type with curly braces. i.e. generated string must be like this:

.method(Method.GET, uri"$baseUrl/flow/processor-types?bundleGroupFilter=$bundleGroupFilter&bundleArtifactFilter=$bundleArtifactFilter&type=${`type`}")

CC @ghostbuster91

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions