Class: Dry::Doc::Value
- Inherits:
-
Struct
- Object
- Struct
- Dry::Doc::Value
- Defined in:
- lib/dry/doc/value.rb
Defined Under Namespace
Modules: Types
Constant Summary collapse
- T =
::Dry::Types.module
Class Method Summary collapse
- .as_open_api ⇒ Object
- .attribute(name, type = nil, opts = {}, &nested) ⇒ Object
- .doc ⇒ Object
- .inspect ⇒ Object
- .ref ⇒ Object
- .types ⇒ Object
Instance Method Summary collapse
Class Method Details
.as_open_api ⇒ Object
40 41 42 |
# File 'lib/dry/doc/value.rb', line 40 def as_open_api doc.as_json end |
.attribute(name, type = nil, opts = {}, &nested) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dry/doc/value.rb', line 48 def attribute name, type=nil, opts={}, &nested if nested opts = type || {} inline_class = build_type :"#{self.name}::#{name}", &nested ::Dry::Doc::Value::Types::Inlines.add inline_class type = types.instance inline_class type = type.optional if opts[:optional] end doc.register name, type, description: opts.delete(:description) super name, type end |
.doc ⇒ Object
32 33 34 |
# File 'lib/dry/doc/value.rb', line 32 def doc @_doc ||= ::Dry::Doc::Schema.new self end |
.inspect ⇒ Object
62 63 64 |
# File 'lib/dry/doc/value.rb', line 62 def inspect "<#{name}>" end |
.ref ⇒ Object
44 45 46 |
# File 'lib/dry/doc/value.rb', line 44 def ref "#/definitions/#{@ref}" if @ref end |
Instance Method Details
#as_json(*_) ⇒ Object
76 77 78 |
# File 'lib/dry/doc/value.rb', line 76 def as_json *_ to_h end |