lib/prmd/schema.rb in prmd-0.7.1 vs lib/prmd/schema.rb in prmd-0.7.2
- old
+ new
@@ -1,10 +1,25 @@
require 'json'
require 'yaml'
# :nodoc:
module Prmd
+ # @api private
+ DefaultExamples = {
+ "boolean" => true,
+ "integer" => 42,
+ "number" => 42.0,
+ "string" => "example",
+
+ "date-time" => "2015-01-01T12:00:00Z",
+ "email" => "username@example.com",
+ "hostname" => "example.com",
+ "ipv4" => "192.0.2.1",
+ "ipv6" => "2001:DB8::1",
+ "uuid" => "01234567-89ab-cdef-0123-456789abcdef",
+ }
+
# Schema object
class Schema
# @return [Hash] data
attr_reader :data
@@ -109,9 +124,13 @@
[items['example']]
end
else
[schema_example(items)]
end
+ elsif DefaultExamples.key?(value["format"])
+ DefaultExamples[value["format"]]
+ elsif DefaultExamples.key?(value["type"][0])
+ DefaultExamples[value["type"][0]]
end
end
# @param [Hash, String] schema
def schema_example(schema)