Skip to content

Commit

Permalink
[JSI multischema] ResourceBase.response_object_to_instances
Browse files Browse the repository at this point in the history
  • Loading branch information
notEthan committed Jul 2, 2020
1 parent 918013b commit 2a918c5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/scorpio/resource_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,14 @@ def request_schema_fail(object, schema)

def response_object_to_instances(object, initialize_options = {})
if object.is_a?(JSI::Base)
model = models_by_schema[object.schema]
models = object.jsi_schemas.map { |schema| models_by_schema[schema] }
if models.size == 0
model = nil
elsif models.size == 1
model = models.first
else
raise(Scorpio::OpenAPI::Error, "multiple models indicated by response JSI. models: #{models.inspect}; jsi: #{jsi.pretty_inspect.chomp}")
end
end

if object.respond_to?(:to_hash)
Expand Down

0 comments on commit 2a918c5

Please sign in to comment.