class Swarker::Service

Constants

DEFAULT_SCHEMA

Attributes

definitions[R]
host[R]
original_schema[R]
paths[R]
schema[R]

Public Class Methods

new(host, original_schema, definitions = [], paths = []) click to toggle source
# 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

Public Instance Methods

json_filename() click to toggle source
# File lib/swarker/service.rb, line 21
def json_filename
  host || 'swagger'
end

Private Instance Methods

computed_schema() click to toggle source
# File lib/swarker/service.rb, line 33
def computed_schema
  { info: { title: original_schema[:name] } }.tap do |s|
    s.merge!(host: host) if host
  end
end
parse_schema() click to toggle source
# File lib/swarker/service.rb, line 29
def parse_schema
  @schema = HashWithIndifferentAccess.new(DEFAULT_SCHEMA.deep_merge(computed_schema))
end