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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00f797762078297ac1632725fe728aab33b5a68364caa863b2b54b43bd096165
4
- data.tar.gz: ea24290dc26cd7702983483eabaa109763945aba8123e320184e3dbc29ae937a
3
+ metadata.gz: c1e2c40dc6ad77e8425946eb53d32fa96d098c8e0d68596584a44ec21b93700a
4
+ data.tar.gz: 632e53a21620f471638f84261a72776ca4fad8c866758dfc55f5483dcb85c0d8
5
5
  SHA512:
6
- metadata.gz: 7335fcca6e5e5e6a4b60bdba1dc1d4de476af604b2959a064c0f2629dec6080ff465a8d42e6d63d416f78621faeb60a483c2d1ce2e2f5b7c943fd4fa859670f4
7
- data.tar.gz: 244665e2f2beb611e8ecbe6a9d8e34d412a09eff037e0390af7593fbecca0fbb9f1af60e7caed6ed1d5546c4f5c3ac6d816bc1cba6014bf79a958760f8af111e
6
+ metadata.gz: d53d87fc449ab535f1c5cfd03c9cf815b6ac908f9ee847c515f662183141d264ae2154ee0da6eb1b1020bd91dac9a9d030e1b828fb5984b827de1305c4d0c657
7
+ data.tar.gz: 36a869d2c7397124d567eb86466f5e090b1060b4e709da50160c277a3379332979f90748b51b865a95b6dc802b7f16520ea3fd3bfa2b815adb9c2ce1f448bdea
data/.env.example CHANGED
@@ -1,2 +1 @@
1
1
  OAS_PATH='../api-specification'
2
- OAS_CI=true
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.6.3
2
+ * Remove the need to have a `definitions` folder, just specify the correct path in `OAS_PATH`
3
+ * Remove OAS constraints, since they are not needed to run this standalone
4
+
1
5
  # 0.6.0
2
6
  * Upgraded to Rails 6
3
7
 
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
- redirect_path = Constraints::Redirector.find(request)
66
- redirect(redirect_path) if redirect_path
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}/definitions"
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
- pass if !Constraints::OpenApi.match?(definition)
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}/../errors/#{@definition_name}.md")
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}/../errors/#{@definition_name}.md")
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
- versions = Constraints::OpenApi.find_all_versions(base_name)
27
- # Add in anything in the old /_api folder
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
- versions.sort_by! { |v| v['version'] }
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
@@ -21,7 +21,7 @@ module Nexmo
21
21
  end
22
22
 
23
23
  def self.path(name, format)
24
- "#{API.oas_path}/definitions/#{name}.#{format}"
24
+ "#{API.oas_path}/#{name}.#{format}"
25
25
  end
26
26
 
27
27
  def self.resolve(path)
@@ -1,7 +1,7 @@
1
1
  module Nexmo
2
2
  module OAS
3
3
  module Renderer
4
- VERSION = "0.6.2"
4
+ VERSION = "0.6.3"
5
5
  end
6
6
  end
7
7
  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.2
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-23 00:00:00.000000000 Z
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
- rubyforge_project:
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