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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c91d17285ccb7056d82f4765816c11097127528e459cc76ed720fe81e14ed9b6
|
4
|
+
data.tar.gz: 680f1b12419968f6528a48552a9d0c9327cdae7c7a0072d2ed43189b91784854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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|
|