weak_swagger_parameters 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/weak_swagger_parameters/definitions/api.rb +25 -23
- data/lib/weak_swagger_parameters/version.rb +1 -1
- data/weak_swagger_parameters.gemspec +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589aa60bdf2a8aa4440760767a381550ad571bc8
|
4
|
+
data.tar.gz: 51ba734c3937cd9f7638f1227c7fb52dc358c582
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff490d4fab86590a2d39655a3919c07c2f6034daf83fdc06d631147ebecc34bdeaa90123ac394fbde2cd070d39143e5a62ba66b5d1ffe76c14fc8a8ac11dbc6d
|
7
|
+
data.tar.gz: 93f1d65d0aa7c5315498a7c7585aa9ca904cc75ee37d2abbfeb43d45abb1f208bd95130d802b8f9dfe846bd1a8edcfc699b783921f124713de7bebec103b604d
|
data/.rubocop.yml
CHANGED
@@ -2,7 +2,15 @@
|
|
2
2
|
module WeakSwaggerParameters
|
3
3
|
module Definitions
|
4
4
|
class Api
|
5
|
-
|
5
|
+
KNOWN_METHODS = {
|
6
|
+
create: :post,
|
7
|
+
index: :get,
|
8
|
+
show: :get,
|
9
|
+
destroy: :delete,
|
10
|
+
update: :put
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
attr_reader :path
|
6
14
|
|
7
15
|
def initialize(method, path, summary, &block)
|
8
16
|
@method = method
|
@@ -15,6 +23,10 @@ module WeakSwaggerParameters
|
|
15
23
|
instance_eval(&block)
|
16
24
|
end
|
17
25
|
|
26
|
+
def description(description)
|
27
|
+
@description = description
|
28
|
+
end
|
29
|
+
|
18
30
|
def params(&block)
|
19
31
|
@param_definition = WeakSwaggerParameters::Definitions::Params.new(&block)
|
20
32
|
end
|
@@ -35,40 +47,30 @@ module WeakSwaggerParameters
|
|
35
47
|
end
|
36
48
|
|
37
49
|
def apply_docs(controller_class)
|
38
|
-
|
39
|
-
|
40
|
-
method = http_method
|
41
|
-
operation_params = operation_params(method, controller_class)
|
50
|
+
this = self
|
51
|
+
operation_params = operation_params(http_method, controller_class)
|
42
52
|
|
43
53
|
controller_class.instance_eval do
|
44
|
-
swagger_path path do
|
45
|
-
operation
|
46
|
-
child_definitions.each { |definition| definition.apply_docs(self) }
|
54
|
+
swagger_path this.path do
|
55
|
+
operation this.http_method, operation_params do
|
56
|
+
this.child_definitions.each { |definition| definition.apply_docs(self) }
|
47
57
|
end
|
48
58
|
end
|
49
59
|
end
|
50
60
|
end
|
51
61
|
|
52
|
-
|
53
|
-
|
54
|
-
def doc_definitions
|
62
|
+
def child_definitions
|
55
63
|
validation_definitions + @response_definitions
|
56
64
|
end
|
57
65
|
|
58
|
-
def
|
59
|
-
[@
|
66
|
+
def http_method
|
67
|
+
KNOWN_METHODS[@method]
|
60
68
|
end
|
61
69
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
show: :get,
|
67
|
-
destroy: :delete,
|
68
|
-
update: :put
|
69
|
-
}
|
70
|
-
|
71
|
-
known_methods[@method]
|
70
|
+
private
|
71
|
+
|
72
|
+
def validation_definitions
|
73
|
+
[@param_definition]
|
72
74
|
end
|
73
75
|
|
74
76
|
def operation_params(method, controller_class)
|
@@ -2,10 +2,11 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
lib = File.expand_path('../lib', __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'weak_swagger_parameters/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
8
|
spec.name = 'weak_swagger_parameters'
|
8
|
-
spec.version =
|
9
|
+
spec.version = ::WeakSwaggerParameters::VERSION
|
9
10
|
spec.authors = ['AgileFreaks']
|
10
11
|
spec.email = ['office@agilefreaks.com']
|
11
12
|
|