diff --git a/.ameba.yml b/.ameba.yml index ef211735..31184c94 100644 --- a/.ameba.yml +++ b/.ameba.yml @@ -3,6 +3,6 @@ ignored_paths: Metrics/CyclomaticComplexity: Description: Disallows methods with a cyclomatic complexity higher than `MaxComplexity` - MaxComplexity: 30 + MaxComplexity: 35 Enabled: true Severity: Warning diff --git a/shard.yml b/shard.yml index 4056ba2a..ac68de28 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: noir -version: 0.7.0 +version: 0.7.1 authors: - hahwul diff --git a/spec/functional_test/fixtures/oas3/doc.yml b/spec/functional_test/fixtures/oas3/common/doc.yml similarity index 100% rename from spec/functional_test/fixtures/oas3/doc.yml rename to spec/functional_test/fixtures/oas3/common/doc.yml diff --git a/spec/functional_test/fixtures/oas3/no_servers/doc_no_servers.yml b/spec/functional_test/fixtures/oas3/no_servers/doc_no_servers.yml new file mode 100644 index 00000000..2be08d53 --- /dev/null +++ b/spec/functional_test/fixtures/oas3/no_servers/doc_no_servers.yml @@ -0,0 +1,19 @@ +openapi: 3.0.0 +info: + title: Gem Store API + version: 1.0.0 + description: Sample API for managing pets in a Gem store. +paths: + /gems: + get: + summary: Get a list of pets + responses: + '200': + description: A list of pets + content: + application/json: + example: + - id: 1 + name: Ruby + - id: 2 + name: Crystal diff --git a/spec/functional_test/testers/oas3_spec.cr b/spec/functional_test/testers/oas3_spec.cr index c05ef9f2..517bc17d 100644 --- a/spec/functional_test/testers/oas3_spec.cr +++ b/spec/functional_test/testers/oas3_spec.cr @@ -7,7 +7,12 @@ extected_endpoints = [ Endpoint.new("/pets/{petId}", "PUT"), ] -FunctionalTester.new("fixtures/oas3/", { +FunctionalTester.new("fixtures/oas3/common/", { :techs => 1, :endpoints => 4, }, extected_endpoints).test_all + +FunctionalTester.new("fixtures/oas3/no_servers/", { + :techs => 1, + :endpoints => 1, +}, nil).test_all diff --git a/src/analyzer/analyzers/analyzer_oas3.cr b/src/analyzer/analyzers/analyzer_oas3.cr index f65e8ed7..4eaf409f 100644 --- a/src/analyzer/analyzers/analyzer_oas3.cr +++ b/src/analyzer/analyzers/analyzer_oas3.cr @@ -21,13 +21,17 @@ class AnalyzerOAS3 < Analyzer locator = CodeLocator.instance oas3_json = locator.get("oas3-json") oas3_yaml = locator.get("oas3-yaml") + base_path = @url if !oas3_json.nil? if File.exists?(oas3_json) content = File.read(oas3_json, encoding: "utf-8", invalid: :skip) json_obj = JSON.parse(content) - base_path = get_base_path json_obj["servers"] + begin + base_path = get_base_path json_obj["servers"] + rescue + end json_obj["paths"].as_h.each do |path, path_obj| path_obj.as_h.each do |method, method_obj| @@ -82,7 +86,11 @@ class AnalyzerOAS3 < Analyzer if File.exists?(oas3_yaml) content = File.read(oas3_yaml, encoding: "utf-8", invalid: :skip) yaml_obj = YAML.parse(content) - base_path = get_base_path yaml_obj["servers"] + + begin + base_path = get_base_path yaml_obj["servers"] + rescue + end yaml_obj["paths"].as_h.each do |path, path_obj| path_obj.as_h.each do |method, method_obj| diff --git a/src/noir.cr b/src/noir.cr index 6f972582..fb99e237 100644 --- a/src/noir.cr +++ b/src/noir.cr @@ -6,7 +6,7 @@ require "./options.cr" require "./techs/techs.cr" module Noir - VERSION = "0.7.0" + VERSION = "0.7.1" end noir_options = default_options()