lib/prmd/templates/schemata/helper.erb in prmd-0.13.0 vs lib/prmd/templates/schemata/helper.erb in prmd-0.14.0
- old
+ new
@@ -135,11 +135,14 @@
if value['enum']
description += '<br/> **one of:**' + [*value['enum']].map { |e| "`#{e.to_json}`" }.join(" or ")
end
if value['pattern']
- description += "<br/> **pattern:** `#{value['pattern']}`"
+ # Prevent the pipe regex pattern characters from being interpreted as markdown table:
+ pattern = value['pattern'].gsub(/\|/, '|')
+
+ description += "<br/> **pattern:** <pre>#{pattern}</pre>"
end
if value['minLength'] || value['maxLength']
description += "<br/> **Length:** `"
if value['minLength']
@@ -173,19 +176,19 @@
type = if value['type'].include?('null')
'nullable '
else
''
end
- type += (value['format'] || (value['type'] - ['null']).first)
+ type += (value['format'] || (value['type'] - ['null']).join(' or '))
[key, type, description, example]
end
def build_link_path(schema, link)
link['href'].gsub(%r|(\{\([^\)]+\)\})|) do |ref|
ref = ref.gsub('%2F', '/').gsub('%23', '#').gsub(%r|[\{\(\)\}]|, '')
- ref_resource = ref.split('#/definitions/').last.split('/').first.gsub('-','_')
identity_key, identity_value = schema.dereference(ref)
+ ref_resource = identity_key.split('#/definitions/').last.split('/').first.gsub('-','_')
if identity_value.has_key?('anyOf')
'{' + ref_resource + '_' + identity_value['anyOf'].map {|r| r['$ref'].split('/').last}.join('_or_') + '}'
else
'{' + ref_resource + '_' + identity_key.split('/').last + '}'
end