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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1115da4842c8121b7889c7dda59162abd282be23
4
- data.tar.gz: fce57b9824de4ae255acb77253ff26c6e452755d
3
+ metadata.gz: 589aa60bdf2a8aa4440760767a381550ad571bc8
4
+ data.tar.gz: 51ba734c3937cd9f7638f1227c7fb52dc358c582
5
5
  SHA512:
6
- metadata.gz: 2d64a8a87628021d0a533dc54d1cce12b38e26eb1137fbee56e4cb56b66bad71641a878ec83afcc789e5274b20ce4d7bfd28b672989c1d4ab653cb195df35ba8
7
- data.tar.gz: e60a312ce9abcf379e0f4246906f3c5e68f16f745972d0126ed33af65925b86b8e2e1ea486282eca97a0d3dbc5bef758c2a96e51c59df0d04cca1561a41d059c
6
+ metadata.gz: ff490d4fab86590a2d39655a3919c07c2f6034daf83fdc06d631147ebecc34bdeaa90123ac394fbde2cd070d39143e5a62ba66b5d1ffe76c14fc8a8ac11dbc6d
7
+ data.tar.gz: 93f1d65d0aa7c5315498a7c7585aa9ca904cc75ee37d2abbfeb43d45abb1f208bd95130d802b8f9dfe846bd1a8edcfc699b783921f124713de7bebec103b604d
data/.rubocop.yml CHANGED
@@ -6,3 +6,6 @@ Metrics/LineLength:
6
6
 
7
7
  Style/Documentation:
8
8
  Enabled: false
9
+
10
+ Style/TrivialAccessors:
11
+ AllowDSLWriters: true
@@ -2,7 +2,15 @@
2
2
  module WeakSwaggerParameters
3
3
  module Definitions
4
4
  class Api
5
- attr_writer :description
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
- child_definitions = doc_definitions
39
- path = @path
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 method, operation_params do
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
- private
53
-
54
- def doc_definitions
62
+ def child_definitions
55
63
  validation_definitions + @response_definitions
56
64
  end
57
65
 
58
- def validation_definitions
59
- [@param_definition]
66
+ def http_method
67
+ KNOWN_METHODS[@method]
60
68
  end
61
69
 
62
- def http_method
63
- known_methods = {
64
- create: :post,
65
- index: :get,
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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module WeakSwaggerParameters
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
@@ -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 = '0.0.1'
9
+ spec.version = ::WeakSwaggerParameters::VERSION
9
10
  spec.authors = ['AgileFreaks']
10
11
  spec.email = ['office@agilefreaks.com']
11
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: weak_swagger_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - AgileFreaks