jsonapi-swagger 0.3.1 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38a21f228ae6527871910d16622f39218d08f0c8310d44efd7b9472dd089e172
4
- data.tar.gz: e44e41b8e18e7eda501da5b20bf15fc79c35f6fa351340d8fdb13e2d2d7907b5
3
+ metadata.gz: 3d75e88719af0dce5ecee9e6063d2d25c9592038293ebc26340afd2c692e9c1f
4
+ data.tar.gz: 30b4a6d0d565c712c4781ff7115ff15e4c9a8cd2397b476bf60ffea91ef63208
5
5
  SHA512:
6
- metadata.gz: 3a780d9bb80023f3c2350edb259cc45219e4acbb912381539e4a1bcf7c91307e2f858bba8f3c5eab484a5bb890b36a497fe41333204efcbe44c2a111ce5e3288
7
- data.tar.gz: 7262ffab5f06d2e7423d6bff37bb8ae4aac44053aab3d9c0eef4a912db4af71a86858d490651e175b791d0ed90f81c914b2a46d761669353af23b169c395f657
6
+ metadata.gz: d2c380d494e0f6b2c094266e50c45b0faef5f51cac0b3bab76a1e32027a9e63adeaf4d63f6652e6ed2c56d0c797bc54d659fd124d5a000c13173401bee0eeb64
7
+ data.tar.gz: 6881dcef1d7f977aee13f837b5b8809cb7bdcbfe3b745f00d4c8af8cc198132c42419daf6bae2a171dafe92daf5d4349b08b57ee5451c192a4883b321ac3e5b9
@@ -50,6 +50,10 @@ module Jsonapi
50
50
  resource_klass._relationships
51
51
  end
52
52
 
53
+ def filters
54
+ resource_klass.filters
55
+ end
56
+
53
57
  def columns_with_comment
54
58
  @columns_with_comment ||= {}.tap do |clos|
55
59
  model_klass.columns.each do |col|
@@ -60,6 +64,7 @@ module Jsonapi
60
64
 
61
65
  def swagger_type(column)
62
66
  return 'array' if column.array
67
+
63
68
  case column.type
64
69
  when :bigint, :integer then 'integer'
65
70
  when :boolean then 'boolean'
@@ -12,6 +12,9 @@ RSpec.describe '<%= resouces_name %>', type: :request do
12
12
  produces 'application/vnd.api+json'
13
13
  parameter name: :'page[number]', in: :query, type: :string, description: '<%= t(:page_num) %>', required: false
14
14
  parameter name: :include, in: :query, type: :string, description: '<%= t(:include_related_data) %>', required: false
15
+ <% filters.each do |filter_attr, filter_config| -%>
16
+ parameter name: :'filter[<%= filter_attr %>]', in: :query, type: :string, description: '<%= t(:filter_field) %>', <% if filter_config[:default] -%>default: '<%= safe_encode(filter_config[:default]) %>',<% end %>required: false
17
+ <% end -%>
15
18
  parameter name: :'fields[<%= route_resouces %>]', in: :query, type: :string, description: '<%= t(:display_field) %>', required: false
16
19
  <% relationships.each_value do |relation| -%>
17
20
  parameter name: :'fields[<%= relation.class_name.tableize %>]', in: :query, type: :string, description: '<%= t(:display_field) %>', required: false
@@ -36,7 +39,7 @@ RSpec.describe '<%= resouces_name %>', type: :request do
36
39
  type: :object,
37
40
  properties: {
38
41
  <% attributes.each_key.each do |attr| -%>
39
- <%= attr %>: { type: :<%= columns_with_comment[attr][:type] %>, <%if columns_with_comment[attr][:is_array] -%> items: { type: :<%= columns_with_comment[attr][:items_type] %>},<% end -%> 'x-nullable': <%= columns_with_comment[attr][:nullable] %>, description: '<%= columns_with_comment[attr][:comment] %>'},
42
+ <%= attr %>: { type: :<%= columns_with_comment[attr][:type] %>, <%if columns_with_comment[attr][:is_array] -%> items: { type: :<%= columns_with_comment[attr][:items_type] %>},<% end -%>'x-nullable': <%= columns_with_comment[attr][:nullable] %>, description: '<%= columns_with_comment[attr][:comment] %>'},
40
43
  <% end -%>
41
44
  },
42
45
  description: '<%= t(:attributes) %>'
@@ -120,7 +123,7 @@ RSpec.describe '<%= resouces_name %>', type: :request do
120
123
  type: :object,
121
124
  properties: {
122
125
  <% attributes.each_key.each do |attr| -%>
123
- <%= attr %>: { type: :<%= columns_with_comment[attr][:type] %>, <%if columns_with_comment[attr][:is_array] -%> items: { type: :<%= columns_with_comment[attr][:items_type] %>},<% end -%> 'x-nullable': <%= columns_with_comment[attr][:nullable] %>, description: '<%= columns_with_comment[attr][:comment] %>'},
126
+ <%= attr %>: { type: :<%= columns_with_comment[attr][:type] %>, <%if columns_with_comment[attr][:is_array] -%> items: { type: :<%= columns_with_comment[attr][:items_type] %>},<% end -%>'x-nullable': <%= columns_with_comment[attr][:nullable] %>, description: '<%= columns_with_comment[attr][:comment] %>'},
124
127
  <% end -%>
125
128
  },
126
129
  description: '<%= t(:attributes) %>'
data/lib/i18n/en.yml CHANGED
@@ -3,6 +3,7 @@ en:
3
3
  page_num: 'Page Number'
4
4
  include_related_data: 'Include Related Data'
5
5
  display_field: 'Display Field'
6
+ filter_field: 'Filter Field'
6
7
  list: 'List'
7
8
  get_list: 'Fetch List'
8
9
  detail_link: 'Detail Link'
data/lib/i18n/zh-CN.yml CHANGED
@@ -3,6 +3,7 @@ zh-CN:
3
3
  page_num: '页码'
4
4
  include_related_data: '包含关联数据'
5
5
  display_field: '显示字段'
6
+ filter_field: '过滤字段'
6
7
  list: '列表'
7
8
  get_list: '获取列表'
8
9
  detail_link: '详情链接'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jsonapi
4
4
  module Swagger
5
- VERSION = '0.3.1'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-swagger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YingRui Lu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-28 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler