186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/attributor/type.rb', line 186
def as_json_schema( shallow: false, example: nil, attribute_options: {} )
type_name = self.ancestors.find { |k| k.name && !k.name.empty? }.name
hash = { type: json_schema_type, 'x-type_name': type_name.gsub( Attributor::MODULE_PREFIX_REGEX, '' )}
if hash[:type] == :string && the_format = json_schema_string_format
hash[:format] = the_format
end
hash[:enum] = attribute_options[:values] if attribute_options[:values]
hash
end
|