Skip to content

Commit

Permalink
chore: updating templates for ruby sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
emajo authored and fattureincloud-bot committed Feb 28, 2024
1 parent 08d923a commit e2568d5
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 29 deletions.
2 changes: 1 addition & 1 deletion templates/openapi-generator/ruby/Gemfile.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ gemspec
group :development, :test do
gem 'rake', '~> 13.0.1'
gem 'pry-byebug'
gem 'rubocop', '~> 1.12.0'
gem 'rubocop', '~> 0.66.0'
end
49 changes: 38 additions & 11 deletions templates/openapi-generator/ruby/README.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# FattureInCloud Ruby SDK

[![Ruby Gems](https://img.shields.io/gem/v/fattureincloud_ruby_sdk?color=g)](https://rubygems.org/gems/fattureincloud_ruby_sdk) ![unit tests](https://github.com/fattureincloud/fattureincloud-ruby-sdk/actions/workflows/validate.yaml/badge.svg)
# {{gemName}}

{{moduleName}} - the Ruby gem for the {{appName}}

Expand All @@ -16,20 +14,46 @@ This SDK is automatically generated by the [OpenAPI Generator](https://openapi-g
- Build date: {{generatedDate}}
{{/hideGenerationTimestamp}}
- Build package: {{generatorClass}}


{{#infoUrl}}
For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
{{/infoUrl}}

## Installation

### RubyGems
### Build a gem

To build the Ruby code into a gem:

```shell
gem build {{{gemName}}}.gemspec
```

Then either install the gem locally:

```shell
gem install ./{{{gemName}}}-{{{gemVersion}}}.gem
```

(for development, run `gem install --dev ./{{{gemName}}}-{{{gemVersion}}}.gem` to install the development dependencies)

or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).

Finally add this to the Gemfile:

gem '{{{gemName}}}', '~> {{{gemVersion}}}'

### Install from Git

If the Ruby gem is hosted at a git repository: https://{{gitHost}}/{{gitUserId}}{{^gitUserId}}YOUR_GIT_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}YOUR_GIT_REPO{{/gitRepoId}}, then add the following in the Gemfile:

gem '{{{gemName}}}', :git => 'https://{{gitHost}}/{{gitUserId}}{{^gitUserId}}YOUR_GIT_USERNAME{{/gitUserId}}/{{gitRepoId}}{{^gitRepoId}}YOUR_GIT_REPO{{/gitRepoId}}.git'

### Include the Ruby code directly

To install the gem via [RubyGems](https://rubygems.org/), run the following command:
Include the Ruby code directly using `-I` as follows:

```sh
$ gem install fattureincloud_ruby_sdk
```shell
ruby -Ilib script.rb
```

## Getting Started
Expand Down Expand Up @@ -61,6 +85,10 @@ require '{{{gemName}}}'
# Configure faraday connection
config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' }
{{/isFaraday}}
{{#isHttpx}}
# Configure httpx session
config.configure_session { |session| 'YOUR CONNECTION CONFIG PROC' }
{{/isHttpx}}
{{/authMethods}}end
{{/hasAuthMethods}}

Expand Down Expand Up @@ -127,8 +155,7 @@ Class | Method | HTTP request | Description
- **Flow**: {{flow}}
- **Authorization URL**: {{authorizationUrl}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}}
- **{{{scope}}}**: {{{description}}}
{{#scopes}} - {{scope}}: {{description}}
{{/scopes}}
{{/isOAuth}}

Expand Down
2 changes: 0 additions & 2 deletions templates/openapi-generator/ruby/base_object.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
when :Hash
value
else # model
# models (e.g. Pet) or oneOf
klass = {{moduleName}}.const_get(type)
Expand Down
12 changes: 0 additions & 12 deletions templates/openapi-generator/ruby/gem.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,6 @@ require '{{importPath}}'
{{/apis}}
{{/apiInfo}}

# Filter
require 'fattureincloud_ruby_sdk/filter/operator'
require 'fattureincloud_ruby_sdk/filter/condition'
require 'fattureincloud_ruby_sdk/filter/conjunction'
require 'fattureincloud_ruby_sdk/filter/disjunction'
require 'fattureincloud_ruby_sdk/filter/filter'
require 'fattureincloud_ruby_sdk/filter/expression'

#oauth
require 'fattureincloud_ruby_sdk/oauth2/oauth2'
require 'fattureincloud_ruby_sdk/oauth2/scope'

module {{moduleName}}
class << self
# Customize default settings for the SDK using block.
Expand Down
4 changes: 2 additions & 2 deletions templates/openapi-generator/ruby/gemspec.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Gem::Specification.new do |s|
s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}"
s.required_ruby_version = ">= {{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}2.7{{/gemRequiredRubyVersion}}"
s.metadata = {{{gemMetadata}}}{{^gemMetadata}}{}{{/gemMetadata}}
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.7{{/gemRequiredRubyVersion}}"
s.metadata = {{{gemMetadata}}}{{^gemMetadata}}{}{{/gemMetadata}}

{{#isFaraday}}
s.add_runtime_dependency 'faraday', '>= 1.0.1', '< 3.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,23 @@
| ---- | ---- | ----------- | ----- |
{{#vars}}
| **{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional]{{/required}}{{#isReadOnly}}[readonly]{{/isReadOnly}}{{#defaultValue}}[default to {{.}}]{{/defaultValue}} |
{{/vars}}
{{/vars}}

## Example

```ruby
require '{{{gemName}}}'

{{^vars}}
instance = {{moduleName}}::{{classname}}.new()
{{/vars}}
{{#vars}}
{{#-first}}
instance = {{moduleName}}::{{classname}}.new(
{{/-first}}
{{name}}: {{example}}{{^-last}},{{/-last}}
{{#-last}}
)
{{/-last}}
{{/vars}}
```

0 comments on commit e2568d5

Please sign in to comment.