openapi_parameters 0.3.2 → 0.3.3

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: ce377792c0096d9aba455f83d129162c636f6cab951e43221de7dfbfb9e67227
4
- data.tar.gz: e8f320696d3af924bd25496c6f98e19222af638365bfd39d5199b0da27104002
3
+ metadata.gz: e010a357f13e7452f8945d95e7c277fc35c87d1cc713e41dccae68a20d37db03
4
+ data.tar.gz: 763b4eed6e0e11c4f0ff839afa366cadc6569c371a4ccd5490a7b3368f8849fc
5
5
  SHA512:
6
- metadata.gz: 67bf514be29731af8936dbab3ec1dfcb61b1091332487f4602c56bab7a708dd9637925b8e58c819d9d39d75e4bf861800dfaf407608837f846f2ed3b09f6cf2d
7
- data.tar.gz: cf4f96c5a4e0f4c0b025eaa116dd3e38d040f6e1ef2be0cde8b3a2b1f871d5b027454ed1d57ca69ccb3310ae84162488c4111797985cf9ec3a0b321c2f30d717
6
+ metadata.gz: 49a1e95d33f513346408826aa1954d9a8c58b7a656d23b1643f8f5664e3747ab04589586d8c6ffcd9392022ff85ad2f4722dd9e541f569399ff8a7bd2226ecb6
7
+ data.tar.gz: 6bc8eadb1948050b12ab6561c8e412ab124d0bfd64d94414506f71d5c1549d963c2d765ce0e9ebea1908c258ef30d17b7f8c4db3bd9c81643897c0bac86ad487
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.3] - 2023-04-13
4
+
5
+ - Remove zeitwerk. It's awesome, but not needed here
6
+
3
7
  ## [0.3.2] - 2023-11-14
4
8
 
5
9
  - Assume that schemas with `properties` or `style: deepObject` describe Objects and therefore convert it's values.
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiParameters
4
- ##
5
4
  # Tries to convert a request parameter value (string) to the type specified in the JSON Schema.
6
5
  module Converter
7
6
  class << self
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rack'
4
-
5
3
  module OpenapiParameters
6
4
  # Cookie parses OpenAPI cookie parameters from a cookie string.
7
5
  class Cookie
@@ -6,17 +6,18 @@ module OpenapiParameters
6
6
  class Parameter
7
7
  # @param definition [Hash] The parameter definition. A string keyed Hash.
8
8
  def initialize(definition)
9
- check_supported!(definition)
10
9
  @definition = definition
10
+ @name = definition['name']
11
+ @is_deep_object = style == 'deepObject'
12
+ check_supported!
11
13
  end
12
14
 
13
- attr_reader :definition
15
+ attr_reader :definition, :name
14
16
 
15
- def name
16
- definition['name']
17
+ def deep_object?
18
+ @is_deep_object
17
19
  end
18
20
 
19
- ##
20
21
  # @return [String] The location of the parameter in the request, "path", "query", "header" or "cookie".
21
22
  def location
22
23
  definition['in']
@@ -90,8 +91,8 @@ module OpenapiParameters
90
91
  REF = '$ref'
91
92
  private_constant :REF
92
93
 
93
- def check_supported!(definition)
94
- return unless definition.values.any? { |v| v.is_a?(Hash) && v.key?(REF) }
94
+ def check_supported!
95
+ return unless schema&.key?(REF)
95
96
 
96
97
  raise NotSupportedError,
97
98
  "Parameter schema with $ref is not supported: #{definition.inspect}"
@@ -16,7 +16,7 @@ module OpenapiParameters
16
16
  parsed_query = Rack::Utils.parse_query(query_string)
17
17
  parameters.each_with_object({}) do |parameter, result|
18
18
  parameter = Parameter.new(parameter)
19
- if parameter.style == 'deepObject'
19
+ if parameter.deep_object?
20
20
  parsed_nested_query = Rack::Utils.parse_nested_query(query_string)
21
21
  next unless parsed_nested_query.key?(parameter.name)
22
22
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiParameters
4
- ## Unpacks a paramexter value from a string as defined in the OpenAPI specification.
4
+ # Unpacks a parameter value from a string as defined in the OpenAPI specification.
5
5
  # @visibility private
6
6
  module Unpacker
7
7
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OpenapiParameters
4
- VERSION = '0.3.2'
4
+ VERSION = '0.3.3'
5
5
  end
@@ -1,9 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'zeitwerk'
3
+ require 'rack'
4
+ require_relative 'openapi_parameters/converter'
5
+ require_relative 'openapi_parameters/cookie'
6
+ require_relative 'openapi_parameters/error'
7
+ require_relative 'openapi_parameters/header'
8
+ require_relative 'openapi_parameters/headers_hash'
9
+ require_relative 'openapi_parameters/not_supported_error'
10
+ require_relative 'openapi_parameters/parameter'
11
+ require_relative 'openapi_parameters/path'
12
+ require_relative 'openapi_parameters/query'
13
+ require_relative 'openapi_parameters/unpacker'
4
14
 
5
15
  # OpenapiParameters is a gem that parses OpenAPI parameters from Rack
6
16
  module OpenapiParameters
7
- LOADER = Zeitwerk::Loader.for_gem
8
- LOADER.setup
9
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openapi_parameters
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Haller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-14 00:00:00.000000000 Z
11
+ date: 2024-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '2.2'
27
- - !ruby/object:Gem::Dependency
28
- name: zeitwerk
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.6'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.6'
41
27
  description: This parses HTTP query/path/header/cookie parameters exactly as described
42
28
  in an OpenAPI API description.
43
29
  email:
@@ -46,15 +32,8 @@ executables: []
46
32
  extensions: []
47
33
  extra_rdoc_files: []
48
34
  files:
49
- - ".rspec"
50
- - ".rubocop.yml"
51
- - ".tool-versions"
52
35
  - CHANGELOG.md
53
- - Gemfile
54
- - Gemfile.lock
55
- - LICENSE
56
36
  - README.md
57
- - Rakefile
58
37
  - lib/openapi_parameters.rb
59
38
  - lib/openapi_parameters/converter.rb
60
39
  - lib/openapi_parameters/cookie.rb
@@ -67,8 +46,6 @@ files:
67
46
  - lib/openapi_parameters/query.rb
68
47
  - lib/openapi_parameters/unpacker.rb
69
48
  - lib/openapi_parameters/version.rb
70
- - openapi_parameters.gemspec
71
- - sig/openapi_parameters.rbs
72
49
  homepage: https://github.com/ahx/openapi_parameters
73
50
  licenses:
74
51
  - MIT
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,19 +0,0 @@
1
- require:
2
- - rubocop-rspec
3
-
4
- Naming/MethodParameterName:
5
- Enabled: false
6
-
7
- AllCops:
8
- NewCops: enable
9
- SuggestExtensions: false
10
- TargetRubyVersion: 3.1
11
-
12
- RSpec/ExampleLength:
13
- Enabled: false
14
-
15
- RSpec/NestedGroups:
16
- Max: 4
17
-
18
- Metrics/MethodLength:
19
- Max: 20
data/.tool-versions DELETED
@@ -1 +0,0 @@
1
- ruby 3.2.1
data/Gemfile DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in OpenapiParameters.gemspec
6
- gemspec
7
-
8
- gem 'rack-test'
9
- gem 'rake', '~> 13.0'
10
- gem 'rspec', '~> 3.0'
11
- gem 'rspec-benchmark'
12
- gem 'rubocop'
13
- gem 'rubocop-rspec'
data/Gemfile.lock DELETED
@@ -1,89 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- openapi_parameters (0.3.2)
5
- rack (>= 2.2)
6
- zeitwerk (~> 2.6)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- ast (2.4.2)
12
- benchmark-malloc (0.2.0)
13
- benchmark-perf (0.6.0)
14
- benchmark-trend (0.4.0)
15
- diff-lcs (1.5.0)
16
- json (2.6.3)
17
- language_server-protocol (3.17.0.3)
18
- parallel (1.23.0)
19
- parser (3.2.2.4)
20
- ast (~> 2.4.1)
21
- racc
22
- racc (1.7.3)
23
- rack (3.0.8)
24
- rack-test (2.1.0)
25
- rack (>= 1.3)
26
- rainbow (3.1.1)
27
- rake (13.1.0)
28
- regexp_parser (2.8.2)
29
- rexml (3.2.6)
30
- rspec (3.12.0)
31
- rspec-core (~> 3.12.0)
32
- rspec-expectations (~> 3.12.0)
33
- rspec-mocks (~> 3.12.0)
34
- rspec-benchmark (0.6.0)
35
- benchmark-malloc (~> 0.2)
36
- benchmark-perf (~> 0.6)
37
- benchmark-trend (~> 0.4)
38
- rspec (>= 3.0)
39
- rspec-core (3.12.2)
40
- rspec-support (~> 3.12.0)
41
- rspec-expectations (3.12.3)
42
- diff-lcs (>= 1.2.0, < 2.0)
43
- rspec-support (~> 3.12.0)
44
- rspec-mocks (3.12.6)
45
- diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.12.0)
47
- rspec-support (3.12.1)
48
- rubocop (1.57.2)
49
- json (~> 2.3)
50
- language_server-protocol (>= 3.17.0)
51
- parallel (~> 1.10)
52
- parser (>= 3.2.2.4)
53
- rainbow (>= 2.2.2, < 4.0)
54
- regexp_parser (>= 1.8, < 3.0)
55
- rexml (>= 3.2.5, < 4.0)
56
- rubocop-ast (>= 1.28.1, < 2.0)
57
- ruby-progressbar (~> 1.7)
58
- unicode-display_width (>= 2.4.0, < 3.0)
59
- rubocop-ast (1.30.0)
60
- parser (>= 3.2.1.0)
61
- rubocop-capybara (2.19.0)
62
- rubocop (~> 1.41)
63
- rubocop-factory_bot (2.24.0)
64
- rubocop (~> 1.33)
65
- rubocop-rspec (2.25.0)
66
- rubocop (~> 1.40)
67
- rubocop-capybara (~> 2.17)
68
- rubocop-factory_bot (~> 2.22)
69
- ruby-progressbar (1.13.0)
70
- unicode-display_width (2.5.0)
71
- zeitwerk (2.6.12)
72
-
73
- PLATFORMS
74
- arm64-darwin-21
75
- arm64-darwin-22
76
- x86_64-darwin-20
77
- x86_64-linux
78
-
79
- DEPENDENCIES
80
- openapi_parameters!
81
- rack-test
82
- rake (~> 13.0)
83
- rspec (~> 3.0)
84
- rspec-benchmark
85
- rubocop
86
- rubocop-rspec
87
-
88
- BUNDLED WITH
89
- 2.3.10
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 Andreas Haller
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
-
7
- RSpec::Core::RakeTask.new(:spec)
8
- RuboCop::RakeTask.new
9
-
10
- task default: %i[spec rubocop]
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'lib/openapi_parameters/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'openapi_parameters'
7
- spec.version = OpenapiParameters::VERSION
8
- spec.authors = ['Andreas Haller']
9
- spec.email = ['andreas.haller@posteo.de']
10
-
11
- spec.summary = 'openapi_parameters is an OpenAPI aware parameter parser'
12
- spec.description =
13
- 'This parses HTTP query/path/header/cookie parameters exactly as described in an OpenAPI API description.'
14
- spec.homepage = 'https://github.com/ahx/openapi_parameters'
15
- spec.required_ruby_version = '>= 3.1.0'
16
- spec.licenses = ['MIT']
17
-
18
- spec.metadata['homepage_uri'] = spec.homepage
19
- spec.metadata['source_code_uri'] = 'https://github.com/ahx/openapi_parameters'
20
- spec.metadata[
21
- 'changelog_uri'
22
- ] = 'https://github.com/ahx/openapi_parameters/blob/main/CHANGELOG.md'
23
-
24
- # Specify which files should be added to the gem when it is released.
25
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
- spec.files =
27
- Dir.chdir(__dir__) do
28
- `git ls-files -z`.split("\x0")
29
- .reject do |f|
30
- (f == __FILE__) ||
31
- f.match(
32
- %r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}
33
- )
34
- end
35
- end
36
- spec.bindir = 'exe'
37
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
38
- spec.require_paths = ['lib']
39
-
40
- spec.add_dependency 'rack', '>= 2.2'
41
- spec.add_dependency 'zeitwerk', '~> 2.6'
42
-
43
- # For more information and examples about making a new gem, check out our
44
- # guide at: https://bundler.io/guides/creating_gem.html
45
- spec.metadata['rubygems_mfa_required'] = 'true'
46
- end
@@ -1,4 +0,0 @@
1
- module OpenapiParameters
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end