module Swaggable

Constants

VERSION

Public Instance Methods

call(env) click to toggle source
# File lib/swaggable/rack_app.rb, line 14
def call env
  [
    200,
    {'Content-Type' => 'application/json'},
    [serializer.serialize(api_definition).to_json]
  ]
end
endpoint() click to toggle source
# File lib/swaggable/api_validator.rb, line 20
def endpoint
  definition.endpoints.detect do |e|
    e.match? *request_signature
  end || raise_endpoint_not_found
end
endpoint_validator() click to toggle source
# File lib/swaggable/api_validator.rb, line 26
def endpoint_validator
  @endpoint_validator ||= EndpointValidator.new(endpoint: endpoint)
end
errors_for_request() click to toggle source
# File lib/swaggable/api_validator.rb, line 12
def errors_for_request
  endpoint_validator.errors_for_request request
end
errors_for_response(response) click to toggle source
# File lib/swaggable/api_validator.rb, line 16
def errors_for_response response
  endpoint_validator.errors_for_response response
end
serializer() click to toggle source
# File lib/swaggable/rack_app.rb, line 22
def serializer
  @serializer ||= Swagger2Serializer.new
end
validate() click to toggle source
# File lib/swaggable/rack_app.rb, line 30
def validate
  serializer.validate api_definition
end
validate!() click to toggle source
# File lib/swaggable/rack_app.rb, line 26
def validate!
  serializer.validate! api_definition
end

Private Instance Methods

raise_endpoint_not_found() click to toggle source
# File lib/swaggable/api_validator.rb, line 32
def raise_endpoint_not_found
  raise Errors::EndpointNotFound.new(
    "No endpoint matched #{request_signature.join(" ")}"
  )
end
redirect() click to toggle source
# File lib/swaggable/rack_redirect.rb, line 43
def redirect
  [301, {'Location' => to}, []]
end
request_signature() click to toggle source
# File lib/swaggable/api_validator.rb, line 38
def request_signature
  [request['REQUEST_METHOD'], request['PATH_INFO']]
end