jsonapi_swagger_helpers 0.4.2 → 0.4.3
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 +4 -4
- data/lib/jsonapi_swagger_helpers/create_action.rb +5 -1
- data/lib/jsonapi_swagger_helpers/index_action.rb +8 -0
- data/lib/jsonapi_swagger_helpers/payload_definition.rb +4 -1
- data/lib/jsonapi_swagger_helpers/readable.rb +17 -0
- data/lib/jsonapi_swagger_helpers/resource_mixin.rb +1 -1
- data/lib/jsonapi_swagger_helpers/show_action.rb +8 -0
- data/lib/jsonapi_swagger_helpers/update_action.rb +5 -1
- data/lib/jsonapi_swagger_helpers/version.rb +1 -1
- data/lib/jsonapi_swagger_helpers/writeable.rb +36 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1feea97f395c500cbf8914d31a2e02a3ad0529cd
|
4
|
+
data.tar.gz: 1d5e093336798ba21f41020ef8b58c83e8fa979e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13265b4a6f5f91b060536991587c8be0878537e705230faf04cd8df381e138257d573ad8dbaf6d3fba1e9d6ce9c25448f0e243566af0c29ea3d9f09393c8d9a6
|
7
|
+
data.tar.gz: c277e20daa4b1785cfbffb826267e34c733179c4ba21a87dd120ffa24508e551d19e52d346d8a9347a119404f11d8aab0b1b8c52acffb65d72b209e627632a69
|
@@ -20,9 +20,13 @@ module JsonapiSwaggerHelpers
|
|
20
20
|
key :in, :body
|
21
21
|
|
22
22
|
schema do
|
23
|
-
key :'$ref',
|
23
|
+
key :'$ref', _self.request_schema_id
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
response 200 do
|
28
|
+
key :description, 'API Response'
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
@@ -8,12 +8,20 @@ module JsonapiSwaggerHelpers
|
|
8
8
|
|
9
9
|
def generate
|
10
10
|
_self = self
|
11
|
+
generate_response_schema!
|
11
12
|
|
12
13
|
@node.operation :get do
|
13
14
|
key :description, _self.full_description
|
14
15
|
key :operationId, _self.operation_id
|
15
16
|
key :tags, _self.all_tags
|
16
17
|
|
18
|
+
response 200 do
|
19
|
+
key :description, 'API Response'
|
20
|
+
schema do
|
21
|
+
key :'$ref', _self.response_schema_id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
17
25
|
_self.util.jsonapi_sorting(self)
|
18
26
|
_self.util.jsonapi_pagination(self)
|
19
27
|
|
@@ -50,7 +50,10 @@ module JsonapiSwaggerHelpers
|
|
50
50
|
property attribute do
|
51
51
|
type = _self.class.swagger_type_for(payload.name, attribute, config[:type])
|
52
52
|
key :type, type
|
53
|
-
|
53
|
+
|
54
|
+
if config[:description]
|
55
|
+
key :description, config[:description]
|
56
|
+
end
|
54
57
|
end
|
55
58
|
end
|
56
59
|
end
|
@@ -78,6 +78,23 @@ module JsonapiSwaggerHelpers
|
|
78
78
|
resource.config[:type]
|
79
79
|
end
|
80
80
|
|
81
|
+
def response_schema_id
|
82
|
+
"#{operation_id}_#{action_name}_response"
|
83
|
+
end
|
84
|
+
|
85
|
+
def generate_response_schema!
|
86
|
+
_self = self
|
87
|
+
|
88
|
+
payloads = util.payloads_for(resource, include_directive.to_hash)
|
89
|
+
JsonapiSwaggerHelpers.docs_controller.send(:swagger_schema, response_schema_id) do
|
90
|
+
payloads.each do |p|
|
91
|
+
property p.name do
|
92
|
+
key :'$ref', p.name
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
81
98
|
def generate
|
82
99
|
raise 'override me'
|
83
100
|
end
|
@@ -20,7 +20,7 @@ module JsonapiSwaggerHelpers
|
|
20
20
|
tags = config[:tags]
|
21
21
|
descriptions = config[:descriptions]
|
22
22
|
only = config[:only]
|
23
|
-
except = config[:
|
23
|
+
except = config[:except]
|
24
24
|
|
25
25
|
actions = [:index, :show, :create, :update, :destroy]
|
26
26
|
actions.select! { |a| only.include?(a) } unless only.empty?
|
@@ -8,12 +8,20 @@ module JsonapiSwaggerHelpers
|
|
8
8
|
|
9
9
|
def generate
|
10
10
|
_self = self
|
11
|
+
generate_response_schema!
|
11
12
|
|
12
13
|
@node.operation :get do
|
13
14
|
key :description, _self.full_description
|
14
15
|
key :operationId, _self.operation_id
|
15
16
|
key :tags, _self.all_tags
|
16
17
|
|
18
|
+
response 200 do
|
19
|
+
key :description, 'API Response'
|
20
|
+
schema do
|
21
|
+
key :'$ref', _self.response_schema_id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
17
25
|
_self.util.id_in_url(self)
|
18
26
|
_self.util.jsonapi_fields(self, _self.jsonapi_type)
|
19
27
|
|
@@ -22,9 +22,13 @@ module JsonapiSwaggerHelpers
|
|
22
22
|
key :in, :body
|
23
23
|
|
24
24
|
schema do
|
25
|
-
key :'$ref',
|
25
|
+
key :'$ref', _self.request_schema_id
|
26
26
|
end
|
27
27
|
end
|
28
|
+
|
29
|
+
response 200 do
|
30
|
+
key :description, 'API Response'
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
end
|
@@ -56,21 +56,53 @@ module JsonapiSwaggerHelpers
|
|
56
56
|
controller._strong_resources[action_name]
|
57
57
|
end
|
58
58
|
|
59
|
+
def request_schema_id
|
60
|
+
"#{operation_id}_#{action_name}_request"
|
61
|
+
end
|
62
|
+
|
63
|
+
def generate_request_schema!
|
64
|
+
_self = self
|
65
|
+
|
66
|
+
JsonapiSwaggerHelpers.docs_controller.send(:swagger_schema, request_schema_id) do
|
67
|
+
property _self.strong_resource.name do
|
68
|
+
key :'$ref', :"#{_self.strong_resource.name}_#{_self.action_name}"
|
69
|
+
end
|
70
|
+
|
71
|
+
_self.each_strong_relation(_self.strong_resource) do |relation_name, relation_config|
|
72
|
+
property relation_name do
|
73
|
+
key :'$ref', :"#{_self.strong_resource.name}_#{relation_name}_#{_self.action_name}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def each_strong_relation(strong_resource)
|
80
|
+
strong_resource.relations.each_pair do |relation_name, relation_config|
|
81
|
+
yield relation_name, relation_config
|
82
|
+
|
83
|
+
each_strong_relation(relation_config[:resource]) do |sub_relation_name, sub_relation_config|
|
84
|
+
yield sub_relation_name, sub_relation_config
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
59
89
|
def define_schema
|
90
|
+
generate_request_schema!
|
91
|
+
|
60
92
|
_self = self
|
61
93
|
context.send(:swagger_schema, :"#{strong_resource.name}_#{action_name}") do
|
62
94
|
_self.strong_resource.attributes.each_pair do |attribute, config|
|
63
95
|
property attribute do
|
64
|
-
key :type, config[:type]
|
96
|
+
key :type, config[:type]
|
65
97
|
end
|
66
98
|
end
|
67
99
|
end
|
68
100
|
|
69
|
-
_self.strong_resource
|
101
|
+
_self.each_strong_relation(_self.strong_resource) do |relation_name, relation_config|
|
70
102
|
context.send(:swagger_schema, :"#{strong_resource.name}_#{relation_name}_#{action_name}") do
|
71
103
|
relation_config[:resource].attributes.each_pair do |attribute, config|
|
72
104
|
property attribute do
|
73
|
-
key :type, config[:type]
|
105
|
+
key :type, config[:type]
|
74
106
|
end
|
75
107
|
end
|
76
108
|
end
|
@@ -78,14 +110,7 @@ module JsonapiSwaggerHelpers
|
|
78
110
|
end
|
79
111
|
|
80
112
|
def generate
|
81
|
-
|
82
|
-
|
83
|
-
define_schema
|
84
|
-
@node.operation :post do
|
85
|
-
key :description, _self.description
|
86
|
-
key :operationId, _self.operation_id
|
87
|
-
key :tags, _self.all_tags
|
88
|
-
end
|
113
|
+
raise 'override me'
|
89
114
|
end
|
90
115
|
end
|
91
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonapi_swagger_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lee Richmond
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: swagger-blocks
|