Class: Schemacop::V3::BinaryNode
- Defined in:
- lib/schemacop/v3/binary_node.rb
Overview
Node type for binary data fields such as file uploads. Represented as
{ type: 'string', format: 'binary' } in JSON Schema / OpenAPI output.
At runtime, validates that the value is an instance of one of the
configured classes (using is_a?).
Default accepted classes (resolved lazily, missing classes are silently skipped):
ActionDispatch::Http::UploadedFileRack::Multipart::UploadedFileTempfileString
Constant Summary collapse
- DEFAULT_CLASSES =
Classes that are always available (stdlib).
[Tempfile, String].freeze
- OPTIONAL_CLASS_NAMES =
Optional classes resolved lazily via
safe_constantize(may not be available outside of Rails/Rack). %w[ ActionDispatch::Http::UploadedFile Rack::Multipart::UploadedFile ].freeze
Instance Attribute Summary
Attributes inherited from Node
#as, #default, #description, #name, #options, #parent, #require_key, #title
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Node
#cast, #cast_str_wrapper?, #children, create, #create, dsl_methods, #dsl_node, #dsl_scm, #initialize, #require_key?, #required?, resolve_class, #schemas, supports_children, supports_children_options, #used_external_schemas, #validate
Constructor Details
This class inherits a constructor from Schemacop::V3::Node
Class Method Details
.allowed_options ⇒ Object
32 33 34 |
# File 'lib/schemacop/v3/binary_node.rb', line 32 def self. super + %i[classes] end |
Instance Method Details
#as_json ⇒ Object
36 37 38 |
# File 'lib/schemacop/v3/binary_node.rb', line 36 def as_json process_json([], type: :string, format: :binary) end |