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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3d75e88719af0dce5ecee9e6063d2d25c9592038293ebc26340afd2c692e9c1f
|
|
4
|
+
data.tar.gz: 30b4a6d0d565c712c4781ff7115ff15e4c9a8cd2397b476bf60ffea91ef63208
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 -%>
|
|
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 -%>
|
|
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
data/lib/i18n/zh-CN.yml
CHANGED
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.
|
|
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-
|
|
11
|
+
date: 2019-04-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|