Skip to content

Commit

Permalink
Merge pull request #104 from hahwul/dev
Browse files Browse the repository at this point in the history
Release v0.7.3
  • Loading branch information
hahwul authored Sep 21, 2023
2 parents cede708 + 22a9bf4 commit 6276ecc
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 6 deletions.
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.2
version: 0.7.3

authors:
- hahwul <[email protected]>
Expand Down
10 changes: 10 additions & 0 deletions spec/unit_test/models/delivers/zap_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require "../../../../src/models/delivers/zap.cr"
require "../../../../src/options.cr"

describe "Initialize" do
zap = ZAP.new "http://localhost:8090"

it "init" do
zap.nil?.should eq(false)
end
end
14 changes: 10 additions & 4 deletions src/analyzer/analyzers/analyzer_oas2.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ class AnalyzerOAS2 < Analyzer
content = File.read(swagger_json, encoding: "utf-8", invalid: :skip)
json_obj = JSON.parse(content)
base_path = @url
if json_obj["basePath"].to_s != ""
base_path = base_path + json_obj["basePath"].to_s
begin
if json_obj["basePath"].to_s != ""
base_path = base_path + json_obj["basePath"].to_s
end
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 @@ -49,8 +52,11 @@ class AnalyzerOAS2 < Analyzer
content = File.read(swagger_yaml, encoding: "utf-8", invalid: :skip)
yaml_obj = YAML.parse(content)
base_path = @url
if yaml_obj["basePath"].to_s != ""
base_path = base_path + yaml_obj["basePath"].to_s
begin
if yaml_obj["basePath"].to_s != ""
base_path = base_path + yaml_obj["basePath"].to_s
end
rescue
end
yaml_obj["paths"].as_h.each do |path, path_obj|
path_obj.as_h.each do |method, method_obj|
Expand Down
26 changes: 26 additions & 0 deletions src/models/delivers/zap.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class ZAP
@endpoint : String
@apikey : String

API_ACCESS = "/JSON/core/action/accessUrl"

def initialize(@endpoint)
if ENV.keys.includes? "ZAP_API_KEY"
@apikey = ENV["ZAP_API_KEY"].to_s
else
@apikey = ""
end
end

def add_url(url : String)
call(@endpoint + API_ACCESS + "?url=#{url}")
end

def call(query : String)
if @apikey == ""
HTTP::Client.get(query)
else
HTTP::Client.get(query, headers: {"X-ZAP-API-Key" => @apikey})
end
end
end
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.2"
VERSION = "0.7.3"
end

noir_options = default_options()
Expand Down

0 comments on commit 6276ecc

Please sign in to comment.