Class: OpenAPIParser::Schemas::Responses

Inherits:
Base
  • Object
show all
Defined in:
lib/openapi_parser/schemas/classes.rb,
lib/openapi_parser/schemas/responses.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#object_reference, #parent, #raw_schema, #root

Instance Method Summary collapse

Methods inherited from Base

#after_init, #initialize, #inspect

Methods included from Expandable

#expand_reference

Methods included from Findable

#find_object, #purge_object_cache

Methods included from Parser

#_openapi_all_child_objects, #_update_child_object, included, #load_data

Constructor Details

This class inherits a constructor from OpenAPIParser::Schemas::Base

Instance Attribute Details

#defaultResponse, ... (readonly)

Returns default response object.

Returns:



7
# File 'lib/openapi_parser/schemas/responses.rb', line 7

openapi_attr_object :default, Response, reference: true

#responseHash{String => Response, Reference}? (readonly)

Returns:



11
# File 'lib/openapi_parser/schemas/responses.rb', line 11

openapi_attr_hash_body_objects 'response', Response, reject_keys: [:default], reference: true, allow_data_type: false

Instance Method Details

#validate(response_body, response_validate_options) ⇒ Object

validate params data by definition find response object by status_code and content_type github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#patterned-fields-1



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/openapi_parser/schemas/responses.rb', line 18

def validate(response_body, response_validate_options)
  return nil unless response

  if (res = find_response_object(response_body.status_code))

    return res.validate(response_body, response_validate_options)
  end

  raise ::OpenAPIParser::NotExistStatusCodeDefinition, object_reference if response_validate_options.strict

  nil
end