OpenAPITools / OpenAPITools/openapi-generator

[BUG][JAVA] java.lang.ClassCastException in ruby generator

Open
#15,831 1 comment 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

I'm trying to generate a ruby api client using the ruby generator but it has started throwing an exception. This is being thrown from a GitHub workflow step that runs npx @openapitools/openapi-generator-cli generate -g ruby -c openapi-generator-config.yaml -o . and that runs via the openapi-generators/openapitools-generator-action@v1 action.

Exception in thread "main" java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')
	at org.openapitools.codegen.languages.RubyClientCodegen.processOpts(RubyClientCodegen.java:208)
	at org.openapitools.codegen.DefaultGenerator.configureGeneratorProperties(DefaultGenerator.java:255)
	at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:945)
	at org.openapitools.codegen.cmd.Generate.execute(Generate.java:487)
	at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
	at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Error: Process completed with exit code 1.
openapi-generator version

6.6.0

OpenAPI declaration file content or url
name: publish ruby api client docs
on: workflow_dispatch
jobs:
  api-client-ruby:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: api_client_ruby
    steps:
      - uses: actions/checkout@v3
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.0.2
      - name: Get Spec
        id: get_spec
        run: |
          NEXT_VERSION=$(API=$API ruby getspec.rb)
          echo $NEXT_VERSION
          echo gemVersion: $NEXT_VERSION >> openapi-generator-config.yaml
          echo "next_version=$NEXT_VERSION" >> $GITHUB_OUTPUT
        env:
          API:  https://api.songtradr.com/v3/api-docs
      - name: Generate Client
        uses: openapi-generators/openapitools-generator-action@v1
        with:
          generator: ruby
          config-file: api_client_ruby/openapi-generator-config.yaml
          openapi-url: $API
          command-args: -o api_client_ruby
        env:
          API: https://api.songtradr.com/v3/api-docs
Generation Details
library: faraday
moduleName: SongtradrApiClientRuby
gemHomepage: https://songtradr.com
gemAuthor: songtradr
gemAuthorEmail: daryl.findlay@songtradr.com
gemSummary: Basic client for Songtradr API, generated with openapi-generator
gemLicense: MIT
inputSpec: https://api.songtradr.com/v3/api-docs
# gemVersion: this is appended during workflow
Steps to reproduce

Steps are in the workflow yaml.

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

Start in RubyClientCodegen.processOpts at RubyClientCodegen.java:208 and reproduce the failure using the supplied workflow configuration, API URL, and ruby generator command. Check how the values in openapi-generator-config.yaml are read, then verify generation completes without the ClassCastException and add or run a regression test if the repository provides one for Ruby generator options.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.