nexmo-oas-renderer 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 386fdf3ed82834c48d914044ebb508731c1ffd11ece58c938838b701f03e740f
4
- data.tar.gz: 8114c77db9d427c1b91b14eec1b3a81dbe2cb23ac7e1bb12bb771a30aa36f519
3
+ metadata.gz: 96566dc3b7c32b1faaf58490da59a44cd5d84bf7d31bc2e96c63fa83bbb0e2b2
4
+ data.tar.gz: 54c7eec75b23ce13faf82a4ef6f04d1166bbbba744334f947eab3f627d785071
5
5
  SHA512:
6
- metadata.gz: ba72d949b949515c93413986307d1a9566ee6462d1c78ef2d2bbbad934fe4be8b614d50f71b4277729fabe8b87783783a49a19d4cc7107d05cf95686338751a5
7
- data.tar.gz: d1d25d488466021faf651bba03ef7d29932dc7bb48dbff824b53394f809e29b148909fd568fdd4bf0289577a8cc2e83ad9efa3938ac9d40d2d6fde4f7d0dee96
6
+ metadata.gz: a354aee9de2e810dd12b667af8c91d1ee44e6d4f95369c4f653fe3eb03329c215e29db6123b7746238dc51ebae9dd2206614331c2a110dcc6094e4a22b417afb
7
+ data.tar.gz: 5d045bc34c210e9989b94a744962f58b1d1d93ed91c29d3b2f6c167407fdd1f375f3ecf3708ac8f17a2f38e8548bde094770e1e5b7adf092b18881a83745da39
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nexmo-oas-renderer (0.4.1)
4
+ nexmo-oas-renderer (0.5.0)
5
5
  activemodel (~> 5.2)
6
6
  activesupport (~> 5.2)
7
7
  banzai (~> 0.1.2)
8
8
  dotenv (~> 2.7)
9
9
  neatjson (~> 0.8)
10
- oas_parser (= 0.18.1)
10
+ oas_parser (= 0.21.1)
11
11
  octicons_helper (~> 8.2)
12
12
  redcarpet (= 3.4.0)
13
13
  rouge (= 2.0.7)
@@ -74,6 +74,7 @@ GEM
74
74
  globalid (0.4.2)
75
75
  activesupport (>= 4.2.0)
76
76
  hansi (0.2.0)
77
+ hash-deep-merge (0.1.1)
77
78
  i18n (1.6.0)
78
79
  concurrent-ruby (~> 1.0)
79
80
  loofah (2.2.3)
@@ -96,11 +97,12 @@ GEM
96
97
  nio4r (2.5.1)
97
98
  nokogiri (1.10.4)
98
99
  mini_portile2 (~> 2.4.0)
99
- oas_parser (0.18.1)
100
+ oas_parser (0.21.1)
100
101
  activesupport (>= 4.0.0)
101
102
  addressable (~> 2.3)
102
103
  builder (~> 3.2.3)
103
104
  deep_merge (~> 1.2.1)
105
+ hash-deep-merge
104
106
  mustermann-contrib (~> 1.0.3s)
105
107
  nokogiri
106
108
  octicons (8.5.0)
@@ -81,6 +81,15 @@ module Nexmo
81
81
  end
82
82
  end
83
83
 
84
+ def set_code_language
85
+ return if params[:code_language] == 'templates'
86
+ @code_language = params[:code_language]
87
+ end
88
+
89
+ before do
90
+ set_code_language
91
+ end
92
+
84
93
  get '(/api)/*definition' do
85
94
  check_redirect!
86
95
 
@@ -104,8 +113,23 @@ module Nexmo
104
113
  end
105
114
  end
106
115
 
107
- get '(/api)/*document' do
108
- @specification = Presenters::ApiSpecification.new(document_name: params[:document])
116
+ def set_document
117
+ if params[:code_language] == 'templates'
118
+ @document = 'verify/templates'
119
+ elsif params[:code_language] == 'ncco'
120
+ @document = 'voice/ncco'
121
+ else
122
+ @document = params[:document]
123
+ end
124
+ end
125
+
126
+ get '(/api)/*document(/:code_language)' do
127
+ set_document
128
+
129
+ @specification = Presenters::ApiSpecification.new(
130
+ document_name: @document,
131
+ code_language: @code_language
132
+ )
109
133
 
110
134
  @navigation = Presenters::Navigation.new(
111
135
  content: @specification.content,
@@ -8,7 +8,7 @@ module Nexmo
8
8
  end
9
9
 
10
10
  def canonical_path
11
- request.path.chomp("/#{params[:code_language]}")
11
+ request.path.chomp("/#{@code_language}")
12
12
  end
13
13
  end
14
14
  end
@@ -4,8 +4,9 @@ module Nexmo
4
4
  module Presenters
5
5
  class ApiSpecification
6
6
 
7
- def initialize(document_name:)
7
+ def initialize(document_name:, code_language: nil)
8
8
  @document_name = document_name
9
+ @code_language = code_language
9
10
  end
10
11
 
11
12
  def side_navigation
@@ -33,7 +34,9 @@ module Nexmo
33
34
  end
34
35
 
35
36
  def content
36
- @content ||= MarkdownPipeline.new.call(document)
37
+ options = {}
38
+ options.merge(code_language: @code_language) if @code_language
39
+ @content ||= MarkdownPipeline.new(options).call(document)
37
40
  end
38
41
  end
39
42
  end
@@ -1,7 +1,7 @@
1
1
  module Nexmo
2
2
  module OAS
3
3
  module Renderer
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
6
6
  end
7
7
  end
@@ -42,9 +42,47 @@
42
42
  <%= erb :'open_api/_parameters', locals: { parameters: params, callback: callback } %>
43
43
  <% end %>
44
44
  <% else %>
45
- <% endpoint.request_body.split_properties_for_format(format).each_with_index do |parameters, index| %>
46
- <h4><%= parameters[0].schema['oneOf'][index]['description'] %></h4>
47
- <%= erb :'open_api/_parameters', locals: { parameters: parameters, callback: callback } %>
48
- <% end %>
45
+
46
+ <%
47
+ # This can likely be better done as a presenter, but it works for now
48
+ panels = []
49
+ endpoint.request_body.split_properties_for_format(format).each_with_index do |parameters, index|
50
+ description = 'Request body'
51
+ c = parameters[0].schema['oneOf'][index]
52
+ description = c['description'] if c['description']
53
+ if c['allOf']
54
+ c['allOf'].each_with_index do |current, index|
55
+ description = c[index]['description'] if c[index]['description']
56
+ end
57
+ end
58
+
59
+ panels.push({
60
+ 'description' => description,
61
+ 'parameters' => parameters,
62
+ 'active' => index == 0
63
+ })
64
+ end
65
+ %>
66
+
67
+ <div class="Vlt-tabs js-format" data-format="<%= format %>">
68
+ <div class="Vlt-tabs__header" role="tablist" aria-label="Responses">
69
+ <% panels.each do |panel| %>
70
+ <div class="Vlt-tabs__link <%= panel['active'] ? 'Vlt-tabs__link_active' : '' %>">
71
+ <%= panel['description'] %>
72
+ </div>
73
+ <% end %>
74
+ </div>
75
+ <div class="Vlt-tabs__content">
76
+ <% panels.each do |panel| %>
77
+ <div class="Vlt-tabs__panel <%= panel['active'] ? 'Vlt-tabs__panel_active' : '' %>">
78
+ <h4>
79
+ <%= panel['description'] %>
80
+ <span class="Vlt-badge Vlt-badge--blue"><%= format %></span>
81
+ </h4>
82
+ <%= erb :'open_api/_parameters', locals: { parameters: panel['parameters'], callback: callback } %>
83
+ </div>
84
+ <% end %>
85
+ </div>
86
+ </div>
49
87
  <% end %>
50
88
  <% end %>
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_runtime_dependency 'sinatra', '~> 2.0'
35
35
  spec.add_runtime_dependency 'shotgun', '~> 0.9'
36
36
  spec.add_runtime_dependency 'rouge', '2.0.7'
37
- spec.add_runtime_dependency 'oas_parser', '0.18.1'
37
+ spec.add_runtime_dependency 'oas_parser', '0.21.1'
38
38
  spec.add_runtime_dependency 'neatjson', '~> 0.8'
39
39
  spec.add_runtime_dependency 'activesupport', '~> 5.2'
40
40
  spec.add_runtime_dependency 'banzai', '~> 0.1.2'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nexmo-oas-renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabian Rodriguez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2019-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.18.1
61
+ version: 0.21.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.18.1
68
+ version: 0.21.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: neatjson
71
71
  requirement: !ruby/object:Gem::Requirement