rails-param-validation 0.3.1 → 0.3.2

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: 379a0af49ad44233f32c49a193e2eabae05b111330d93316c87d83968ea0693e
4
- data.tar.gz: a0db01c2e6c16a1f0b1ed940d7c54d3c347fb46532119bc737dab460889a3b84
3
+ metadata.gz: c91d17285ccb7056d82f4765816c11097127528e459cc76ed720fe81e14ed9b6
4
+ data.tar.gz: 680f1b12419968f6528a48552a9d0c9327cdae7c7a0072d2ed43189b91784854
5
5
  SHA512:
6
- metadata.gz: 7d5b1a95b756da8407b90d8cc8acff4910aa3d3f81af2bdbd740b04fdc8defb38737eb09e60ed2c1a430c8b27b70db6dcad3c85d579b16809a7cb1230d1b08a6
7
- data.tar.gz: 8f66b039139bf738674123a44168083fc94a6d00c2eee3255d2853e27746f98403a622ca9302accc92fd7f199f181a78e35e2d0d6392102e23ba45650f9d2b10
6
+ metadata.gz: cda64c3b3a95f3ecbc96381f9e5b2e4681b0c6d2b3dde14e6d3e2037e8c65d1b9dd70663aae52739271914086327e0ce913e685e346af883135b37d33762e9dd
7
+ data.tar.gz: b39531488e543569efa588e35c8f3fc887e14e2891f0243817f2fb4476470315d609854b90d032f895205c626a6546cbaab686876dea7a517a947f5e1ed40171
@@ -65,7 +65,7 @@ module RailsParamValidation
65
65
 
66
66
  def finalize!(class_name, method_name)
67
67
  @responses.each do |code, response|
68
- name = "#{class_name.to_s.capitalize}#{method_name.to_s.camelcase}#{Rack::Utils::SYMBOL_TO_STATUS_CODE.key(code).to_s.camelize}Response".to_sym
68
+ name = "#{RailsHelper.clean_controller_name(class_name)}#{method_name.to_s.camelcase}#{Rack::Utils::SYMBOL_TO_STATUS_CODE.key(code).to_s.camelize}Response".to_sym
69
69
  AnnotationTypes::CustomT.register(name, response[:schema])
70
70
 
71
71
  response.merge!(schema: AnnotationTypes::CustomT.new(name))
@@ -4,6 +4,11 @@ module RailsParamValidation
4
4
  def self.controller_to_tag(klass)
5
5
  (klass.is_a?(String) ? klass : klass.name).gsub(/Controller$/, '').to_sym
6
6
  end
7
+
8
+ def self.clean_controller_name(klass)
9
+ klass = klass.to_s if klass.is_a? Symbol
10
+ (klass.is_a?(String) ? klass : klass.name).gsub(/Controller$/, '').split('::').map { |p| p.capitalize }.join.to_sym
11
+ end
7
12
  end
8
13
 
9
- end
14
+ end
@@ -25,7 +25,7 @@ module RailsParamValidation
25
25
  openapi: OPENAPI_VERSION,
26
26
  info: { version: @info[:version], title: @info[:title], description: @info[:description] },
27
27
  servers: @info[:url].map { |url| { url: url } },
28
- tags: @tags.map { |tag, description| { name: tag, description: description } },
28
+ tags: @tags.map { |tag, description| { name: RailsHelper.clean_controller_name(tag), description: description } },
29
29
  paths: {},
30
30
  components: { schemas: {} }
31
31
  }
@@ -49,7 +49,7 @@ module RailsParamValidation
49
49
  RoutingHelper.routes_for(operation.controller.to_s.underscore, operation.action.to_s).each do |route|
50
50
  action_definition = {
51
51
  operationId: "#{route[:method].downcase}#{route[:path].split(/[^a-zA-Z0-9]+/).map(&:downcase).map(&:capitalize).join}",
52
- tags: [operation.controller],
52
+ tags: [RailsHelper.clean_controller_name(operation.controller)],
53
53
  parameters: parameters,
54
54
  security: operation.security,
55
55
  responses: operation.responses.map do |status, values|
@@ -70,7 +70,7 @@ module RailsParamValidation
70
70
  action_definition.merge!(summary: operation.description) if operation.description.present?
71
71
 
72
72
  if body.any?
73
- body_type_name = "#{operation.controller.capitalize}#{operation.action.capitalize}Body".to_sym
73
+ body_type_name = "#{RailsHelper.clean_controller_name operation.controller}#{operation.action.capitalize}Body".to_sym
74
74
  AnnotationTypes::CustomT.register(body_type_name, body)
75
75
 
76
76
  action_definition[:requestBody] = {
@@ -104,7 +104,7 @@ module RailsParamValidation
104
104
  description = AnnotationManager.instance.class_annotation klass, :description
105
105
 
106
106
  if description
107
- @tags[RailsHelper.controller_to_tag klass] = description
107
+ @tags[RailsHelper.controller_to_tag klass.constantize] = description
108
108
  end
109
109
 
110
110
  AnnotationManager.instance.methods(klass).each do |method|
@@ -1,3 +1,3 @@
1
1
  module RailsParamValidation
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-param-validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oskar Kirmis