Class: Apiwork::Adapter::Serializer::Error::Default::APIBuilder

Inherits:
Builder::API::Base show all
Defined in:
lib/apiwork/adapter/serializer/error/default/api_builder.rb

Instance Attribute Summary

Attributes inherited from Builder::API::Base

#data_type

Instance Method Summary collapse

Methods inherited from Builder::API::Base

#enum, #enum?, #initialize, #object, #type?, #union

Constructor Details

This class inherits a constructor from Apiwork::Adapter::Builder::API::Base

Instance Method Details

#buildObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/apiwork/adapter/serializer/error/default/api_builder.rb', line 9

def build
  enum(:error_layer, values: %w[http contract domain])

  object(:error_issue) do |object|
    object.string(:code)
    object.string(:detail)
    object.array(:path) do |array|
      array.of(:union) do |union|
        union.variant(&:string)
        union.variant(&:integer)
      end
    end
    object.string(:pointer)
    object.object(:meta)
  end

  object(data_type) do |object|
    object.reference(:layer, to: :error_layer)
    object.array(:issues) do |element|
      element.reference(:error_issue)
    end
  end
end