Class: Literal::OpenAPI::Adapters::OpenAPI3_0
- Inherits:
-
BaseAdapter
- Object
- BaseAdapter
- Literal::OpenAPI::Adapters::OpenAPI3_0
- Defined in:
- lib/literal/openapi/adapters/open_api_3_0.rb
Direct Known Subclasses
Constant Summary
Constants inherited from BaseAdapter
BaseAdapter::PRIMITIVE_MAP, BaseAdapter::PROPERTY_KEY_ORDER
Instance Method Summary collapse
Methods inherited from BaseAdapter
#build_schema, #convert_class_type, #convert_primitive, #convert_ref, #convert_type, #convert_union, #inline_schema, #ref_schema?, #reorder_property_keys, #schema_name
Instance Method Details
#convert_nilable(type) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/literal/openapi/adapters/open_api_3_0.rb', line 8 def convert_nilable(type) inner = convert_type(type.type) # OpenAPI 3.0 disallows siblings to `$ref`, so `nullable: true` on a # ref is ignored. Emit an `anyOf` with a null branch instead. if inner.is_a?(::Hash) && inner.keys == ["$ref"] { "anyOf" => [inner, { "type" => "null" }] } else inner.merge("nullable" => true) end end |
#convert_oneof(types, include_null:) ⇒ Object
19 20 21 22 23 |
# File 'lib/literal/openapi/adapters/open_api_3_0.rb', line 19 def convert_oneof(types, include_null:) result = { "oneOf" => types.map { |t| convert_type(t) } } result["oneOf"] << { "nullable" => true } if include_null result end |