Class: Swagger::V2::APIDeclaration

Inherits:
APIDeclaration show all
Defined in:
lib/swagger/v2/api_declaration.rb

Direct Known Subclasses

Builder

Instance Attribute Summary collapse

Attributes inherited from DefinitionSection

#parent

Instance Method Summary collapse

Methods inherited from APIDeclaration

build, #initialize

Methods inherited from DefinitionSection

#initialize, required_section, section

Methods included from Attachable

#attach_parent, #attach_to_children, #root

Constructor Details

This class inherits a constructor from Swagger::APIDeclaration

Instance Attribute Details

#apisObject (readonly)

def initialize(hash)

super
attach_to_apis

end



24
25
26
# File 'lib/swagger/v2/api_declaration.rb', line 24

def apis
  @apis
end

#infoInfo

Required.

Returns:



12
# File 'lib/swagger/v2/api_declaration.rb', line 12

required_section :info, Info

#pathsHash[String => Path]

Required.

Returns:

  • (Hash[String => Path])


13
# File 'lib/swagger/v2/api_declaration.rb', line 13

required_section :paths, Hash[String => Path]

#swaggerFloat

Required.

Returns:

  • (Float)


11
# File 'lib/swagger/v2/api_declaration.rb', line 11

required_section :swagger, Float

Instance Method Details

#fully_validateObject



46
47
48
49
50
51
# File 'lib/swagger/v2/api_declaration.rb', line 46

def fully_validate
  # FIXME: fully_validate is ideal, but very slow with the current schema/validator
  errors = JSON::Validator.fully_validate(swagger_schema, to_json)
  fail Swagger::InvalidDefinition, errors unless errors.empty?
  true
end

#uri_templateObject



40
41
42
43
44
# File 'lib/swagger/v2/api_declaration.rb', line 40

def uri_template
  # TODO: Can calculated values be safely memoized?
  # TODO: Actual URI Template objects or just strings?
  "#{host}#{basePath}"
end

#validateObject



53
54
55
56
57
# File 'lib/swagger/v2/api_declaration.rb', line 53

def validate
  JSON::Validator.validate!(swagger_schema, to_json)
rescue JSON::Schema::ValidationError => e
  raise Swagger::InvalidDefinition, e.message
end