Armand Mégrot 07a9257ee9
[Ruby][client] Handle enums (and other scalars) in oneOf and anyOf schemas (#17515)
* Handle enums in oneOf and anyOf schemas

* Update specs
2024-01-05 15:01:08 +08:00

722 B

Petstore::MamalWithEnum

Class instance methods

openapi_one_of

Returns the list of classes defined in oneOf.

Example

require 'petstore'

Petstore::MamalWithEnum.openapi_one_of
# =>
# [
#   :'Cow'
# ]

build

Find the appropriate object from the openapi_one_of list and casts the data into it.

Example

require 'petstore'

Petstore::MamalWithEnum.build(data)
# => #<Cow:0x00007fdd4aab02a0>

Petstore::MamalWithEnum.build(data_that_doesnt_match)
# => nil

Parameters

Name Type Description
data Mixed data to be matched against the list of oneOf items

Return type

  • Cow
  • nil (if no type matches)