prmd 0.7.3 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prmd/templates/init_resource.json.erb +0 -4
- data/lib/prmd/templates/schemata.md.erb +10 -6
- data/lib/prmd/templates/schemata/helper.erb +33 -1
- data/lib/prmd/templates/schemata/link.md.erb +2 -0
- data/lib/prmd/version.rb +1 -1
- data/schemas/interagent-hyper-schema.json +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74cb8c4e07101320893a1a99c2cbbdb9d1db05e9
|
4
|
+
data.tar.gz: 54623e6a8c00abdc86f1800d327df8fe091f8b5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf7f7a284348b34634f2ee4ce6c6135fecd460b1d1be153477fd9a8d1a29e5537cbe9d5150bdacfec2c38844b0b0eb71c8f5c4488d20be204026a97e757867e3
|
7
|
+
data.tar.gz: 6075c2f9d282c53f7317ae6c41ba0411f9793e0a4ce755edc14567a5fecc2ca404462f78aa574011b9206e407dba74f24d309a2070df839b73fe9bc0f82fecf8
|
@@ -4,14 +4,12 @@
|
|
4
4
|
"definitions": {
|
5
5
|
"id": {
|
6
6
|
"description": "unique identifier of <%= resource %>",
|
7
|
-
"example": "01234567-89ab-cdef-0123-456789abcdef",
|
8
7
|
"readOnly": true,
|
9
8
|
"format": "uuid",
|
10
9
|
"type": ["string"]
|
11
10
|
},
|
12
11
|
"name": {
|
13
12
|
"description": "unique name of <%= resource %>",
|
14
|
-
"example": "name",
|
15
13
|
"readOnly": true,
|
16
14
|
"type": ["string"]
|
17
15
|
},
|
@@ -27,13 +25,11 @@
|
|
27
25
|
},
|
28
26
|
"created_at": {
|
29
27
|
"description": "when <%= resource %> was created",
|
30
|
-
"example": "2012-01-01T12:00:00Z",
|
31
28
|
"format": "date-time",
|
32
29
|
"type": ["string"]
|
33
30
|
},
|
34
31
|
"updated_at": {
|
35
32
|
"description": "when <%= resource %> was updated",
|
36
|
-
"example": "2012-01-01T12:00:00Z",
|
37
33
|
"format": "date-time",
|
38
34
|
"type": ["string"]
|
39
35
|
}
|
@@ -1,6 +1,4 @@
|
|
1
1
|
<%-
|
2
|
-
return unless schemata.has_key?('links') && !schemata['links'].empty?
|
3
|
-
|
4
2
|
Prmd::Template.render('schemata/helper.erb', options[:template], {
|
5
3
|
options: options,
|
6
4
|
resource: resource,
|
@@ -11,7 +9,7 @@
|
|
11
9
|
title = schemata['title'].split(' - ', 2).last
|
12
10
|
-%>
|
13
11
|
<%- unless options[:doc][:disable_title_and_description] %>
|
14
|
-
##
|
12
|
+
## <a name="resource-<%= resource %>"></a><%= title %>
|
15
13
|
|
16
14
|
<%= schemata['description'] %>
|
17
15
|
<%- end -%>
|
@@ -21,12 +19,18 @@
|
|
21
19
|
|
22
20
|
| Name | Type | Description | Example |
|
23
21
|
| ------- | ------- | ------- | ------- |
|
24
|
-
<%-
|
25
|
-
|
22
|
+
<%- refs = extract_schemata_refs(schema, schemata['properties']).map {|v| v && v.split("/")} %>
|
23
|
+
<%- extract_attributes(schema, schemata['properties']).each_with_index do |(key, type, description, example), i| %>
|
24
|
+
<%- if refs[i] && refs[i][1] == "definitions" && refs[i][2] != resource %>
|
25
|
+
<%- name = '[%s](#%s)' % [key, 'resource-' + refs[i][2]] %>
|
26
|
+
<%- else %>
|
27
|
+
<%- name = key %>
|
28
|
+
<%- end %>
|
29
|
+
| **<%= name %>** | *<%= type %>* | <%= description %> | <%= example %> |
|
26
30
|
<%- end %>
|
27
31
|
|
28
32
|
<%- end %>
|
29
|
-
<%- schemata['links'].each do |link, datum| %>
|
33
|
+
<%- (schemata['links'] || []).each do |link, datum| %>
|
30
34
|
<%=
|
31
35
|
Prmd::Template.render('schemata/link.md.erb', options[:template], {
|
32
36
|
options: options,
|
@@ -58,13 +58,45 @@
|
|
58
58
|
end
|
59
59
|
attributes.map! { |key, type, description, example|
|
60
60
|
if example.nil? && Prmd::DefaultExamples.key?(type)
|
61
|
-
example = Prmd::DefaultExamples[type]
|
61
|
+
example = "`%s`" % Prmd::DefaultExamples[type].to_json
|
62
62
|
end
|
63
63
|
[key, type, description, example]
|
64
64
|
}
|
65
65
|
return attributes
|
66
66
|
end
|
67
67
|
|
68
|
+
def extract_schemata_refs(schema, properties)
|
69
|
+
ret = []
|
70
|
+
properties.each do |_, value|
|
71
|
+
ref, value = schema.dereference(value)
|
72
|
+
if value['properties']
|
73
|
+
refs = extract_schemata_refs(schema, value['properties'])
|
74
|
+
elsif value['items'] && value['items']['properties']
|
75
|
+
refs = extract_schemata_refs(schema, value['items']['properties'])
|
76
|
+
else
|
77
|
+
refs = [ref]
|
78
|
+
end
|
79
|
+
if value.has_key?('type') && value['type'].include?('null') && (value.has_key?('items') || value.has_key?('properties'))
|
80
|
+
# A nullable object usually isn't a reference to another schema. It's
|
81
|
+
# either not a reference at all, or it's a reference within the same
|
82
|
+
# schema. Instead, the definition of the nullable object might contain
|
83
|
+
# references to specific properties.
|
84
|
+
#
|
85
|
+
# If all properties refer to the same schema, we'll use that as the
|
86
|
+
# reference. This might even overwrite an actual, intra-schema
|
87
|
+
# reference.
|
88
|
+
|
89
|
+
l = refs.map {|v| v && v.split("/")[0..2]}
|
90
|
+
if l.uniq.size == 1 && l[0] != nil
|
91
|
+
ref = l[0].join("/")
|
92
|
+
end
|
93
|
+
ret << ref
|
94
|
+
end
|
95
|
+
ret.concat(refs)
|
96
|
+
end
|
97
|
+
ret
|
98
|
+
end
|
99
|
+
|
68
100
|
def build_attribute(schema, key, value)
|
69
101
|
description = value['description'] || ""
|
70
102
|
if value['default']
|
data/lib/prmd/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Prmd
|
3
3
|
# Well, duh, its a Version module, what did you expect?
|
4
4
|
module Version
|
5
|
-
MAJOR, MINOR, TEENY, PATCH = 0, 7,
|
5
|
+
MAJOR, MINOR, TEENY, PATCH = 0, 7, 4, nil
|
6
6
|
# version string
|
7
7
|
# @return [String]
|
8
8
|
STRING = [MAJOR, MINOR, TEENY, PATCH].compact.join('.').freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geemus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: erubis
|