class Grape::Validations::AttributesDoc
def details
def details @details ||= {} end
def document(attrs)
def document(attrs) return if @api.namespace_inheritable(:do_not_document) details[:type] = type.to_s if type details[:values] = values if values documented_attrs = attrs.each_with_object({}) do |name, memo| memo[@scope.full_name(name)] = details end @api.namespace_stackable(:params, documented_attrs) end
def extract_details(validations)
def extract_details(validations) details[:required] = validations.key?(:presence) desc = validations.delete(:desc) || validations.delete(:description) details[:desc] = desc if desc documentation = validations.delete(:documentation) details[:documentation] = documentation if documentation details[:default] = validations[:default] if validations.key?(:default) details[:min_length] = validations[:length][:min] if validations.key?(:length) && validations[:length].key?(:min) details[:max_length] = validations[:length][:max] if validations.key?(:length) && validations[:length].key?(:max) end
def initialize(api, scope)
-
scope
(Validations::ParamsScope
) -- -
api
(Grape::API::Instance
) --
def initialize(api, scope) @api = api @scope = scope @type = type end
def required
def required details[:required] end