OpenAPITools / OpenAPITools/openapi-generator
[BUG] Ruby Generator creates invalid constant from enum
Nobody has claimed this yet.
- 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?
- 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
Generating a ruby client gem for nutanix APIs generates invalid ruby constants for enums that start with $
NameError:
undefined local variable or method `_UNKNOWN' for NutanixClustermgmt::ClustermgmtV40ConfigHypervisorType:Class
@all_vars ||= [AHV, ESX, HYPERV, XEN, NATIVEHOST, _UNKNOWN, _REDACTED].freeze
^^^^^^^^
openapi-generator version
openapi-generator-cli-7.17.0.jar
Also tested with openapi-generator-cli-7.18.0-20251123.092543-63.jar
OpenAPI declaration file content or url
https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/v4.0/yaml
clustermgmt.v4.0.config.ErasureCodeStatus:
type: string
description: Indicates the current status value of Erasure Coding for the Storage
Container.
enum:
- NONE
- "OFF"
- "ON"
- $UNKNOWN
- $REDACTED
x-enumDescriptions:
NONE: Option to ignore this option while creating the Storage Container.
$UNKNOWN: |
Unknown value.
"OFF": Erasure coding is disabled for the Storage Container instance.
$REDACTED: |
Redacted value.
"ON": Erasure coding is enabled for the Storage Container instance.
The spec validates with only warnings about unused models:
Validating spec (https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/v4.0/yaml)
Warnings:
- Unused model: clustermgmt.v4.0.config.UpdateRsyslogServerApiResponse
...
[info] Spec has 94 recommendation(s).
Generation Details
Steps to reproduce
java -jar openapi-generator-cli-7.17.0.jar generate --input-spec https://developers.nutanix.com/api/v1/namespaces/clustermgmt/versions/v4.0/yaml --generator-name ruby --config .openapi-config.json
$ cat .openapi-config.json
{
"gemName": "nutanix_clustermgmt",
"gemAuthor": "ManageIQ Developers",
"gemSummary": "Nutanix VMM API",
"gemDescription": "Ruby gem for Nutanix Cluster Management APIs",
"gemLicense": "Apache-2.0",
"useAutoload": true
}
$ bin/console
irb(main):001> NutanixClustermgmt::ClustermgmtV40ConfigHypervisorType.all_vars
/home/grare/adam/src/manageiq/nutanix_clustermgmt-sdk-ruby/lib/nutanix_clustermgmt/models/clustermgmt_v40_config_hypervisor_type.rb:27:in `all_vars': undefined local variable or method `_UNKNOWN' for class NutanixClustermgmt::ClustermgmtV40ConfigHypervisorType (NameError)
@all_vars ||= [AHV, ESX, HYPERV, XEN, NATIVEHOST, _UNKNOWN, _REDACTED].freeze
^^^^^^^^
from (irb):1:in `<main>'
from <internal:kernel>:187:in `loop'
from bin/console:15:in `<main>'
Related issues/PRs
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the documented openapi-generator CLI command, the Nutanix OpenAPI URL, and generator-name ruby, then inspect the generated clustermgmt_v40_config_hypervisor_type.rb model. Trace how enum values beginning with "$" become constants and add coverage for the affected enum; done means the generated Ruby model loads and all_vars works without NameError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100