rack-json_schema 1.5.2 → 1.5.4

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
- SHA1:
3
- metadata.gz: ea834b3142894728ead0af4795f018e28b76e49e
4
- data.tar.gz: 4ad711b840ae6164ad75b97108b1c429a71fdec4
2
+ SHA256:
3
+ metadata.gz: ce06bbcab6fe693bd6d4f1f03bb2d11b2af03bff953b5b6b7250caadf2e99842
4
+ data.tar.gz: e41e6794ef89f60a6a6c55891d995d6cf96ed0ac5a682dbee22807d6d5123559
5
5
  SHA512:
6
- metadata.gz: 29d10eb928628fd8b5daef027e1a79e10ffd07d1ff80e2c08b35d7d043b2c676809ae61d25b5277a6cb33fba233ccd7d1e26f91471270b908e3906674b7ebb52
7
- data.tar.gz: a18e18e1c587917e875514f6b626e7da6145969e3b8339bd1452658b17c0e1bfc41ca9a40a4dfa9be930d90e4aee04b26a409022cd1f8285bf2b1e0a3da14094
6
+ metadata.gz: c35cc8a1fab3dd7872fdadc7c8488e9c72ad230afb01f705aaae95483cbe4d45063a13085028c4242b7337477de7a84adcf3d18a86ec9365d112dafdab6d6b55
7
+ data.tar.gz: a2f8ed388dc27c368a6caa124d9580969edd36e3724384d93ec2489708de60985380b4f8c073a9c24f368b3b844011d6e65b4c071e1c65c20f67c5ff375137a9
@@ -0,0 +1,23 @@
1
+ changelog:
2
+ categories:
3
+ - title: Added
4
+ labels:
5
+ - add
6
+ - title: Changed
7
+ labels:
8
+ - change
9
+ - title: Deprecated
10
+ labels:
11
+ - deprecate
12
+ - title: Fixed
13
+ labels:
14
+ - fix
15
+ - title: Removed
16
+ labels:
17
+ - remove
18
+ - title: Security
19
+ labels:
20
+ - security
21
+ - title: Others
22
+ labels:
23
+ - "*"
@@ -0,0 +1,26 @@
1
+ name: bump-request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to change to.
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ run:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v3
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: '3.3'
20
+ bundler-cache: true
21
+ - uses: r7kamura/bump-request@v0
22
+ with:
23
+ command: |
24
+ sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/rack/json_schema/version.rb
25
+ bundle install
26
+ version: ${{ inputs.version }}
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ rspec:
11
+ runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.ruby }}
13
+ strategy:
14
+ matrix:
15
+ ruby:
16
+ - '3.3'
17
+ steps:
18
+ - uses: actions/checkout@v3
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+ - name: Run the default task
25
+ run: bundle exec rake
@@ -0,0 +1,18 @@
1
+ name: github-label-sync
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ paths:
8
+ - .github/workflows/github-label-sync.yml
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ build:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: r7kamura/github-label-sync-action@v0
16
+ with:
17
+ source_path: labels-keepachangelog.yml
18
+ source_repository: r7kamura/github-label-presets
@@ -0,0 +1,14 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: softprops/action-gh-release@v1
13
+ with:
14
+ generate_release_notes: true
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
7
6
  InstalledFiles
8
7
  _yardoc
9
8
  coverage
data/Gemfile.lock ADDED
@@ -0,0 +1,95 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rack-json_schema (1.5.4)
5
+ erubis
6
+ jdoc (>= 0.4.4)
7
+ json_schema (~> 0.2)
8
+ rack
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (7.1.2)
14
+ base64
15
+ bigdecimal
16
+ concurrent-ruby (~> 1.0, >= 1.0.2)
17
+ connection_pool (>= 2.2.5)
18
+ drb
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ mutex_m
22
+ tzinfo (~> 2.0)
23
+ amazing_print (1.5.0)
24
+ base64 (0.2.0)
25
+ bigdecimal (3.1.5)
26
+ bond (0.5.1)
27
+ coderay (1.1.3)
28
+ concurrent-ruby (1.2.2)
29
+ connection_pool (2.4.1)
30
+ diff-lcs (1.5.0)
31
+ drb (2.2.0)
32
+ ruby2_keywords
33
+ erubis (2.7.0)
34
+ i18n (1.14.1)
35
+ concurrent-ruby (~> 1.0)
36
+ jdoc (0.4.4)
37
+ activesupport
38
+ erubis
39
+ json_schema
40
+ rack
41
+ redcarpet
42
+ json (2.7.1)
43
+ json_schema (0.21.0)
44
+ method_source (1.0.0)
45
+ minitest (5.21.1)
46
+ mutex_m (0.2.0)
47
+ pry (0.14.2)
48
+ coderay (~> 1.1)
49
+ method_source (~> 1.0)
50
+ rack (3.2.4)
51
+ rack-test (2.1.0)
52
+ rack (>= 1.3)
53
+ rake (13.1.0)
54
+ redcarpet (3.6.0)
55
+ rspec (3.12.0)
56
+ rspec-core (~> 3.12.0)
57
+ rspec-expectations (~> 3.12.0)
58
+ rspec-mocks (~> 3.12.0)
59
+ rspec-console (0.6.1)
60
+ bond
61
+ rspec-core (3.12.2)
62
+ rspec-support (~> 3.12.0)
63
+ rspec-expectations (3.12.3)
64
+ diff-lcs (>= 1.2.0, < 2.0)
65
+ rspec-support (~> 3.12.0)
66
+ rspec-json_matcher (0.2.0)
67
+ amazing_print
68
+ json
69
+ rspec-mocks (3.12.6)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.12.0)
72
+ rspec-support (3.12.1)
73
+ ruby2_keywords (0.0.5)
74
+ shotgun (0.9.2)
75
+ rack (>= 1.0)
76
+ tzinfo (2.0.6)
77
+ concurrent-ruby (~> 1.0)
78
+
79
+ PLATFORMS
80
+ ruby
81
+ x86_64-linux
82
+
83
+ DEPENDENCIES
84
+ bundler (>= 1.5)
85
+ pry
86
+ rack-json_schema!
87
+ rack-test
88
+ rake
89
+ rspec (>= 2.14.1)
90
+ rspec-console
91
+ rspec-json_matcher
92
+ shotgun
93
+
94
+ BUNDLED WITH
95
+ 2.5.3
data/README.md CHANGED
@@ -1,4 +1,7 @@
1
- # Rack::JsonSchema [![Build Status](https://travis-ci.org/r7kamura/rack-json_schema.svg?branch=master)](https://travis-ci.org/r7kamura/rack-json_schema)
1
+ # Rack::JsonSchema
2
+
3
+ [![CI](https://github.com/r7kamura/rack-json_schema/actions/workflows/ci.yml/badge.svg)](https://github.com/r7kamura/rack-json_schema/actions/workflows/ci.yml)
4
+
2
5
  [JSON Schema](http://json-schema.org/) based Rack middlewares.
3
6
 
4
7
  * [Rack::JsonSchema::RequestValidation](#rackjsonschemarequestvalidation)
@@ -57,10 +60,10 @@ $ curl http://localhost:8080/apps -H "Content-Type: application/json" -d '{"name
57
60
  ```
58
61
 
59
62
  ### Rack::JsonSchema::ResponseValidation
60
- Validates request and raises errors below.
63
+ Validates response and raises errors below.
61
64
 
62
- * Rack::JsonSchema::RequestValidation::InvalidResponseContentType
63
- * Rack::JsonSchema::RequestValidation::InvalidResponseType
65
+ * Rack::JsonSchema::ResponseValidation::InvalidResponseContentType
66
+ * Rack::JsonSchema::ResponseValidation::InvalidResponseType
64
67
 
65
68
  ```sh
66
69
  $ curl http://localhost:8080/apps
@@ -3,8 +3,8 @@ module Rack
3
3
  # Base class for providing some utility methods to handle Rack env and JSON Schema
4
4
  class BaseRequestHandler
5
5
  # Utility wrapper method
6
- def self.call(**args)
7
- new(**args).call
6
+ def self.call(*args, **kwargs)
7
+ new(*args, **kwargs).call
8
8
  end
9
9
 
10
10
  # @param env [Hash] Rack env
@@ -34,8 +34,8 @@ module Rack
34
34
  end
35
35
 
36
36
  class DocumentGenerator
37
- def self.call(*args)
38
- new(*args).call
37
+ def self.call(*args, **kwargs)
38
+ new(*args, **kwargs).call
39
39
  end
40
40
 
41
41
  # @param app [Object] Rack application
@@ -138,13 +138,15 @@ module Rack
138
138
 
139
139
  # @return [String] request body
140
140
  def body
141
- if instance_variable_defined?(:@body)
142
- @body
143
- else
141
+ return @body if instance_variable_defined?(:@body)
142
+
143
+ if request.body
144
144
  @body = request.body.read
145
145
  request.body.rewind
146
- @body
146
+ else
147
+ @body = ''
147
148
  end
149
+ @body
148
150
  end
149
151
 
150
152
  # @return [Hash] Request parameters decoded from JSON
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module JsonSchema
3
- VERSION = "1.5.2"
3
+ VERSION = "1.5.4"
4
4
  end
5
5
  end
@@ -18,14 +18,14 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "erubis"
21
- spec.add_dependency "jdoc", ">= 0.1.4"
21
+ spec.add_dependency "jdoc", ">= 0.4.4"
22
22
  spec.add_dependency "json_schema", "~> 0.2"
23
23
  spec.add_dependency "rack"
24
- spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "bundler", ">= 1.5"
25
25
  spec.add_development_dependency "pry"
26
26
  spec.add_development_dependency "rack-test"
27
27
  spec.add_development_dependency "rake"
28
- spec.add_development_dependency "rspec", "2.14.1"
28
+ spec.add_development_dependency "rspec", ">= 2.14.1"
29
29
  spec.add_development_dependency "rspec-console"
30
30
  spec.add_development_dependency "rspec-json_matcher"
31
31
  spec.add_development_dependency "shotgun"
@@ -60,7 +60,7 @@ describe Rack::JsonSchema::Docs do
60
60
 
61
61
  it "generates API documentation and returns it to request to GET /docs" do
62
62
  should == 200
63
- response.body.should include("Example API")
63
+ expect(response.body).to include("Example API")
64
64
  end
65
65
  end
66
66
 
@@ -75,7 +75,7 @@ describe Rack::JsonSchema::Docs do
75
75
 
76
76
  it "responds to specified path" do
77
77
  should == 200
78
- response.body.should_not == "dummy"
78
+ expect(response.body).not_to eq("dummy")
79
79
  end
80
80
  end
81
81
 
@@ -86,7 +86,7 @@ describe Rack::JsonSchema::Docs do
86
86
 
87
87
  it "delegates request to inner app" do
88
88
  should == 200
89
- response.body.should == "dummy"
89
+ expect(response.body).to eq("dummy")
90
90
  end
91
91
  end
92
92
 
@@ -97,7 +97,7 @@ describe Rack::JsonSchema::Docs do
97
97
 
98
98
  it "also accepts GET /docs.md" do
99
99
  should == 200
100
- response.body.should_not == "dummy"
100
+ expect(response.body).not_to eq("dummy")
101
101
  end
102
102
  end
103
103
  end
@@ -56,7 +56,7 @@ describe Rack::JsonSchema::Mock do
56
56
 
57
57
  it "returns Array dummy response" do
58
58
  should == 200
59
- response.body.should be_json_as(
59
+ expect(response.body).to be_json_as(
60
60
  [
61
61
  {
62
62
  id: schema["definitions"]["app"]["definitions"]["id"]["example"],
@@ -78,7 +78,7 @@ describe Rack::JsonSchema::Mock do
78
78
 
79
79
  it "returns dummy response" do
80
80
  should == 200
81
- response.body.should be_json_as(
81
+ expect(response.body).to be_json_as(
82
82
  {
83
83
  id: schema["definitions"]["app"]["definitions"]["id"]["example"],
84
84
  name: schema["definitions"]["app"]["definitions"]["name"]["example"],
@@ -116,7 +116,7 @@ describe Rack::JsonSchema::Mock do
116
116
 
117
117
  it "returns example_not_found error" do
118
118
  should == 500
119
- response.body.should be_json_as(
119
+ expect(response.body).to be_json_as(
120
120
  id: "example_not_found",
121
121
  message: "No example found for #/definitions/app/id",
122
122
  )
@@ -60,7 +60,7 @@ describe Rack::JsonSchema::SchemaProvider do
60
60
 
61
61
  it "returns JSON Schema to request to GET /schema" do
62
62
  should == 200
63
- response.body.should include("app")
63
+ expect(response.body).to include("app")
64
64
  end
65
65
  end
66
66
 
@@ -75,7 +75,7 @@ describe Rack::JsonSchema::SchemaProvider do
75
75
 
76
76
  it "responds to specified path" do
77
77
  should == 200
78
- response.body.should_not == "dummy"
78
+ expect(response.body).not_to eq("dummy")
79
79
  end
80
80
  end
81
81
 
@@ -86,7 +86,7 @@ describe Rack::JsonSchema::SchemaProvider do
86
86
 
87
87
  it "delegates request to inner app" do
88
88
  should == 200
89
- response.body.should == "dummy"
89
+ expect(response.body).to eq("dummy")
90
90
  end
91
91
  end
92
92
  end
@@ -114,7 +114,7 @@ describe Rack::JsonSchema do
114
114
 
115
115
  it "returns link_not_found error" do
116
116
  should == 404
117
- response.body.should be_json_as(
117
+ expect(response.body).to be_json_as(
118
118
  id: "link_not_found",
119
119
  message: "Could not find the link definition for request path #{path}.",
120
120
  )
@@ -138,7 +138,7 @@ describe Rack::JsonSchema do
138
138
 
139
139
  it "returns invalid_content_type error" do
140
140
  should == 400
141
- response.body.should be_json_as(
141
+ expect(response.body).to be_json_as(
142
142
  id: "invalid_content_type",
143
143
  message: "Invalid content type",
144
144
  )
@@ -181,7 +181,7 @@ describe Rack::JsonSchema do
181
181
 
182
182
  it "returns invalid_parameter error" do
183
183
  should == 400
184
- response.body.should be_json_as(
184
+ expect(response.body).to be_json_as(
185
185
  id: "invalid_parameter",
186
186
  message: String,
187
187
  )
@@ -216,7 +216,7 @@ describe Rack::JsonSchema do
216
216
 
217
217
  it "returns invalid_parameter error" do
218
218
  should == 400
219
- response.body.should be_json_as(
219
+ expect(response.body).to be_json_as(
220
220
  id: "invalid_json",
221
221
  message: "Request body wasn't valid JSON",
222
222
  )
@@ -255,7 +255,7 @@ describe Rack::JsonSchema do
255
255
  context "when mediaType is not specified" do
256
256
  it "returns invalid_response_content_type error" do
257
257
  should == 500
258
- response.body.should be_json_as(
258
+ expect(response.body).to be_json_as(
259
259
  id: "invalid_response_content_type",
260
260
  message: "Response Content-Type wasn't for JSON",
261
261
  )
@@ -270,7 +270,7 @@ describe Rack::JsonSchema do
270
270
 
271
271
  it "returns invalid_response_type error" do
272
272
  should == 500
273
- response.body.should be_json_as(
273
+ expect(response.body).to be_json_as(
274
274
  id: "invalid_response_type",
275
275
  message: String,
276
276
  )
@@ -284,7 +284,7 @@ describe Rack::JsonSchema do
284
284
 
285
285
  it "returns invalid_response_type error" do
286
286
  should == 500
287
- response.body.should be_json_as(
287
+ expect(response.body).to be_json_as(
288
288
  id: "invalid_response_type",
289
289
  message: String,
290
290
  )
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,6 @@ require "rack/test"
4
4
  require "rspec/json_matcher"
5
5
 
6
6
  RSpec.configure do |config|
7
- config.treat_symbols_as_metadata_keys_with_true_values = true
8
7
  config.run_all_when_everything_filtered = true
9
8
  config.filter_run :focus
10
9
  config.include RSpec::JsonMatcher
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-json_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2015-06-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: erubis
@@ -30,14 +29,14 @@ dependencies:
30
29
  requirements:
31
30
  - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: 0.1.4
32
+ version: 0.4.4
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: 0.1.4
39
+ version: 0.4.4
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: json_schema
43
42
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +69,14 @@ dependencies:
70
69
  name: bundler
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
- - - "~>"
72
+ - - ">="
74
73
  - !ruby/object:Gem::Version
75
74
  version: '1.5'
76
75
  type: :development
77
76
  prerelease: false
78
77
  version_requirements: !ruby/object:Gem::Requirement
79
78
  requirements:
80
- - - "~>"
79
+ - - ">="
81
80
  - !ruby/object:Gem::Version
82
81
  version: '1.5'
83
82
  - !ruby/object:Gem::Dependency
@@ -126,14 +125,14 @@ dependencies:
126
125
  name: rspec
127
126
  requirement: !ruby/object:Gem::Requirement
128
127
  requirements:
129
- - - '='
128
+ - - ">="
130
129
  - !ruby/object:Gem::Version
131
130
  version: 2.14.1
132
131
  type: :development
133
132
  prerelease: false
134
133
  version_requirements: !ruby/object:Gem::Requirement
135
134
  requirements:
136
- - - '='
135
+ - - ">="
137
136
  - !ruby/object:Gem::Version
138
137
  version: 2.14.1
139
138
  - !ruby/object:Gem::Dependency
@@ -178,7 +177,6 @@ dependencies:
178
177
  - - ">="
179
178
  - !ruby/object:Gem::Version
180
179
  version: '0'
181
- description:
182
180
  email:
183
181
  - r7kamura@gmail.com
184
182
  executables:
@@ -186,10 +184,15 @@ executables:
186
184
  extensions: []
187
185
  extra_rdoc_files: []
188
186
  files:
187
+ - ".github/release.yml"
188
+ - ".github/workflows/bump-request.yml"
189
+ - ".github/workflows/ci.yml"
190
+ - ".github/workflows/github-label-sync.yml"
191
+ - ".github/workflows/release.yml"
189
192
  - ".gitignore"
190
- - ".travis.yml"
191
193
  - CHANGELOG.md
192
194
  - Gemfile
195
+ - Gemfile.lock
193
196
  - LICENSE.txt
194
197
  - README.md
195
198
  - Rakefile
@@ -218,7 +221,6 @@ homepage: https://github.com/r7kamura/rack-json_schema
218
221
  licenses:
219
222
  - MIT
220
223
  metadata: {}
221
- post_install_message:
222
224
  rdoc_options: []
223
225
  require_paths:
224
226
  - lib
@@ -233,9 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
233
235
  - !ruby/object:Gem::Version
234
236
  version: '0'
235
237
  requirements: []
236
- rubyforge_project:
237
- rubygems_version: 2.4.5
238
- signing_key:
238
+ rubygems_version: 3.6.9
239
239
  specification_version: 4
240
240
  summary: JSON Schema based Rack middlewares
241
241
  test_files:
@@ -245,4 +245,3 @@ test_files:
245
245
  - spec/rack/spec/schema_provider_spec.rb
246
246
  - spec/rack/spec_spec.rb
247
247
  - spec/spec_helper.rb
248
- has_rdoc:
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0