Module: Sinatra::Swagger::SwaggerLinked::Helpers

Defined in:
lib/sinatra/swagger/swagger_linked.rb

Instance Method Summary collapse

Instance Method Details

#schema_from_spec_at(path) ⇒ Object


20
21
22
23
24
25
26
27
28
# File 'lib/sinatra/swagger/swagger_linked.rb', line 20

def schema_from_spec_at(path)
  schema = swagger_spec[:spec]
  path.split("/").each do |key|
    schema = schema[YAML.load(key)]
    return if schema.nil?
  end
  schema['definitions'] = settings.swagger['definitions'] if settings.swagger['definitions']
  schema
end

#swagger_specObject


15
16
17
18
# File 'lib/sinatra/swagger/swagger_linked.rb', line 15

def swagger_spec
  raise "No swagger file loaded" unless settings.swagger
  settings.swagger.request_spec(env: env)
end