Class: Useless::Doc::Core::Body
- Inherits:
-
Object
- Object
- Useless::Doc::Core::Body
- Defined in:
- lib/useless/doc/core/body.rb
Overview
Documentation for an HTTP body, belonging either to the request or the response.
Defined Under Namespace
Classes: Attribute
Instance Attribute Summary collapse
-
#attributes ⇒ Array<Body::Attribute>
readonly
Documentation for each of the body attributes.
-
#content_type ⇒ String
readonly
The MIME type of the body.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Body
constructor
A new instance of Body.
Constructor Details
#initialize(attrs) ⇒ Body
Returns a new instance of Body.
21 22 23 24 |
# File 'lib/useless/doc/core/body.rb', line 21 def initialize(attrs) @content_type = attrs[:content_type] @attributes = attrs[:attributes] || [] end |
Instance Attribute Details
#attributes ⇒ Array<Body::Attribute> (readonly)
Returns documentation for each of the body attributes.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/useless/doc/core/body.rb', line 15 class Body attr_reader :content_type, :attributes # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @content_type = attrs[:content_type] @attributes = attrs[:attributes] || [] end # Documentation for an attribute on an HTTP body. # # @!attribute [r] key # @return [String] the key of this attribute in the body. # # @!attribute [r] value_type # @return [String] one of "string", "number", "object", # "array", or "boolean". "string" is the default value. # # @!attribute [r] required # @return [Boolean] whether or not the attribute is required. If it # is required, and the attribute is omitted, the response should have # a 4xx code. +true+ is the default value. # # @!attribute [r] description # @return [String] a description of the attribute. # class Attribute attr_reader :key, :type, :required, :default, :description # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end end end |
#content_type ⇒ String (readonly)
Returns the MIME type of the body.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/useless/doc/core/body.rb', line 15 class Body attr_reader :content_type, :attributes # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @content_type = attrs[:content_type] @attributes = attrs[:attributes] || [] end # Documentation for an attribute on an HTTP body. # # @!attribute [r] key # @return [String] the key of this attribute in the body. # # @!attribute [r] value_type # @return [String] one of "string", "number", "object", # "array", or "boolean". "string" is the default value. # # @!attribute [r] required # @return [Boolean] whether or not the attribute is required. If it # is required, and the attribute is omitted, the response should have # a 4xx code. +true+ is the default value. # # @!attribute [r] description # @return [String] a description of the attribute. # class Attribute attr_reader :key, :type, :required, :default, :description # @param [Hash] attrs corresponds to the class's instance attributes. # def initialize(attrs) @key = attrs[:key] @type = attrs[:type] || 'string' @required = attrs.key?(:required) ? attrs[:required] : true @default = attrs[:default] @description = attrs[:description] end end end |