Class: SwaggerYard::TypeParser

Inherits:
Object
  • Object
show all
Defined in:
lib/swagger_yard/type_parser.rb

Defined Under Namespace

Classes: Parser, Transform

Instance Method Summary collapse

Constructor Details

#initialize(model_path = Type::MODEL_PATH) ⇒ TypeParser

Returns a new instance of TypeParser.



130
131
132
133
134
# File 'lib/swagger_yard/type_parser.rb', line 130

def initialize(model_path = Type::MODEL_PATH)
  @parser = Parser.new
  @xform  = Transform.new
  @model_path = model_path
end

Instance Method Details

#json_schema(str) ⇒ Object



140
141
142
143
144
# File 'lib/swagger_yard/type_parser.rb', line 140

def json_schema(str)
  @xform.apply(parse(str), model_path: @model_path)
rescue Parslet::ParseFailed => e
  raise InvalidTypeError, "'#{str}': #{e.message}"
end

#parse(str) ⇒ Object



136
137
138
# File 'lib/swagger_yard/type_parser.rb', line 136

def parse(str)
  @parser.parse(str)
end