lambda_open_api 0.2.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/lambda_open_api/builder.rb +3 -2
- data/lib/lambda_open_api/configuration.rb +4 -3
- data/lib/lambda_open_api/event.rb +4 -0
- data/lib/lambda_open_api/formatter.rb +34 -3
- data/lib/lambda_open_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 668813e6540b575a0f236bcd4573e62e8bbb1fd7a4da444cc4a45e12e8c79a19
|
4
|
+
data.tar.gz: 3cea133cc9dc22238667bc1015c913d3d9a9af18a2a4c1301617810ee252d5ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cb4df4f6c316ae4b94937dc35e156e6d882609a3ede0b72b19d58813bc2000654a88735721ecea9df1783fcead7e7141b9c7b59223df671becb646472c738ea
|
7
|
+
data.tar.gz: 4ffa3f982fedbf0bc6db2a24369f293780b77a78bf4c016b1dd839dcd68ec14ce764dca2438dac74acfbba12e470708e4658f59efd5268400cbfd7e6c5fb9a31
|
data/Gemfile.lock
CHANGED
@@ -50,7 +50,7 @@ module LambdaOpenApi
|
|
50
50
|
def crud_verb(verb, path)
|
51
51
|
@action = LambdaOpenApi::Action.new(name: @name, http_verb: verb, path_name: path)
|
52
52
|
@event = @default_event.dup
|
53
|
-
@event.request_context = {"httpMethod" => verb.upcase}
|
53
|
+
@event.request_context = {"httpMethod" => verb.upcase, "http" => {"method" => verb.upcase}}
|
54
54
|
|
55
55
|
yield
|
56
56
|
|
@@ -66,8 +66,9 @@ module LambdaOpenApi
|
|
66
66
|
|
67
67
|
def run_example(test_name=nil, &block)
|
68
68
|
klass = create_class
|
69
|
+
test_name ||= "#{@action.http_verb} #{@action.path_name}"
|
69
70
|
|
70
|
-
it "#{test_name
|
71
|
+
it "#{test_name}" do
|
71
72
|
@klass = klass
|
72
73
|
def lambda_response
|
73
74
|
@lambda_response ||= @klass.invoke
|
@@ -1,16 +1,17 @@
|
|
1
1
|
module LambdaOpenApi
|
2
2
|
class Configuration
|
3
|
-
attr_accessor :file_name, :title, :description, :version, :host, :schemes, :consumes, :produces
|
3
|
+
attr_accessor :file_name, :title, :description, :version, :host, :schemes, :consumes, :produces, :file_sets
|
4
4
|
|
5
5
|
def initialize
|
6
|
-
@file_name = "open_api.json"
|
6
|
+
@file_name = "open_api/open_api.json"
|
7
7
|
@title = "Workflow Settings Api"
|
8
8
|
@description = "About this api"
|
9
9
|
@version = "1"
|
10
|
-
@host = "
|
10
|
+
@host = "google.com"
|
11
11
|
@schemes = ["https"]
|
12
12
|
@consumes = ["application/json"]
|
13
13
|
@produces = ["application/json"]
|
14
|
+
@file_sets = []
|
14
15
|
end
|
15
16
|
end
|
16
17
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'fileutils'
|
1
2
|
|
2
3
|
module LambdaOpenApi
|
3
4
|
class Formatter
|
@@ -10,12 +11,25 @@ module LambdaOpenApi
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def generate_docs
|
13
|
-
open_api = high_level.merge({"paths" => @paths})
|
14
14
|
|
15
|
-
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
if uses_file_sets?
|
19
|
+
LambdaOpenApi.configuration.file_sets.each do |file_set|
|
20
|
+
LambdaOpenApi.configuration.host = file_set[:host]
|
21
|
+
|
22
|
+
open_api = high_level_structure.merge({"paths" => @paths})
|
23
|
+
|
24
|
+
create_file(file_set[:file_name], open_api)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
open_api = high_level_structure.merge({"paths" => @paths})
|
28
|
+
create_file(LambdaOpenApi.configuration.file_name, open_api)
|
29
|
+
end
|
16
30
|
end
|
17
31
|
|
18
|
-
def
|
32
|
+
def high_level_structure
|
19
33
|
{
|
20
34
|
"swagger" => "2.0",
|
21
35
|
"info" => {
|
@@ -29,6 +43,23 @@ module LambdaOpenApi
|
|
29
43
|
"produces" => LambdaOpenApi.configuration.produces
|
30
44
|
}
|
31
45
|
end
|
46
|
+
|
47
|
+
def uses_file_sets?
|
48
|
+
LambdaOpenApi.configuration.file_sets&.is_a?(Array) &&
|
49
|
+
LambdaOpenApi.configuration.file_sets.any?
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_file(file_name, file_content)
|
53
|
+
dirname = File.dirname(file_name)
|
54
|
+
p dirname
|
55
|
+
unless File.directory?(dirname)
|
56
|
+
p 'to create'
|
57
|
+
p FileUtils.mkdir_p(dirname)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
File.open(file_name, "w") {|f| f.write(JSON.pretty_generate(file_content) + "\n") }
|
62
|
+
end
|
32
63
|
end
|
33
64
|
end
|
34
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lambda_open_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timothyjb
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|