Class: Swagger::SwaggerObject
- Inherits:
-
Hashie::Dash
- Object
- Hashie::Dash
- Swagger::SwaggerObject
- Includes:
- Hashie::Extensions::Coercion, Hashie::Extensions::IndifferentAccess, Attachable
- Defined in:
- lib/swagger/swagger_object.rb
Overview
A class that represents an Object defined in the Swagger specification. Provides methods for defining fields in the object.
Direct Known Subclasses
API, V2::Header, V2::Info, V2::Info::Contact, V2::Info::License, V2::Operation, V2::Parameter, V2::Path, V2::Response, V2::SecurityScheme, V2::Tag
Constant Summary collapse
- CUSTOM_PROPERTY_PREFIX =
/^x\-/
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Attributes included from Attachable
Class Method Summary collapse
-
.field(name, type, opts = {}) ⇒ Object
private
Defines a Swagger field on a class.
-
.property?(name) ⇒ Boolean
Swagger allows any properties starting with
x-. -
.required_field(name, type, opts = {}) ⇒ Object
private
Defines a required Swagger field on a class.
Instance Method Summary collapse
-
#initialize(hash) ⇒ SwaggerObject
constructor
private
Initializes a Swagger object, using Hashie::Dash, and attaches to children objects so navigation via
parentandrootis possible.
Methods included from Attachable
#attach_parent, #attach_to_children, #root
Constructor Details
#initialize(hash) ⇒ SwaggerObject
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes a Swagger object, using Hashie::Dash, and attaches to children objects so navigation via parent and root is possible.
22 23 24 25 |
# File 'lib/swagger/swagger_object.rb', line 22 def initialize(hash) super attach_to_children end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
16 17 18 |
# File 'lib/swagger/swagger_object.rb', line 16 def parent @parent end |
Class Method Details
.field(name, type, opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines a Swagger field on a class.
33 34 35 36 |
# File 'lib/swagger/swagger_object.rb', line 33 def self.field(name, type, opts = {}) property name, opts coerce_key name, type end |
.property?(name) ⇒ Boolean
Swagger allows any properties starting with x-
12 13 14 |
# File 'lib/swagger/swagger_object.rb', line 12 def self.property?(name) super(name) || name.to_s =~ CUSTOM_PROPERTY_PREFIX end |
.required_field(name, type, opts = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Defines a required Swagger field on a class.
44 45 46 47 |
# File 'lib/swagger/swagger_object.rb', line 44 def self.required_field(name, type, opts = {}) opts[:required] = true field(name, type, opts) end |