rails-param-validation 0.4.7 → 0.4.10

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
  SHA256:
3
- metadata.gz: f08d88f808fa165c2d4ffae550d8c4eb6d7a69904ec8f159a29562307a072cf9
4
- data.tar.gz: 5335b9a61723376dd56bc09182506c20536bb94cad4630a0380103e65610017c
3
+ metadata.gz: 6986755ba3d6b9b626b5544560e111b5ec57fb880775d3743f3fd10c82f56141
4
+ data.tar.gz: 93932c2a023ca4a9ee260fcac52472d3d32c299369c1f68a395110d51940d7b6
5
5
  SHA512:
6
- metadata.gz: e44809c8f21e77aa4f988cf1317b7f4c4ec312db72e9d239e70544596bbf51bc28007cbd16cb07dffe537ad3762dae09584ff14294afeebffb5a5919d9ef3f82
7
- data.tar.gz: ad5241ed4bdaeac88b8416fb1bb63725bf4c2d83c31068425976f5ae527d955fc5b71e8993f2125b8441423ebe63e694044c850a0ed750f98a66a53e7bdecc89
6
+ metadata.gz: 900f628d863aab14082ce9948cda48189d60a101729a7709fd97588a1561ff54915e0832f92e6f6614ffe05e3b8cd1272468493da28e8e7371ec9016c161764c
7
+ data.tar.gz: 63d4fde71ceec6d935cbd7553af841de930a57d68caaefdf5d9642515a62e0bc4f7ae9238e0a437cda0b7ef1f4da7f4b72aba0079cb7f95360e197719c33b375
@@ -23,7 +23,7 @@ module RailsParamValidation
23
23
 
24
24
  @param_definition.store_origin! class_name, method_name
25
25
  RailsParamValidation.config.post_action_definition_hook.call(@param_definition)
26
- @param_definition.finalize! class_name, method_name, (@base_paths || {}).fetch(self.name, self.name.underscore)
26
+ @param_definition.finalize! class_name, method_name, (@base_paths || {}).fetch(self.name, self.name.gsub(/Controller$/, "").underscore)
27
27
 
28
28
  AnnotationManager.instance.annotate_method! self, name, :param_definition, @param_definition
29
29
  @param_definition = nil
@@ -67,7 +67,19 @@ module RailsParamValidation
67
67
  end.to_h
68
68
  }
69
69
 
70
- action_definition.merge!(summary: operation.description) if operation.description.present?
70
+ param_documentation = operation
71
+ .params
72
+ .filter { |_, v| v[:description].present? }
73
+ .map { |name, param| "* `#{name}`<br />#{param[:description]}" }
74
+ .join("\n\n")
75
+
76
+ if param_documentation.present?
77
+ param_documentation = "**Parameters**\n#{param_documentation}"
78
+ end
79
+
80
+ if param_documentation.present? || operation.description.present?
81
+ action_definition.merge!(description: "#{operation.description}\n\n#{param_documentation}".strip)
82
+ end
71
83
 
72
84
  if body.any?
73
85
  body_type_name = Types::Namespace.with_namespace(
@@ -43,10 +43,11 @@ class OptionalT < AnnotationT
43
43
  end
44
44
 
45
45
  class CustomT < AnnotationT
46
- attr_reader :type
46
+ attr_reader :type, :from
47
47
 
48
- def initialize(type)
48
+ def initialize(type, from: :name)
49
49
  @type = type
50
+ @from = from
50
51
  end
51
52
 
52
53
  def schema
@@ -62,7 +63,7 @@ class CustomT < AnnotationT
62
63
 
63
64
  def self.registered(type)
64
65
  raise TypeNotFound.new(type) unless registry.key? type
65
- registry[type]
66
+ registry[type].is_a?(Proc) ? registry[type].call : registry[type]
66
67
  end
67
68
 
68
69
  def self.types
@@ -75,6 +76,8 @@ class CustomT < AnnotationT
75
76
  @@types ||= {}
76
77
  end
77
78
  end
79
+
80
+ CustomType = CustomT
78
81
  end
79
82
 
80
83
  module Types
@@ -1,3 +1,3 @@
1
1
  module RailsParamValidation
2
- VERSION = "0.4.7"
2
+ VERSION = "0.4.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-param-validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.7
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oskar Kirmis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-21 00:00:00.000000000 Z
11
+ date: 2022-04-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Declarative parameter definition and validation for Rails
14
14
  email: