OpenAPITools / OpenAPITools/openapi-generator

[Question] Is oneOf supported in ruby openapi generator?

Open
#15,572 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Hi there, I have a question: is oneOf supported in the ruby openapi generator?

I'm having such a yaml file (see below) and then I'm trying to write an integration test for it, using ruby generated http client from openapi generator, like this:

before(:all) do
  @client = ::HttpClient::Api.new
 end

 it 'test' do
   some_setting...
   result = @client.get_lpn(paras)

When I run bundle exec rspec spec, it gives this error

NameError:
       uninitialized constant HttpClient::OneOfObjectAObjectB

Clearly, I don't have an object named OneOfObjectAObjectB. What I expect here is that the response can either be objectA or objectB.

Is this an expected result? How would you suggest if I want to achieve what I try to do here?
Appreciate any suggestions in advance!

openapi-generator version

cli-v5.2.0

OpenAPI declaration file content or url
paths:
/v2/endpoint:
    parameters:
     ...
    get:
      ...
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GetResponse'

components:
  schemas:
     GetResponse:
      type: object
      properties:
        data:
          type: object
          oneOf:
            - $ref: '#/components/schemas/objectA'
            - $ref: '#/components/schemas/objectB'
Command line used for generation

docker run openapitools/openapi-generator:cli-v5.2.0 generate ...

Steps to reproduce

N/A

Related issues/PRs

The most similar issue I found is: https://github.com/OpenAPITools/openapi-generator/issues/8441

Suggest a fix/enhancement

N/A

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

Reproduce the reported NameError with the cli-v5.2.0 Docker command, the shown OpenAPI schema, and the Ruby integration spec using HttpClient::Api#get_lpn. Inspect the generated Ruby client for OneOfObjectAObjectB and compare the behavior with related issue #8441; done means establishing whether oneOf is supported and documenting or correcting the observed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, ruby
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.