module Swagger

Provides loading and building capabilities for Swagger. @see swagger.io Swagger

Constants

RESOURCES_DIR
VERSION

Public Class Methods

build(content, opts = {}) click to toggle source

Instantiates a Swagger::API from the content. @param [Hash] opts the build options @option opts [String] :version the target Swagger specification version @returns [API]

# File lib/swagger.rb, line 22
def self.build(content, opts = {})
  parser ||= Swagger::Parsers.parser_for(opts[:format])
  content = parser.parse(content) unless parser.nil?
  Swagger::API.build_api(content)
end
builder(opts = {}) click to toggle source

Creates a Swagger::Builder that can be used to create a Swagger document. @param [Hash] opts the build options @option opts [String] :version the target Swagger specification version @returns Swagger::Builder

# File lib/swagger.rb, line 43
def self.builder(opts = {})
  Swagger::Builder.builder(opts)
end
load(file, opts = {}) click to toggle source

Load a Swagger document from a file. @param [Hash] opts the load options @option opts [String] :format the format (yaml or json). Detected by file extension if omitted. @returns [API] a Swagger API object

# File lib/swagger.rb, line 32
def self.load(file, opts = {})
  ext = File.extname file
  opts[:format] = ext
  content = File.read(file)
  build(content, opts)
end