Class: Raml::Root

Inherits:
PropertiesNode show all
Includes:
Parent, SecuredBy, Validation
Defined in:
lib/raml/node/root.rb

Overview

RAML root node. Its parent is itself.

Instance Attribute Summary collapse

Attributes included from Parent

#children

Attributes inherited from PropertiesNode

#optional

Attributes inherited from Node

#name, #parent

Instance Method Summary collapse

Methods included from SecuredBy

#_validate_secured_by, #parse_secured_by

Methods included from Validation

#classes_to_s, #validate_array, #validate_hash, #validate_property, #validate_string

Methods inherited from PropertiesNode

#_regexp_property, #non_scalar_properties, #scalar_properties

Constructor Details

#initialize(root_data) ⇒ Root

Returns a new instance of Root.



76
77
78
# File 'lib/raml/node/root.rb', line 76

def initialize(root_data)
  super nil, root_data, self
end

Instance Attribute Details

#base_uriString

Returns the API base URI.

Returns:

  • (String)

    the API base URI.



# File 'lib/raml/node/root.rb', line 19

#base_uri_parametersHash<String, Raml::Parameter::BaseUriParameter> (readonly)

Returns the base URI parameters, keyed by the parameter name.

Returns:



# File 'lib/raml/node/root.rb', line 32

#documentsArray<Raml::Documentation> (readonly)

Returns the top level documentation.

Returns:



# File 'lib/raml/node/root.rb', line 29

#media_typeString Also known as: default_media_type

Returns the default request and response body media type.

Returns:

  • (String)

    the default request and response body media type.



# File 'lib/raml/node/root.rb', line 26

#protocolsArray<String>?

Returns the supported protocols. Nil or an array of up to two string elements from the set “HTTP” and “HTTPS”.

Returns:

  • (Array<String>, nil)

    the supported protocols. Nil or an array of up to two string elements from the set “HTTP” and “HTTPS”.



# File 'lib/raml/node/root.rb', line 22

#resource_typesHash<String, Raml::ResourceType> (readonly) Also known as: resource_type_declarations

Returns the resource type definitions, keyed by the resource type name.

Returns:



# File 'lib/raml/node/root.rb', line 45

#resourcesHash<String, Raml::Resource> (readonly)

Returns the nested resources, keyed by the resource relative path.

Returns:

  • (Hash<String, Raml::Resource>)

    the nested resources, keyed by the resource relative path.



# File 'lib/raml/node/root.rb', line 39

#schemasHash<String, Raml::Schema> (readonly) Also known as: schema_declarations

Returns the schema definitions, keyed by the schema name.

Returns:

  • (Hash<String, Raml::Schema>)

    the schema definitions, keyed by the schema name.



# File 'lib/raml/node/root.rb', line 36

#security_schemesHash<String, Raml::SecurityScheme> (readonly) Also known as: security_scheme_declarations

Returns the security scheme definitions, keyed by the security scheme name.

Returns:



51
52
# File 'lib/raml/node/root.rb', line 51

scalar_property :title      , :version    , :base_uri     ,
:protocols  , :media_type

#titleString

Returns API title.

Returns:

  • (String)

    API title.



# File 'lib/raml/node/root.rb', line 13

#traitsHash<String, Raml::Trait> (readonly) Also known as: trait_declarations

Returns the trait definitions, keyed by the trait name.

Returns:

  • (Hash<String, Raml::Trait>)

    the trait definitions, keyed by the trait name.



# File 'lib/raml/node/root.rb', line 42

#versionString?

Returns API version.

Returns:

  • (String, nil)

    API version.



# File 'lib/raml/node/root.rb', line 16

Instance Method Details

#expandObject

Applies resource types and traits, and inlines schemas. It should be called before documentation is generated.



82
83
84
85
86
87
88
89
# File 'lib/raml/node/root.rb', line 82

def expand
  unless @expanded
    resources.values.each(&:apply_resource_type)
    resources.values.each(&:apply_traits)
    inline_reference SchemaReference, schemas, @children
    @expanded = true
  end
end

#resource_pathObject



92
93
94
# File 'lib/raml/node/root.rb', line 92

def resource_path
  ''
end