rails-param-validation 0.4.4 → 0.4.5
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 +4 -4
- data/.gitignore +0 -0
- data/.gitlab-ci.yml +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/.keep +0 -0
- data/docs/_config.yml +0 -0
- data/docs/annotations.md +0 -0
- data/docs/getting-started.md +0 -0
- data/docs/image/error-screenshot.png +0 -0
- data/docs/index.md +0 -0
- data/docs/main-idea.md +0 -0
- data/docs/openapi.md +0 -0
- data/docs/type-definition.md +0 -0
- data/lib/rails-param-validation/errors/missing_parameter_annotation.rb +0 -0
- data/lib/rails-param-validation/errors/no_matching_factory.rb +0 -0
- data/lib/rails-param-validation/errors/param_validation_failed_error.rb +0 -0
- data/lib/rails-param-validation/errors/type_not_found.rb +0 -0
- data/lib/rails-param-validation/rails/action_definition.rb +5 -1
- data/lib/rails-param-validation/rails/annotation_manager.rb +0 -0
- data/lib/rails-param-validation/rails/config.rb +0 -0
- data/lib/rails-param-validation/rails/extensions/annotation_extension.rb +19 -1
- data/lib/rails-param-validation/rails/extensions/custom_type_extension.rb +0 -0
- data/lib/rails-param-validation/rails/extensions/error.template.html.erb +0 -0
- data/lib/rails-param-validation/rails/extensions/validation_extension.rb +0 -0
- data/lib/rails-param-validation/rails/helper.rb +6 -1
- data/lib/rails-param-validation/rails/openapi/openapi.rb +1 -1
- data/lib/rails-param-validation/rails/openapi/routing_helper.rb +0 -0
- data/lib/rails-param-validation/rails/rails.rb +0 -0
- data/lib/rails-param-validation/rails/tasks/openapi.rake +2 -2
- data/lib/rails-param-validation/types/types.rb +7 -1
- data/lib/rails-param-validation/validator.rb +0 -0
- data/lib/rails-param-validation/validator_factory.rb +0 -0
- data/lib/rails-param-validation/validators/alternatives.rb +0 -0
- data/lib/rails-param-validation/validators/array.rb +0 -0
- data/lib/rails-param-validation/validators/boolean.rb +0 -0
- data/lib/rails-param-validation/validators/constant.rb +0 -0
- data/lib/rails-param-validation/validators/custom_type.rb +0 -0
- data/lib/rails-param-validation/validators/date.rb +0 -0
- data/lib/rails-param-validation/validators/datetime.rb +0 -0
- data/lib/rails-param-validation/validators/float.rb +0 -0
- data/lib/rails-param-validation/validators/hash.rb +0 -0
- data/lib/rails-param-validation/validators/integer.rb +0 -0
- data/lib/rails-param-validation/validators/object.rb +0 -0
- data/lib/rails-param-validation/validators/optional.rb +0 -0
- data/lib/rails-param-validation/validators/regex.rb +0 -0
- data/lib/rails-param-validation/validators/string.rb +0 -0
- data/lib/rails-param-validation/validators/uuid.rb +0 -0
- data/lib/rails-param-validation/version.rb +1 -1
- data/lib/rails-param-validation.rb +0 -0
- data/rails-param-validation.gemspec +0 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cac5e8e1680a9f3cbdce7cd511d39f4b95d0cddf9f2955e9bbbde3ff56daa5b
|
4
|
+
data.tar.gz: a2f4422840a284a0658fa9c241bcda19edbcf7ad3927bc94a79ec38178b86e5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f1a29d5ed1039772184372c44073af3104cf4acc7d8f9299c561891dcb71f877ef937617fe91776919fd32021e7bc67e69a53f3e78c27e098520376d1ea2466
|
7
|
+
data.tar.gz: e49a9586e8446164a580e4143f8af1dfaa2f04228d102e6ce00b1fb21bc9ddac36c8885b92df5064768439a136bf74d9ff8f1674787f4bf70b605f64ecd6ff6e
|
data/.gitignore
CHANGED
File without changes
|
data/.gitlab-ci.yml
CHANGED
File without changes
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
File without changes
|
data/Rakefile
CHANGED
File without changes
|
data/bin/.keep
CHANGED
File without changes
|
data/docs/_config.yml
CHANGED
File without changes
|
data/docs/annotations.md
CHANGED
File without changes
|
data/docs/getting-started.md
CHANGED
File without changes
|
File without changes
|
data/docs/index.md
CHANGED
File without changes
|
data/docs/main-idea.md
CHANGED
File without changes
|
data/docs/openapi.md
CHANGED
File without changes
|
data/docs/type-definition.md
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -64,7 +64,11 @@ module RailsParamValidation
|
|
64
64
|
@paths.push(method: method, path: path)
|
65
65
|
end
|
66
66
|
|
67
|
-
def finalize!(class_name, method_name)
|
67
|
+
def finalize!(class_name, method_name, base_path)
|
68
|
+
@paths.each do |path|
|
69
|
+
path[:path] = ("/#{base_path}/#{path[:path]}").gsub(/\/+$/, "").gsub(/\/{2,}/, '/')
|
70
|
+
end
|
71
|
+
|
68
72
|
@responses.each do |code, response|
|
69
73
|
name = Types::Namespace.with_namespace(
|
70
74
|
Types::Namespace.fetch(@source_file),
|
File without changes
|
File without changes
|
@@ -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
|
26
|
+
@param_definition.finalize! class_name, method_name, (@base_paths || {}).fetch(self.name, self.name.underscore)
|
27
27
|
|
28
28
|
AnnotationManager.instance.annotate_method! self, name, :param_definition, @param_definition
|
29
29
|
@param_definition = nil
|
@@ -38,6 +38,11 @@ module RailsParamValidation
|
|
38
38
|
end
|
39
39
|
|
40
40
|
module ClassMethods
|
41
|
+
def base_path(path)
|
42
|
+
@base_paths ||= {}
|
43
|
+
@base_paths[self.name] = path
|
44
|
+
end
|
45
|
+
|
41
46
|
def param_definition
|
42
47
|
@param_definition || raise(StandardError.new "Annotation must be part of an operation-block")
|
43
48
|
end
|
@@ -94,10 +99,23 @@ module RailsParamValidation
|
|
94
99
|
end
|
95
100
|
|
96
101
|
def action(description = nil, flags = RailsParamValidation.config.default_action_flags)
|
102
|
+
if description.is_a?(Hash)
|
103
|
+
method = description.keys.first.to_sym
|
104
|
+
path = description.values.first
|
105
|
+
description = ""
|
106
|
+
else
|
107
|
+
method = nil
|
108
|
+
path = nil
|
109
|
+
end
|
110
|
+
|
97
111
|
@param_definition = ActionDefinition.new(Types::Namespace.caller_file)
|
98
112
|
@param_definition.description = description
|
99
113
|
flags.each { |name, value| @param_definition.add_flag name, value }
|
100
114
|
|
115
|
+
if method
|
116
|
+
@param_definition.add_path method, path
|
117
|
+
end
|
118
|
+
|
101
119
|
yield
|
102
120
|
end
|
103
121
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -7,7 +7,12 @@ module RailsParamValidation
|
|
7
7
|
|
8
8
|
def self.clean_controller_name(klass)
|
9
9
|
klass = klass.to_s if klass.is_a? Symbol
|
10
|
-
(klass.is_a?(String) ? klass : klass.name).gsub(/Controller$/, '').split(
|
10
|
+
(klass.is_a?(String) ? klass : klass.name).gsub(/Controller$/, '').split("::").join(".").to_sym
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.clean_name(klass)
|
14
|
+
klass = klass.to_s if klass.is_a? Symbol
|
15
|
+
(klass.is_a?(String) ? klass : klass.name).split("::").join(".").to_sym
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
@@ -46,7 +46,7 @@ module RailsParamValidation
|
|
46
46
|
param_definition
|
47
47
|
end
|
48
48
|
|
49
|
-
RoutingHelper.routes_for(operation.controller.to_s.underscore, operation.action.to_s).each do |route|
|
49
|
+
(operation.paths.any? ? operation.paths : 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
52
|
tags: [RailsHelper.clean_controller_name(operation.controller)],
|
File without changes
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :openapi do
|
2
2
|
|
3
|
-
desc "Export OpenAPI definition to openapi.
|
3
|
+
desc "Export OpenAPI definition to openapi.json"
|
4
4
|
task export: :environment do
|
5
5
|
# Ensure all controllers are loaded
|
6
6
|
if defined? Zeitwerk
|
@@ -22,7 +22,7 @@ namespace :openapi do
|
|
22
22
|
print "Writing #{filename}..."
|
23
23
|
|
24
24
|
begin
|
25
|
-
File.open(filename, "w") { |f| f.write
|
25
|
+
File.open(filename, "w") { |f| f.write JSON.pretty_generate(openapi.to_object) }
|
26
26
|
puts " done."
|
27
27
|
rescue Exception => e
|
28
28
|
puts " failed."
|
@@ -89,6 +89,8 @@ module Types
|
|
89
89
|
|
90
90
|
path.pop
|
91
91
|
end
|
92
|
+
|
93
|
+
nil
|
92
94
|
end
|
93
95
|
|
94
96
|
def self.caller_file
|
@@ -140,7 +142,11 @@ module Types
|
|
140
142
|
end
|
141
143
|
|
142
144
|
def Type(type)
|
143
|
-
|
145
|
+
if type.is_a?(Class)
|
146
|
+
AnnotationTypes::CustomT.new(RailsHelper.clean_name(type))
|
147
|
+
else
|
148
|
+
AnnotationTypes::CustomT.new(Namespace.with_namespace(Namespace.fetch(Namespace.caller_file), type))
|
149
|
+
end
|
144
150
|
end
|
145
151
|
end
|
146
152
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.
|
4
|
+
version: 0.4.5
|
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-
|
11
|
+
date: 2022-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Declarative parameter definition and validation for Rails
|
14
14
|
email:
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
|
-
rubygems_version: 3.3.
|
96
|
+
rubygems_version: 3.3.11
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: Declarative parameter definition and validation for Rails
|