Class: Swarker::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/swarker/service.rb

Constant Summary collapse

DEFAULT_SCHEMA =
{
  swagger:  '2.0'.freeze,
  consumes: ['application/json'.freeze],
  produces: ['application/json'.freeze],
  info:     { version: '1.0'.freeze }
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, original_schema, definitions = [], paths = []) ⇒ Service

Returns a new instance of Service.



12
13
14
15
16
17
18
19
# File 'lib/swarker/service.rb', line 12

def initialize(host, original_schema, definitions = [], paths = [])
  @host            = host
  @original_schema = HashWithIndifferentAccess.new(original_schema)
  @definitions     = definitions
  @paths           = paths

  parse_schema
end

Instance Attribute Details

#definitionsObject (readonly)

Returns the value of attribute definitions.



10
11
12
# File 'lib/swarker/service.rb', line 10

def definitions
  @definitions
end

#hostObject (readonly)

Returns the value of attribute host.



10
11
12
# File 'lib/swarker/service.rb', line 10

def host
  @host
end

#pathsObject (readonly)

Returns the value of attribute paths.



10
11
12
# File 'lib/swarker/service.rb', line 10

def paths
  @paths
end

#schemaObject (readonly)

Returns the value of attribute schema.



10
11
12
# File 'lib/swarker/service.rb', line 10

def schema
  @schema
end

Instance Method Details

#json_filenameObject



21
22
23
# File 'lib/swarker/service.rb', line 21

def json_filename
  host || 'swagger'
end