Skip to content

Commit

Permalink
Merge pull request #91 from hahwul/hahwul-dev
Browse files Browse the repository at this point in the history
Hahwul dev
  • Loading branch information
hahwul authored Sep 13, 2023
2 parents 9f9f4cf + 9d15532 commit b4ac5a7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .ameba.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: noir
version: 0.7.0
version: 0.7.1

authors:
- hahwul <[email protected]>
Expand Down
File renamed without changes.
19 changes: 19 additions & 0 deletions spec/functional_test/fixtures/oas3/no_servers/doc_no_servers.yml
Original file line number Diff line number Diff line change
@@ -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
7 changes: 6 additions & 1 deletion spec/functional_test/testers/oas3_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 10 additions & 2 deletions src/analyzer/analyzers/analyzer_oas3.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down Expand Up @@ -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|
Expand Down
2 changes: 1 addition & 1 deletion src/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b4ac5a7

Please sign in to comment.