swagger_codegen_rails 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: eee36b636a3453a8c2afb020421db4f9f0fc4488
4
- data.tar.gz: 7fe0a82fef3a63aa4b66ac4238429d814bc2a6b3
2
+ SHA256:
3
+ metadata.gz: c23da6493e46a0fe783c81597ad8e0bffa605f7e5f133b6a701458730be9e4eb
4
+ data.tar.gz: f6da5bc77b6132383338a571f7720b82d74fd0f3f0e2b0c181978e295afa0bb2
5
5
  SHA512:
6
- metadata.gz: 662d20770af70fb724ffe04d002dd99c359381043e7e35810faed1a6eded03d977fa92e06d98b898e32270b96a460b121fbba7241acaadf9654ca33454b94da6
7
- data.tar.gz: b07e408eeab460b42ef667e9575f64c1cc6a01e2c45c9b32942422ceec5b22d045ff025977bd3351283df51d3af721b7ca87da28a357c05c127a292a51a4729b
6
+ metadata.gz: 8b7aaab84299f12322d83dd0a2a0290d7e4b8341539e823b435f10b2ea8f8b4ccc91120b37081166431fedcfcfb7b205e8087e8072deb4a98054d03b575453db
7
+ data.tar.gz: 7670e9e0bf2b886a3c0ac19c66bdf182921a7b4ab04470c42f82798110370f679b3d3d922a85bb27259c6f3607fea2127c1f9f79f62fb606ff42d7710aa28aef
data/README.md CHANGED
@@ -29,7 +29,7 @@ $ gem install swagger_codegen_rails
29
29
  ```bash
30
30
  $ rails g swagger:install
31
31
  $ rails g swagger:init /api/v1
32
- $ rails g swagger:add /api/v1 /api/v1/user/:id id:path:integer:true
32
+ $ rails g swagger:add /api/v1 get /api/v1/user/:id id:path:integer:true
33
33
  ```
34
34
 
35
35
  ### Create intializer file
@@ -42,8 +42,6 @@ $ rails g swagger:install
42
42
  # config/initializers/swagger_codegen_rails.rb
43
43
 
44
44
  SwaggerCodegenRails.configure do |config|
45
- config.versioned = false # boolean
46
-
47
45
  config.versions_url = {
48
46
  v1: 'api/v1',
49
47
  v2: 'api/v2'
@@ -61,7 +59,6 @@ Options:
61
59
 
62
60
  |configurations|type|default|description|
63
61
  |:------|:----|:-|:-------------------------|
64
- |config.versioned|boolean|false|set path of versioned API documentations|
65
62
  config.versions_url|hash|EMPTY|define versioned path|
66
63
  |config.concern_dir|string|/app/controllers/concern|set root path of endpoint documentations|
67
64
  |config.schema_dir|string|/app/models/concern|set root path of response schema documentations|
@@ -76,9 +73,8 @@ $ rails g swagger:init NAMESPACE
76
73
  ```bash
77
74
  $ rails g swagger:add NAMESPACE HTTP_METHOD URI [PARAMETERS; name:in:type:required]
78
75
  $ # If you do NOT want namespace, example below
79
- $ rails g swagger:add . GET /users id:path:integer:true
76
+ $ rails g swagger:add . get /users id:path:integer:true
80
77
  ```
81
-
82
78
  Parameters:
83
79
 
84
80
  ||description|
@@ -89,6 +85,21 @@ Parameters:
89
85
  |required|required|
90
86
 
91
87
 
88
+ ### To show SwaggerUI
89
+ Add these lines in your config/application.rb (If you won't create versioned API, it is no needed.)
90
+ ```Ruby
91
+ # config/application.rb
92
+ config.paths.add "#{config.root}/app/controllers/**/*", glob: "**/*", eager_load: true
93
+ ```
94
+
95
+ Then start your server with rails command
96
+ ```bash
97
+ $ rails s
98
+ ```
99
+ And access ``http://localhost:3000/swagger`` in browser.
100
+
101
+
102
+
92
103
  ## Contributing
93
104
  1. Fork it ( https://github.com/technobrain/swagger_codegen_rails )
94
105
  2. Create your feature branch (git checkout -b my-new-feature)
@@ -21,10 +21,19 @@ module Swagger
21
21
  end
22
22
 
23
23
  private
24
+
24
25
  def module_name
25
26
  swagger_file_name.camelize
26
27
  end
27
28
 
29
+ def full_uri
30
+ if uri.sub(/\A\//, "").start_with?(namespace)
31
+ '/' + uri.sub(/\A\//, "")
32
+ else
33
+ '/' + namespace + '/' + uri.sub(/\A\//, "")
34
+ end
35
+ end
36
+
28
37
  def namespace
29
38
  config = SwaggerCodegenRails.configuration.versions_url
30
39
  config ? (config[name.to_sym] || name) : name
@@ -6,12 +6,12 @@ module <%= module_name %>
6
6
  include_swagger '<%= swagger_schema_dir -%>', type: :model
7
7
 
8
8
  included do
9
- swagger_path '<%= uri -%>' do
9
+ swagger_path '<%= full_uri -%>' do
10
10
  operation :<%= http_method.downcase -%> do
11
11
  key :description, "TODO: describe endpoint here"
12
12
  key :operationId, "TODO: "
13
13
  key :produces, [
14
- 'application/join',
14
+ 'application/json',
15
15
  ]
16
16
  key :tags, [
17
17
  # A list of tags used by the specification with additional metadata.
@@ -33,14 +33,14 @@ module <%= module_name %>
33
33
  # key :'$ref', TODO:
34
34
  end
35
35
  end
36
-
36
+
37
37
  response 404 do
38
38
  key :description, "TODO: "
39
39
  schema do
40
40
  # key :'$ref', TODO:
41
41
  end
42
42
  end
43
-
43
+
44
44
  response 501 do
45
45
  key :description, "TODO: "
46
46
  schema do
@@ -19,11 +19,5 @@ module Swagger
19
19
  gem 'swagger_ui_engine'
20
20
  gem 'swagger-blocks'
21
21
  end
22
-
23
- private
24
- def initializer_exist?
25
- initializer_path = "config/initializers/swagger_ui_engine.rb"
26
- File.exist?(initializer_path)
27
- end
28
22
  end
29
23
  end
@@ -1,19 +1,11 @@
1
1
  module SwaggerCodegenRails
2
2
  module Base
3
3
  def concern_dir
4
- concerns.call
5
- end
6
-
7
- def concerns
8
- Proc.new { SwaggerCodegenRails.configuration.concern_dir }
4
+ SwaggerCodegenRails.configuration.concern_dir
9
5
  end
10
6
 
11
7
  def schema_dir
12
- schemas.call
13
- end
14
-
15
- def schemas
16
- Proc.new { SwaggerCodegenRails.configuration.schema_dir }
8
+ SwaggerCodegenRails.configuration.schema_dir
17
9
  end
18
10
  end
19
11
  end
@@ -2,6 +2,5 @@ module SwaggerCodegenRails
2
2
  DEFAULTS = {
3
3
  concern_dir: "app/controllers/concerns",
4
4
  schema_dir: "app/models/concerns",
5
- versioned: false
6
5
  }
7
6
  end
@@ -45,8 +45,9 @@ module SwaggerCodegenRails
45
45
  # => hoge/foo/bar
46
46
  # ------------
47
47
  def reduct(source, reduction)
48
- File.join(File.dirname(source.sub(reduction, '')), File.basename(source, File.extname(source))).sub(/\A\//,'')
49
-
48
+ File.join(File.dirname(source.sub(reduction, '')),
49
+ File.basename(source,
50
+ File.extname(source))).sub(/\A\//,'')
50
51
  end
51
52
 
52
53
  # ------------
@@ -56,7 +57,6 @@ module SwaggerCodegenRails
56
57
  def constant(str)
57
58
  str.split("/").map(&:camelize).join("::").constantize
58
59
  end
59
-
60
60
  end
61
61
  end
62
62
  end
@@ -10,8 +10,8 @@ module SwaggerCodegenRails
10
10
  self[i] = params[i].blank? ? "TODO" : params[i]
11
11
  end
12
12
  rescue IndexError => e
13
- logger.error e
14
- logger.error e.backtrace.join("\n")
13
+ Rails.logger.error e
14
+ Rails.logger.error e.backtrace.join("\n")
15
15
  return nil
16
16
  end
17
17
 
@@ -2,5 +2,6 @@ module SwaggerCodegenRails
2
2
  #VERSION = '0.0.1' 2018/02/26
3
3
  #VERSION = '0.0.12' #2018/02/27
4
4
  #VERSION = '0.1.01' #2018/02/28
5
- VERSION = '0.1.1' #2018/03/01
5
+ #VERSION = '0.1.1' #2018/03/01
6
+ VERSION = '0.1.2' #2018/04/23
6
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swagger_codegen_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akifumi Tomiyama
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-01 00:00:00.000000000 Z
12
+ date: 2018-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -158,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  version: '0'
159
159
  requirements: []
160
160
  rubyforge_project:
161
- rubygems_version: 2.6.14
161
+ rubygems_version: 2.7.3
162
162
  signing_key:
163
163
  specification_version: 4
164
164
  summary: Generator for swagger-blocks and swagger_ui_engine