swagger-template 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +31 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/swagger/template/endpoint.rb +74 -0
- data/lib/swagger/template/tasks.rb +39 -0
- data/lib/swagger/template/tasks/reader.rb +42 -0
- data/lib/swagger/template/tasks/template.rb +2 -0
- data/lib/swagger/template/tasks/writer.rb +34 -0
- data/lib/swagger/template/version.rb +5 -0
- data/swagger-template.gemspec +28 -0
- data/templates/ruby/endpoint.erb +33 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 65c7eee7824206ced87a66109d5fd06da6e56b78006d30f9d85f9b2acadc9f36
|
4
|
+
data.tar.gz: 4141403d77c254ef8f427535b9ec74fafad758921bd18c7c9a1bd3670b063bb7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5ee8afb3951c3562dc2c01ca608cfcfaa118801eefb44e7870072a265d688749544b633f573685a8c547d4e1397dd018866b103d798fd4f3a7ab9d1df4e14114
|
7
|
+
data.tar.gz: ec2a1666a38aa79504b49ec21150116842f174b0dadbbdd64bea633b91b0f253fe032eb489b58c29e12dea2ae851c9aea1d6d8df962cf392c357a3bfdc65441a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at cristiano@betta.io. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
swagger-template (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
awesome_print (1.8.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
rake (10.5.0)
|
12
|
+
rspec (3.7.0)
|
13
|
+
rspec-core (~> 3.7.0)
|
14
|
+
rspec-expectations (~> 3.7.0)
|
15
|
+
rspec-mocks (~> 3.7.0)
|
16
|
+
rspec-core (3.7.0)
|
17
|
+
rspec-support (~> 3.7.0)
|
18
|
+
rspec-expectations (3.7.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.7.0)
|
21
|
+
rspec-mocks (3.7.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.7.0)
|
24
|
+
rspec-support (3.7.0)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
awesome_print (~> 1.8.0)
|
31
|
+
bundler (~> 1.16.a)
|
32
|
+
rake (~> 10.0)
|
33
|
+
rspec (~> 3.0)
|
34
|
+
swagger-template!
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Cristiano Betta
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Swagger::Template
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/swagger/template`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'swagger-template'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install swagger-template
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/swagger-template. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the Swagger::Template project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/swagger-template/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "swagger/template/tasks"
|
4
|
+
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
task :default => :spec
|
8
|
+
|
9
|
+
desc 'Updates the SDK to reflect swagger specs found in ./swagger'
|
10
|
+
task :"swagger:template:generate" do
|
11
|
+
Swagger::Template::Tasks.new(
|
12
|
+
swagger_path: './source/swagger',
|
13
|
+
examples: './source/examples.json',
|
14
|
+
templates_path: './templates',
|
15
|
+
output_path: './output',
|
16
|
+
language: 'ruby',
|
17
|
+
root_entity: 'mail_send'
|
18
|
+
).generate
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Lists the files to be generated based on the Swagger spec'
|
22
|
+
task :"swagger:template:list" do
|
23
|
+
Swagger::Template::Tasks.new(
|
24
|
+
swagger_path: './source/swagger',
|
25
|
+
examples: './source/examples.json',
|
26
|
+
templates_path: './templates',
|
27
|
+
output_path: './output',
|
28
|
+
language: 'ruby',
|
29
|
+
root_entity: 'mail_send'
|
30
|
+
).list
|
31
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "swagger/template"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require "swagger/template/tasks/reader"
|
2
|
+
|
3
|
+
module Swagger
|
4
|
+
module Template
|
5
|
+
class Endpoint
|
6
|
+
attr_reader :path, :verb, :summary, :full_path, :classes, :filename,
|
7
|
+
:parameters, :dirname, :snakecases
|
8
|
+
|
9
|
+
def initialize(spec, path, verb)
|
10
|
+
@spec = spec
|
11
|
+
@path = path
|
12
|
+
@verb = verb
|
13
|
+
extract_summary
|
14
|
+
extract_full_path
|
15
|
+
determine_classes
|
16
|
+
determine_snakecases
|
17
|
+
determine_filename
|
18
|
+
determine_dirname
|
19
|
+
determine_required_parameters
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_h
|
23
|
+
{
|
24
|
+
verb: verb,
|
25
|
+
path: path,
|
26
|
+
summary: summary,
|
27
|
+
full_path: full_path,
|
28
|
+
classes: classes,
|
29
|
+
filename: filename,
|
30
|
+
dirname: dirname,
|
31
|
+
parameters: parameters
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def extract_summary
|
38
|
+
@summary = @spec['paths'][path][verb]['summary']
|
39
|
+
end
|
40
|
+
|
41
|
+
def extract_full_path
|
42
|
+
@full_path = "#{@spec['basePath']}#{path}"
|
43
|
+
end
|
44
|
+
|
45
|
+
def determine_classes
|
46
|
+
@classes = path.split('/').drop(1).map do |chunk|
|
47
|
+
chunk.split('-').map(&:capitalize).join('')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def determine_snakecases
|
52
|
+
@snakecases = path.split('/').drop(1).map do |chunk|
|
53
|
+
chunk.gsub('-', '_')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def determine_filename
|
58
|
+
@filename = path.split('/').drop(1).map do |chunk|
|
59
|
+
chunk.gsub('-', '_')
|
60
|
+
end.join('/')
|
61
|
+
end
|
62
|
+
|
63
|
+
def determine_dirname
|
64
|
+
@dirname = filename.split('/').reverse.drop(1).reverse.join('/')
|
65
|
+
end
|
66
|
+
|
67
|
+
def determine_required_parameters
|
68
|
+
@parameters = @spec['paths'][path][verb]['parameters'].select do |param|
|
69
|
+
param['required']
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "awesome_print"
|
2
|
+
require "json"
|
3
|
+
require "swagger/template/tasks/reader"
|
4
|
+
require "swagger/template/tasks/writer"
|
5
|
+
|
6
|
+
module Swagger
|
7
|
+
module Template
|
8
|
+
class Tasks
|
9
|
+
def initialize(options = {})
|
10
|
+
@swagger_path = options[:swagger_path]
|
11
|
+
@templates_path = options[:templates_path]
|
12
|
+
@examples = JSON.parse(File.read(options[:examples]))
|
13
|
+
@output_path = options[:output_path]
|
14
|
+
@language = options[:language]
|
15
|
+
@root_entity = options[:root_entity]
|
16
|
+
end
|
17
|
+
|
18
|
+
def list
|
19
|
+
endpoints = Swagger::Template::Tasks::Reader.new(@swagger_path).read
|
20
|
+
endpoints.each do |endpoint|
|
21
|
+
ap endpoint.to_h
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def generate
|
26
|
+
endpoints = Swagger::Template::Tasks::Reader.new(@swagger_path).read
|
27
|
+
Swagger::Template::Tasks::Writer.new(
|
28
|
+
endpoints: endpoints,
|
29
|
+
templates_path: @templates_path,
|
30
|
+
output_path: @output_path,
|
31
|
+
root_entity: @root_entity,
|
32
|
+
root_entity_class: @root_entity.split('_').map(&:capitalize).join,
|
33
|
+
language: @language,
|
34
|
+
examples: @examples
|
35
|
+
).write
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'json'
|
2
|
+
require "swagger/template/endpoint"
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
module Template
|
6
|
+
class Tasks
|
7
|
+
class Reader
|
8
|
+
def initialize(path)
|
9
|
+
@path = path
|
10
|
+
end
|
11
|
+
|
12
|
+
# Reads out the required info from the provided path
|
13
|
+
def read
|
14
|
+
specs = read_swagger_specs(@path)
|
15
|
+
endpoints = extract_endpoints(specs)
|
16
|
+
# enrich_all(endpoints)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
# Extract every path from the endpoints, generating a list of endpoints
|
22
|
+
# and related data
|
23
|
+
def extract_endpoints(specs)
|
24
|
+
specs.map do |spec|
|
25
|
+
spec['paths'].keys.map do |path|
|
26
|
+
spec['paths'][path].keys.map do |verb|
|
27
|
+
Swagger::Template::Endpoint.new(spec, path, verb)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end.flatten
|
31
|
+
end
|
32
|
+
|
33
|
+
# Reads the Swagger specs from the path
|
34
|
+
def read_swagger_specs(path)
|
35
|
+
Dir["#{path}/**/*.json"].map do |filename|
|
36
|
+
JSON.parse(File.read(filename))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Swagger
|
5
|
+
module Template
|
6
|
+
class Tasks
|
7
|
+
class Writer
|
8
|
+
def initialize(options = {})
|
9
|
+
@endpoints = options[:endpoints]
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def write
|
14
|
+
@endpoints.each do |endpoint|
|
15
|
+
render('endpoint', endpoint)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def render(filename, endpoint)
|
20
|
+
@template_filename = "#{@options[:templates_path]}" \
|
21
|
+
"/#{@options[:language]}/#{filename}.erb"
|
22
|
+
@template = File.read(@template_filename)
|
23
|
+
rendered = ERB.new(@template, nil, '-').result(binding).tap{|ob| puts ob }
|
24
|
+
directory = "#{@options[:output_path]}/#{endpoint.dirname}"
|
25
|
+
filename = "#{@options[:output_path]}/#{endpoint.filename}.rb"
|
26
|
+
|
27
|
+
FileUtils.mkdir_p(directory) unless File.directory?(directory)
|
28
|
+
|
29
|
+
File.open(filename, 'w') { |file| file.write(rendered) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "swagger/template/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "swagger-template"
|
8
|
+
spec.version = Swagger::Template::VERSION
|
9
|
+
spec.authors = ["Cristiano Betta"]
|
10
|
+
spec.email = ["cristiano@betta.io"]
|
11
|
+
|
12
|
+
spec.summary = "Generate namespaced clients of template & OpenAPI spec"
|
13
|
+
spec.description = "Generate namespaced clients of template & OpenAPI spec"
|
14
|
+
spec.homepage = "https://github.com/workbetta/swagger-template"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "awesome_print", "~> 1.8.0"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16.a"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module <%= @options[:root_entity_class] %>
|
2
|
+
class Client
|
3
|
+
# A namespaced client for the
|
4
|
+
# +<%= endpoint.full_path %>+ endpoints
|
5
|
+
#
|
6
|
+
# Access via the +<%= @options[:root_entity_class] %>::Client+ object
|
7
|
+
#
|
8
|
+
# <%= @options[:root_entity] %> = <%= @options[:root_entity_class] %>::Client.new
|
9
|
+
# <%= @options[:root_entity] %>.<%= endpoint.snakecases.join('.') %>
|
10
|
+
#
|
11
|
+
class <%= endpoint.classes.join('::') %> < <%= @options[:root_entity_class] %>::Client::Decorator
|
12
|
+
# <%= endpoint.summary %>
|
13
|
+
#
|
14
|
+
<% endpoint.parameters.each do |parameter| -%>
|
15
|
+
# @option params [<%= parameter['type'].capitalize %>] :<%= parameter['name'] %>
|
16
|
+
<% end -%>
|
17
|
+
#
|
18
|
+
# @return [<%= @options[:root_entity_class] %>::Response] a parsed response
|
19
|
+
# @raise [<%= @options[:root_entity_class] %>::Exceptions::Base] an exception if the call failed
|
20
|
+
#
|
21
|
+
# @example
|
22
|
+
# <%= @options[:root_entity] %>.<%= endpoint.snakecases.join('.') %>.<%= endpoint.verb %>(
|
23
|
+
<% endpoint.parameters.each do |parameter| -%>
|
24
|
+
# <%= parameter['name'] %>: <%= @options[:examples][parameter['name']].inspect %>,
|
25
|
+
<% end -%>
|
26
|
+
# )
|
27
|
+
#
|
28
|
+
def <%= endpoint.verb %>(params = {})
|
29
|
+
client.<%= endpoint.verb %>('<%= endpoint.full_path %>', params)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: swagger-template
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cristiano Betta
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: awesome_print
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.8.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.16.a
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.16.a
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: Generate namespaced clients of template & OpenAPI spec
|
70
|
+
email:
|
71
|
+
- cristiano@betta.io
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".rubocop.yml"
|
79
|
+
- ".travis.yml"
|
80
|
+
- CODE_OF_CONDUCT.md
|
81
|
+
- Gemfile
|
82
|
+
- Gemfile.lock
|
83
|
+
- LICENSE.txt
|
84
|
+
- README.md
|
85
|
+
- Rakefile
|
86
|
+
- bin/console
|
87
|
+
- bin/setup
|
88
|
+
- lib/swagger/template/endpoint.rb
|
89
|
+
- lib/swagger/template/tasks.rb
|
90
|
+
- lib/swagger/template/tasks/reader.rb
|
91
|
+
- lib/swagger/template/tasks/template.rb
|
92
|
+
- lib/swagger/template/tasks/writer.rb
|
93
|
+
- lib/swagger/template/version.rb
|
94
|
+
- swagger-template.gemspec
|
95
|
+
- templates/ruby/endpoint.erb
|
96
|
+
homepage: https://github.com/workbetta/swagger-template
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.7.3
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Generate namespaced clients of template & OpenAPI spec
|
120
|
+
test_files: []
|