Class: Raml::Body
- Inherits:
-
PropertiesNode
- Object
- Node
- PropertiesNode
- Raml::Body
- Includes:
- Global, Merge, Parent, Validation
- Defined in:
- lib/raml/node/body.rb
Constant Summary collapse
- MEDIA_TYPE_RE =
%r{[a-z\d][-\w.+!#$&^]{0,63}/[a-z\d][-\w.+!#$&^]{0,63}(;.*)?}oi
Instance Attribute Summary collapse
-
#example ⇒ String?
An example of a valid body.
-
#form_parameters ⇒ Hash<String, Raml::Parameter::FormParameter>
readonly
The form parameters, keyed by the parameter name.
-
#media\_type ⇒ String
readonly
Media type of the of body.
-
#schema ⇒ Raml::Schema?
readonly
The body’s schema.
Attributes included from Parent
Attributes inherited from PropertiesNode
Attributes inherited from Node
Instance Method Summary collapse
- #merge(other) ⇒ Object
-
#web_form? ⇒ Boolean
Returns whether the body is a web form.
Methods included from Validation
#classes_to_s, #validate_array, #validate_hash, #validate_property, #validate_string
Methods included from Merge
Methods included from Global
#default_media_type, #resource_type_declarations, #schema_declarations, #security_scheme_declarations, #trait_declarations
Methods inherited from PropertiesNode
#_regexp_property, #initialize, #non_scalar_properties, #scalar_properties
Methods inherited from Node
Constructor Details
This class inherits a constructor from Raml::PropertiesNode
Instance Attribute Details
#example ⇒ String?
Returns an example of a valid body.
|
# File 'lib/raml/node/body.rb', line 13
|
#form_parameters ⇒ Hash<String, Raml::Parameter::FormParameter> (readonly)
Returns the form parameters, keyed by the parameter name. Only valid for “application/x-www-form-urlencoded” and “multipart/form-data” media types.
|
# File 'lib/raml/node/body.rb', line 16
|
#media\_type ⇒ String (readonly)
Returns media type of the of body. An alias for #name.
28 |
# File 'lib/raml/node/body.rb', line 28 scalar_property :example |
#schema ⇒ Raml::Schema? (readonly)
Returns the body’s schema. Only valid if the media type is not one of “application/x-www-form-urlencoded” or “multipart/form-data”.
|
# File 'lib/raml/node/body.rb', line 21
|
Instance Method Details
#merge(other) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/raml/node/body.rb', line 45 def merge(other) raise MergeError, "Media types don't match." if media_type != other.media_type super merge_properties other, :form_parameters if other.schema @children.delete_if { |c| [ Schema, SchemaReference ].include? c.class } if schema @children << other.schema end self end |
#web_form? ⇒ Boolean
Returns whether the body is a web form. Returns true for “application/x-www-form-urlencoded” and “multipart/form-data” media types.
40 41 42 |
# File 'lib/raml/node/body.rb', line 40 def web_form? [ 'application/x-www-form-urlencoded', 'multipart/form-data' ].include? media_type end |