module Swagger::Blocks

Constants

VERSION

Public Class Methods

build_root_json(swaggered_classes) click to toggle source
# 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

  if data[:root_node].is_openapi_3_0?
    data[:root_node].key(:paths, data[:path_nodes]) # Required, so no empty check.
    if data[:component_node] && !data[:component_node].data.empty?
      data[:root_node].key(:components, data[:component_node])
    end
  end

  data[:root_node].as_json(version: data[:root_node].version)
end
included(base) click to toggle source

Inject the swagger_root, swagger_api_root, and swagger_model class methods.

# File lib/swagger/blocks/root.rb, line 8
def self.included(base)
  base.extend(ClassMethods)
end