Skip to content

[BUG] String interpolation in Ruby client code dose not work  #2067

@autopp

Description

@autopp

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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

The interpolation in the error message of Ruby's client dose not work.

Swagger-codegen version
$ java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar version
4.0.0-SNAPSHOT

$ git log --oneline -n 1
0b66fa5c82 (HEAD -> master, origin/master, origin/HEAD) add servers to path, operation (#2048)
Swagger declaration file content or url

https://gist.github.com/autopp/5a7375cd9b521b5e5580ba3b1df40c75

The point to notice in this example contains enum in the model.

Command line used for generation
$ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i 'https://gist.githubusercontent.com/autopp/5a7375cd9b521b5e5580ba3b1df40c75/raw/ca1d5eccce457c7337922b4a6a74f002848e4b4c/swagger.yml' -l ruby -o /tmp/gem
Steps to reproduce
  • Run the above command to generate client code for Ruby.
  • Generated /tmp/gem/lib/openapi_client/models/x.rb contains string interpolation notation in single-quote string. (It dose not work!)
    def y=(y)
      validator = EnumAttributeValidator.new('String', ['a'])
      unless validator.valid?(y)
        fail ArgumentError, 'invalid value for "y", must be one of #{validator.allowable_values}.' # <= HERE!
      end
      @y = y
    end
Related issues/PRs
Suggest a fix/enhancement

The corresponding template is this.

I think that it should be a double-quote string.

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