class MiniApivore::Swagger
Constants
- NONVERB_PATH_ITEMS
Public Instance Methods
base_path()
click to toggle source
# File lib/mini_apivore/swagger.rb, line 23 def base_path self['basePath'] || '' end
each_response(&block)
click to toggle source
# File lib/mini_apivore/swagger.rb, line 27 def each_response(&block) paths.each do |path, path_data| next if vendor_specific_tag? path path_data.each do |verb, method_data| next if NONVERB_PATH_ITEMS.include?(verb) next if vendor_specific_tag? verb if method_data.responses.nil? raise "No responses found in swagger for path '#{path}', " \ "verb #{verb}: #{method_data.inspect}" end method_data.responses.each do |response_code, response_data| schema_location = nil if response_data.schema schema_location = Fragment.new ['#', 'paths', path, verb, 'responses', response_code, 'schema'] end block.call(path, verb, response_code, schema_location) end end end end
validate()
click to toggle source
# File lib/mini_apivore/swagger.rb, line 9 def validate case version when '2.0' schema = File.read(File.expand_path("../../../data/swagger_2.0_schema.json", __FILE__)) else raise "Unknown/unsupported Swagger version to validate against: #{version}" end JSON::Validator.fully_validate(schema, self) end
vendor_specific_tag?(tag)
click to toggle source
# File lib/mini_apivore/swagger.rb, line 48 def vendor_specific_tag? tag tag =~ /\Ax-.*/ end
version()
click to toggle source
# File lib/mini_apivore/swagger.rb, line 19 def version swagger end