Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ruby|client] Fix unmarshalling errors of enums inside other objects #16900

Merged

Conversation

isimluk
Copy link
Contributor

@isimluk isimluk commented Oct 25, 2023

Ruby|Client autogenerated model classes for Enums do not expose openapi_one_of method. Instead they expose openapi_any_of method like:

  # List of class defined in anyOf (OpenAPI v3)
  def openapi_any_of
    [
      :String
    ]
  end

Both types (objects and enums) do respond to build() method.

Addressing:

models/redacted_model.rb:1750:in `_deserialize': undefined method `build_from_hash' for XyzModel:Module (NoMethodError)

        klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
                                                                       ^^^^^^^^^^^^^^^^
        from models/redacted.rb:1705:in `block in build_from_hash'

  • PR checklist

Ruby|Client autogenerated model classes for Enums do not expose openapi_one_of
method. Instead they expose openapi_any_of method like:

      # List of class defined in anyOf (OpenAPI v3)
      def openapi_any_of
        [
          :String
        ]
      end

Both types (objects and enums) do respond to build() method.
@isimluk isimluk force-pushed the ruby-support-nested-wrapper-models branch from 1e75920 to 4ee5b78 Compare October 25, 2023 08:33
@isimluk
Copy link
Contributor Author

isimluk commented Oct 25, 2023

/cc ruby technical committee heroes: @cliffano, @zlx, @autopp

@wing328
Copy link
Member

wing328 commented Oct 26, 2023

lgtm. thanks for the PR.

@wing328 wing328 merged commit b13a1a0 into OpenAPITools:master Oct 26, 2023
16 checks passed
AlanCitrix pushed a commit to AlanCitrix/openapi-generator that referenced this pull request Oct 26, 2023
…penAPITools#16900)

* [ruby|client] Fix unmarshalling errors of enums inside other objects

Ruby|Client autogenerated model classes for Enums do not expose openapi_one_of
method. Instead they expose openapi_any_of method like:

      # List of class defined in anyOf (OpenAPI v3)
      def openapi_any_of
        [
          :String
        ]
      end

Both types (objects and enums) do respond to build() method.

* Regenerate samples
@isimluk isimluk deleted the ruby-support-nested-wrapper-models branch October 26, 2023 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants