class SwaggerYard::Type

Constants

MODEL_PATH

Default model location path

Attributes

source[R]

Public Class Methods

from_type_list(types) click to toggle source
# File lib/swagger_yard/type.rb, line 3
def self.from_type_list(types)
  new(types.first)
end
new(string) click to toggle source
# File lib/swagger_yard/type.rb, line 12
def initialize(string)
  @source  = string
  @name    = nil
end

Public Instance Methods

name() click to toggle source
# File lib/swagger_yard/type.rb, line 17
def name
  return @name if @name
  @name = name_for(schema)
  @name = name_for(schema['items']) if @name == 'array'
  @name
end
schema() click to toggle source
# File lib/swagger_yard/type.rb, line 24
def schema
  @schema ||= TypeParser.new.json_schema(source)
end
schema_with(options = {}) click to toggle source
# File lib/swagger_yard/type.rb, line 28
def schema_with(options = {})
  model_path = options && options[:model_path] || MODEL_PATH
  if model_path != MODEL_PATH
    TypeParser.new(model_path).json_schema(source)
  else
    schema
  end
end

Private Instance Methods

name_for(schema) click to toggle source
# File lib/swagger_yard/type.rb, line 38
def name_for(schema)
  schema["type"] || schema["$ref"][%r'.*/([^/]*)$', 1]
end