Skip to content

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

Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom
isimluk:ruby-support-nested-wrapper-models
Oct 26, 2023
Merged

[ruby|client] Fix unmarshalling errors of enums inside other objects#16900
wing328 merged 2 commits intoOpenAPITools:masterfrom
isimluk:ruby-support-nested-wrapper-models

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
@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.

2 participants