Module: Swagger::Blocks

Defined in:
lib/swagger/blocks.rb,
lib/swagger/blocks/node.rb,
lib/swagger/blocks/root.rb,
lib/swagger/blocks/errors.rb,
lib/swagger/blocks/version.rb,
lib/swagger/blocks/class_methods.rb,
lib/swagger/blocks/nodes/tag_node.rb,
lib/swagger/blocks/nodes/xml_node.rb,
lib/swagger/blocks/nodes/info_node.rb,
lib/swagger/blocks/nodes/path_node.rb,
lib/swagger/blocks/nodes/root_node.rb,
lib/swagger/blocks/internal_helpers.rb,
lib/swagger/blocks/nodes/items_node.rb,
lib/swagger/blocks/nodes/all_of_node.rb,
lib/swagger/blocks/nodes/header_node.rb,
lib/swagger/blocks/nodes/schema_node.rb,
lib/swagger/blocks/nodes/scopes_node.rb,
lib/swagger/blocks/nodes/contact_node.rb,
lib/swagger/blocks/nodes/example_node.rb,
lib/swagger/blocks/nodes/license_node.rb,
lib/swagger/blocks/nodes/property_node.rb,
lib/swagger/blocks/nodes/response_node.rb,
lib/swagger/blocks/nodes/operation_node.rb,
lib/swagger/blocks/nodes/parameter_node.rb,
lib/swagger/blocks/nodes/properties_node.rb,
lib/swagger/blocks/nodes/external_docs_node.rb,
lib/swagger/blocks/nodes/security_scheme_node.rb,
lib/swagger/blocks/nodes/security_requirement_node.rb

Defined Under Namespace

Modules: ClassMethods, InternalHelpers, Nodes Classes: DeclarationError, Error, Node, NotFoundError, NotSupportedError

Constant Summary collapse

VERSION =
'2.0.0'

Class Method Summary collapse

Class Method Details

.build_root_json(swaggered_classes) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/swagger/blocks/root.rb', line 12

def self.build_root_json(swaggered_classes)
  data = Swagger::Blocks::InternalHelpers.parse_swaggered_classes(swaggered_classes)

  if data[:root_node].is_swagger_2_0?
    data[:root_node].key(:paths, data[:path_nodes]) # Required, so no empty check.
    if data[:schema_nodes] && !data[:schema_nodes].empty?
      data[:root_node].key(:definitions, data[:schema_nodes])
    end
  end

  data[:root_node].as_json
end

.included(base) ⇒ Object

Inject the swagger_root, swagger_api_root, and swagger_model class methods.


8
9
10
# File 'lib/swagger/blocks/root.rb', line 8

def self.included(base)
  base.extend(ClassMethods)
end