openapi3_invoker 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/lib/openapi3_invoker/client.rb +21 -7
- data/lib/openapi3_invoker/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 387f982fcf4f6b91e0aa79c0147afab483a082452dcacddd7a0c894f7be04fcf
|
4
|
+
data.tar.gz: 4c9600cc1a03afd90720a46d2bf120d89586961949b534fe0e129a4e6ba14d5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 066b31aab5d1046ffe4b125f0f2c359e5e424a8cff972a642ca89b559fdad184a9c1dd27dc780caa5f93217a0d2907b63980b3c134cc8ccf17033724ae8c0538
|
7
|
+
data.tar.gz: 19131179c9e43e4349ac61ee29db4847a7ca91e4a9a236b46ed0acfb059a7e347f932f801b91098747031c30995ceb2850b28050c51a137b90d31f431dce9f1f
|
data/README.md
CHANGED
@@ -18,13 +18,31 @@ gem install openapi3_invoker
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
openapi_parser = Openapi3Parser.load(open_api_definition)
|
23
|
+
path = "/api/function/name"
|
24
|
+
http_method = "get"
|
25
|
+
parameters = { "some" => "parameter" }
|
26
|
+
openapi_invoker = Openapi3Invoker.new(openapi_definition, base_url: tool.tool_set.base_url)
|
27
|
+
status, headers, result = openapi_invoker.invoke(path, http_method, parameters: parameters)
|
28
|
+
```
|
22
29
|
|
23
30
|
## Development
|
24
31
|
|
25
|
-
|
32
|
+
All development must be done in a pull request and approved before merging.
|
33
|
+
|
34
|
+
To run the specs do the following: `rake spec`
|
35
|
+
|
36
|
+
## Releasing
|
37
|
+
|
38
|
+
To release, first increment the version file, then cut a new tag of the form v#.#.#.
|
26
39
|
|
27
|
-
|
40
|
+
For example:
|
41
|
+
|
42
|
+
```bash
|
43
|
+
git tag v0.2.0 -f
|
44
|
+
git push --tags -f
|
45
|
+
```
|
28
46
|
|
29
47
|
## Contributing
|
30
48
|
|
@@ -15,6 +15,15 @@ module Openapi3Invoker
|
|
15
15
|
@base_url = base_url || openapi.servers.first.url
|
16
16
|
end
|
17
17
|
|
18
|
+
def supported?(path_name, method_name)
|
19
|
+
raise Error::InvalidMethod unless %w[get delete put patch post head trace options].include?(method_name.to_s.downcase)
|
20
|
+
path = openapi.paths[path_name]
|
21
|
+
raise Error::InvalidPath unless path
|
22
|
+
method = path.send(method_name.to_s.downcase)
|
23
|
+
raise Error::InvalidMethodPathCombo unless method
|
24
|
+
raise Error::NotYetImplemented.new("Request Body is not yet supported") if method.request_body&.required?
|
25
|
+
end
|
26
|
+
|
18
27
|
def invoke(path_name, method_name, parameters: {}, headers: {}, body: nil)
|
19
28
|
raise Error::ServerNotSpecified unless base_url
|
20
29
|
raise Error::InvalidMethod unless %w[get delete put patch post head trace options].include?(method_name.to_s.downcase)
|
@@ -22,20 +31,25 @@ module Openapi3Invoker
|
|
22
31
|
raise Error::InvalidPath unless path
|
23
32
|
method = path.send(method_name.to_s.downcase)
|
24
33
|
raise Error::InvalidMethodPathCombo unless method
|
25
|
-
|
26
34
|
raise Error::NotYetImplemented.new("Request Body is not yet supported") if method.request_body&.required?
|
35
|
+
|
36
|
+
# parser.components.schemas["Smiles"].properties.each { |name, prop| puts "#{name}, #{prop.type}" }
|
37
|
+
|
27
38
|
method.parameters.each do |parameter|
|
28
39
|
raise Error::MissingParameter if(parameter.required? && !parameters.key?(parameter.name))
|
29
40
|
end
|
30
41
|
|
31
|
-
response = case method_name
|
42
|
+
response = case method_name.downcase
|
32
43
|
when "get"
|
33
44
|
resulting_url = full_url(path_name, method, parameters: parameters)
|
34
|
-
connection.get(resulting_url, headers)
|
35
|
-
when "
|
36
|
-
|
45
|
+
connection.get(resulting_url, nil, headers)
|
46
|
+
when "post"
|
47
|
+
resulting_url = full_url(path_name, method, parameters: parameters)
|
48
|
+
connection.post(resulting_url, body, headers)
|
49
|
+
when "delete", "put", "patch", "head", "trace", "options"
|
50
|
+
raise Error::NotYetImplemented.new("Only GET and POST requests are currently supported")
|
37
51
|
end
|
38
|
-
response.body
|
52
|
+
[response.status, response.headers.to_h.transform_keys(&:downcase), response.body]
|
39
53
|
end
|
40
54
|
|
41
55
|
# We're expect this method to called from invoke, so much of the error checking has already happened
|
@@ -71,4 +85,4 @@ module Openapi3Invoker
|
|
71
85
|
end
|
72
86
|
end
|
73
87
|
end
|
74
|
-
end
|
88
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openapi3_invoker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Petersen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: openapi3_parser
|
@@ -80,7 +80,7 @@ metadata:
|
|
80
80
|
homepage_uri: https://github.com/assaydepot/openapi3_invoker
|
81
81
|
source_code_uri: https://github.com/assaydepot/openapi3_invoker
|
82
82
|
changelog_uri: https://github.com/assaydepot/openapi3_invoker/releases
|
83
|
-
post_install_message:
|
83
|
+
post_install_message:
|
84
84
|
rdoc_options: []
|
85
85
|
require_paths:
|
86
86
|
- lib
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubygems_version: 3.5.3
|
99
|
-
signing_key:
|
99
|
+
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: A gem to simplify invoking OpenAPI 3.0 operations
|
102
102
|
test_files: []
|