class Katarina::Schema
Attributes
action[R]
controller[R]
http_method[R]
path[R]
response_code[R]
Public Class Methods
new(path, controller, action, http_method, response_code, schema)
click to toggle source
# File lib/katarina/schema.rb, line 9 def initialize(path, controller, action, http_method, response_code, schema) @path = path @controller = controller @action = action @http_method = http_method @response_code = response_code @schema = schema end
Public Instance Methods
name()
click to toggle source
# File lib/katarina/schema.rb, line 26 def name [ prefix, *Katarina::Path.include_paths(@controller.split('/')), action, response_code.to_s ].map(&:camelize).join end
types(schema = @schema)
click to toggle source
# File lib/katarina/schema.rb, line 18 def types(schema = @schema) case schema in { type: 'object', properties: } then build_object(properties) in { type: 'array', items: } then [types(items)] in { type: type } then type end end
Private Instance Methods
build_object(properties)
click to toggle source
# File lib/katarina/schema.rb, line 43 def build_object(properties) properties.keys.each_with_object({}) { _2[_1] = property_type(properties[_1]) } end
prefix()
click to toggle source
# File lib/katarina/schema.rb, line 39 def prefix Katarina.config.prefix ? 'T' : '' end
property_type(property)
click to toggle source
# File lib/katarina/schema.rb, line 47 def property_type(property) case property in { type: 'object' | 'array' } then types(property) in { type: } then type end end