nexmo-oas-renderer 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +0 -1
- data/CHANGELOG.md +4 -0
- data/README.md +0 -1
- data/lib/nexmo/oas/renderer/app.rb +13 -6
- data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +2 -2
- data/lib/nexmo/oas/renderer/presenters/versions.rb +17 -7
- data/lib/nexmo/oas/renderer/services/open_api_definition_resolver.rb +1 -1
- data/lib/nexmo/oas/renderer/version.rb +1 -1
- metadata +3 -7
- data/lib/nexmo/oas/renderer/config/redirects.yml +0 -8
- data/lib/nexmo/oas/renderer/constraints/open_api.rb +0 -85
- data/lib/nexmo/oas/renderer/constraints/redirector.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1e2c40dc6ad77e8425946eb53d32fa96d098c8e0d68596584a44ec21b93700a
|
4
|
+
data.tar.gz: 632e53a21620f471638f84261a72776ca4fad8c866758dfc55f5483dcb85c0d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d53d87fc449ab535f1c5cfd03c9cf815b6ac908f9ee847c515f662183141d264ae2154ee0da6eb1b1020bd91dac9a9d030e1b828fb5984b827de1305c4d0c657
|
7
|
+
data.tar.gz: 36a869d2c7397124d567eb86466f5e090b1060b4e709da50160c277a3379332979f90748b51b865a95b6dc802b7f16520ea3fd3bfa2b815adb9c2ce1f448bdea
|
data/.env.example
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -70,7 +70,6 @@ and assign values to the corresponding variables.
|
|
70
70
|
|
71
71
|
#### Note
|
72
72
|
The env variable `OAS_PATH` indicates the path to the documents that will be rendered.
|
73
|
-
Set `OAS_CI` to true to treat all the OAS docs under `OAS_PATH` as valid.
|
74
73
|
|
75
74
|
## Contributing
|
76
75
|
We ❤️ contributions from everyone! [Bug reports](https://github.com/Nexmo/nexmo-oas-renderer/issues), [bug fixes](https://github.com/Nexmo/nexmo-oas-renderer/pulls) and feedback on the library is always appreciated. Look at the [Contributor Guidelines](https://github.com/Nexmo/nexmo-oas-renderer/blob/master/CONTRIBUTING.md) for more information and please follow the [GitHub Flow](https://guides.github.com/introduction/flow/index.html).
|
@@ -4,7 +4,6 @@ require 'active_support/core_ext/array/conversions'
|
|
4
4
|
require 'active_support/core_ext/string/output_safety'
|
5
5
|
require 'active_model'
|
6
6
|
|
7
|
-
require_relative'./constraints/redirector'
|
8
7
|
require_relative'./decorators/response_parser_decorator'
|
9
8
|
require_relative'./pipelines/markdown_pipeline'
|
10
9
|
require_relative'./presenters/api_specification'
|
@@ -15,7 +14,7 @@ require_relative'./helpers/render'
|
|
15
14
|
require_relative'./helpers/navigation'
|
16
15
|
require_relative'./helpers/summary'
|
17
16
|
require_relative'./helpers/url'
|
18
|
-
|
17
|
+
require_relative './services/code_language_api'
|
19
18
|
require_relative'./lib/core_ext/string'
|
20
19
|
|
21
20
|
require 'dotenv/load'
|
@@ -62,8 +61,16 @@ module Nexmo
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def check_redirect!
|
65
|
-
|
66
|
-
|
64
|
+
if defined?(NexmoDeveloper::Application)
|
65
|
+
redirect_path = Redirector.find(request)
|
66
|
+
redirect(redirect_path) if redirect_path
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def check_oas_constraints!(definition)
|
71
|
+
if defined?(NexmoDeveloper::Application)
|
72
|
+
pass unless OpenApiConstraint.match?(definition)
|
73
|
+
end
|
67
74
|
end
|
68
75
|
|
69
76
|
error Errno::ENOENT do
|
@@ -73,7 +80,7 @@ module Nexmo
|
|
73
80
|
|
74
81
|
unless defined?(NexmoDeveloper::Application)
|
75
82
|
get '/' do
|
76
|
-
prefix = "#{API.oas_path}
|
83
|
+
prefix = "#{API.oas_path}"
|
77
84
|
@definitions = Dir.glob("#{prefix}/**/*.yml").map do |d|
|
78
85
|
d.gsub("#{prefix}/", '').gsub('.yml', '')
|
79
86
|
end.sort.reject { |d| d.include? 'common/' }
|
@@ -95,7 +102,7 @@ module Nexmo
|
|
95
102
|
|
96
103
|
parameters = parse_params(params[:definition])
|
97
104
|
definition = [parameters[:definition], parameters[:version]].compact.join('.')
|
98
|
-
|
105
|
+
check_oas_constraints!(definition)
|
99
106
|
|
100
107
|
@specification = Presenters::OpenApiSpecification.new(
|
101
108
|
definition_name: definition,
|
@@ -26,12 +26,12 @@ module Nexmo
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def errors?
|
29
|
-
File.exist?("#{API.oas_path}
|
29
|
+
File.exist?("#{API.oas_path}/../../errors/#{@definition_name}.md")
|
30
30
|
end
|
31
31
|
|
32
32
|
def definition_errors
|
33
33
|
@definition_errors ||= MarkdownPipeline.new.call(
|
34
|
-
File.read("#{API.oas_path}
|
34
|
+
File.read("#{API.oas_path}/../../errors/#{@definition_name}.md")
|
35
35
|
) if errors?
|
36
36
|
end
|
37
37
|
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require_relative '../constraints/open_api'
|
2
|
-
|
3
1
|
module Nexmo
|
4
2
|
module OAS
|
5
3
|
module Renderer
|
@@ -23,15 +21,27 @@ module Nexmo
|
|
23
21
|
|
24
22
|
def available_versions
|
25
23
|
@available_versions ||= begin
|
26
|
-
|
27
|
-
|
28
|
-
if File.exist?("_api/#{base_name}.md")
|
29
|
-
versions.push({ 'version' => '1', 'name' => base_name })
|
24
|
+
matches = definitions.select do |definition|
|
25
|
+
definition.starts_with?(base_name) && !definition.include?("#{base_name}/")
|
30
26
|
end
|
31
27
|
|
32
|
-
|
28
|
+
matches.map do |definition|
|
29
|
+
name = definition.chomp('.yml')
|
30
|
+
m = /\.v(\d+)/.match(name)
|
31
|
+
next { 'version' => '1', 'name' => name } unless m
|
32
|
+
{ 'version' => m[1], 'name' => name }
|
33
|
+
|
34
|
+
end.sort_by { |v| v['version'] }
|
33
35
|
end
|
34
36
|
end
|
37
|
+
|
38
|
+
def definitions
|
39
|
+
@definitions ||= begin
|
40
|
+
Dir.glob("#{API.oas_path}/definitions/**/*.yml").map do |file|
|
41
|
+
definition = file.sub("#{API.oas_path}/definitions/", '').chomp('.yml')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
35
45
|
end
|
36
46
|
|
37
47
|
end
|
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.6.
|
4
|
+
version: 0.6.3
|
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-10-
|
11
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sinatra
|
@@ -247,9 +247,6 @@ files:
|
|
247
247
|
- lib/nexmo/oas/renderer/config.ru
|
248
248
|
- lib/nexmo/oas/renderer/config/code_languages.yml
|
249
249
|
- lib/nexmo/oas/renderer/config/dynamic_content.yml
|
250
|
-
- lib/nexmo/oas/renderer/config/redirects.yml
|
251
|
-
- lib/nexmo/oas/renderer/constraints/open_api.rb
|
252
|
-
- lib/nexmo/oas/renderer/constraints/redirector.rb
|
253
250
|
- lib/nexmo/oas/renderer/decorators/response_parser_decorator.rb
|
254
251
|
- lib/nexmo/oas/renderer/filters/anchor.rb
|
255
252
|
- lib/nexmo/oas/renderer/filters/audio.rb
|
@@ -403,8 +400,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
403
400
|
- !ruby/object:Gem::Version
|
404
401
|
version: '0'
|
405
402
|
requirements: []
|
406
|
-
|
407
|
-
rubygems_version: 2.7.6.2
|
403
|
+
rubygems_version: 3.0.3
|
408
404
|
signing_key:
|
409
405
|
specification_version: 4
|
410
406
|
summary: OpenAPI Specification renderer.
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"/api/voice/ncco": "/voice/voice-api/ncco-reference"
|
2
|
-
"/api/account/secret-management": "/api/account#secret-management"
|
3
|
-
"/api/developer": "/api/numbers"
|
4
|
-
"/api/developer/numbers": "/api/numbers"
|
5
|
-
"/api/developer/account": "/api/account"
|
6
|
-
"/api/messages": "/api/developer/messages"
|
7
|
-
|
8
|
-
"/api/stitch": "/api/conversation"
|
@@ -1,85 +0,0 @@
|
|
1
|
-
require_relative '../services/code_language_api'
|
2
|
-
|
3
|
-
module Nexmo
|
4
|
-
module OAS
|
5
|
-
module Renderer
|
6
|
-
module Constraints
|
7
|
-
class OpenApi
|
8
|
-
|
9
|
-
OPEN_API_PRODUCTS = %w[
|
10
|
-
sms
|
11
|
-
media
|
12
|
-
number-insight
|
13
|
-
conversation
|
14
|
-
conversation.v2
|
15
|
-
messages-olympus
|
16
|
-
dispatch
|
17
|
-
redact
|
18
|
-
audit
|
19
|
-
voice.v2
|
20
|
-
voice
|
21
|
-
account
|
22
|
-
external-accounts
|
23
|
-
numbers
|
24
|
-
verify
|
25
|
-
vonage-business-cloud/account
|
26
|
-
vonage-business-cloud/extension
|
27
|
-
vonage-business-cloud/reports
|
28
|
-
vonage-business-cloud/user
|
29
|
-
vonage-business-cloud/vgis
|
30
|
-
application
|
31
|
-
application.v2
|
32
|
-
conversion
|
33
|
-
subaccounts
|
34
|
-
developer/messages
|
35
|
-
reports
|
36
|
-
].freeze
|
37
|
-
|
38
|
-
def self.match?(definition, code_language = nil)
|
39
|
-
return true if ENV['OAS_CI']
|
40
|
-
if code_language.nil?
|
41
|
-
products_with_code_language[:definition].match?(definition)
|
42
|
-
else
|
43
|
-
products_with_code_language[:definition].match?(definition) &&
|
44
|
-
products_with_code_language[:code_language].match?(code_language)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.list
|
49
|
-
OPEN_API_PRODUCTS
|
50
|
-
end
|
51
|
-
|
52
|
-
def self.products
|
53
|
-
{ definition: Regexp.new("^(#{OPEN_API_PRODUCTS.join('|')})$") }
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.errors_available
|
57
|
-
all = OPEN_API_PRODUCTS.dup.concat(['application'])
|
58
|
-
{ definition: Regexp.new(all.join('|')) }
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.products_with_code_language
|
62
|
-
products.merge(CodeLanguageAPI.route_constraint)
|
63
|
-
end
|
64
|
-
|
65
|
-
def self.find_all_versions(name)
|
66
|
-
# Remove the .v2 etc if needed
|
67
|
-
name = name.gsub(/(\.v\d+)/, '')
|
68
|
-
|
69
|
-
matches = OPEN_API_PRODUCTS.select do |s|
|
70
|
-
s.start_with?(name) && !s.include?("#{name}/")
|
71
|
-
end
|
72
|
-
|
73
|
-
matches = matches.map do |s|
|
74
|
-
m = /\.v(\d+)/.match(s)
|
75
|
-
next { 'version' => '1', 'name' => s } unless m
|
76
|
-
{ 'version' => m[1], 'name' => s }
|
77
|
-
end
|
78
|
-
|
79
|
-
matches.sort_by { |v| v['version'] }
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Nexmo
|
4
|
-
module OAS
|
5
|
-
module Renderer
|
6
|
-
module Constraints
|
7
|
-
class Redirector
|
8
|
-
REDIRECTS = YAML.load_file(File.expand_path("../config/redirects.yml", __dir__)) || {}
|
9
|
-
|
10
|
-
def self.find(request)
|
11
|
-
REDIRECTS[request.path] || false
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|