Skip to content

Commit 979dc33

Browse files
committed
Cleanup
1 parent 41a64bd commit 979dc33

File tree

6 files changed

+15
-25
lines changed

6 files changed

+15
-25
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030

3131
# Ignore master key for decrypting credentials and more.
3232
/config/master.key
33-
.byebug_history
33+
.byebug_history

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ gem "thruster", require: false
3535
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible
3636
# gem "rack-cors"
3737
gem "committee"
38-
gem "openapi_first"
3938
gem "scalar_ruby", "~> 1.1"
4039

4140
group :development, :test do

Gemfile.lock

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ GEM
106106
raabro (~> 1.4)
107107
globalid (1.2.1)
108108
activesupport (>= 6.1)
109-
hana (1.3.7)
110109
i18n (1.14.7)
111110
concurrent-ruby (~> 1.0)
112111
io-console (0.8.0)
@@ -116,11 +115,6 @@ GEM
116115
reline (>= 0.4.2)
117116
json (2.10.2)
118117
json_schema (0.21.0)
119-
json_schemer (2.4.0)
120-
bigdecimal
121-
hana (~> 1.3)
122-
regexp_parser (~> 2.0)
123-
simpleidn (~> 0.2)
124118
kamal (2.5.3)
125119
activesupport (>= 7.0)
126120
base64 (~> 0.2)
@@ -168,13 +162,6 @@ GEM
168162
racc (~> 1.4)
169163
nokogiri (1.18.3-x86_64-linux-gnu)
170164
racc (~> 1.4)
171-
openapi_first (2.4.0)
172-
hana (~> 1.3)
173-
json_schemer (>= 2.1, < 3.0)
174-
openapi_parameters (>= 0.3.3, < 2.0)
175-
rack (>= 2.2, < 4.0)
176-
openapi_parameters (0.4.0)
177-
rack (>= 2.2)
178165
openapi_parser (2.2.4)
179166
ostruct (0.6.1)
180167
parallel (1.26.3)
@@ -265,7 +252,6 @@ GEM
265252
ruby-progressbar (1.13.0)
266253
scalar_ruby (1.1.0)
267254
securerandom (0.4.1)
268-
simpleidn (0.2.3)
269255
solid_cable (3.0.7)
270256
actioncable (>= 7.2)
271257
activejob (>= 7.2)
@@ -323,7 +309,6 @@ DEPENDENCIES
323309
committee
324310
debug
325311
kamal
326-
openapi_first
327312
puma (>= 5.0)
328313
rails (~> 8.0.2)
329314
rubocop-rails-omakase

docs/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"schema": {
6868
"type": "object",
6969
"properties": {
70-
"id": { "type": "string" },
70+
"id": { "type": "number" },
7171
"message": { "type": "string" },
7272
"created_at": { "type": "string", "format": "date-time" },
7373
"updated_at": { "type": "string", "format": "date-time" }

lib/open_api_schema/request_validator_middleware.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ def initialize(app)
66
@request_validator = Committee::Middleware::RequestValidation.new(app, schema_path: "docs/openapi.json", strict_reference_validation: true, coerce_date_times: true, params_key: "action_dispatch.request.request_parameters", query_hash_key: "action_dispatch.request.query_parameters")
77
end
88

9-
# Handles the middleware call to validate the schema if the "Validate-Schema" header is present.
10-
# If the header is set to "1", it validates the request and response schema.
9+
# Handles the middleware call to validate the schema if the "VALIDATE_SCHEMA" header is present.
10+
# If the header is set to "1", it validates the request schema.
1111
# Otherwise, it continues the request-response cycle as usual.
1212
#
1313
# @param env [Hash] The Rack environment hash.
14-
# @return [Array] The status, headers, and body of the response.
14+
# @return [Array] The status, headers, and response.
1515
def call(env)
1616
status, headers, response = @app.call(env)
1717

lib/open_api_schema/response_validator_middleware.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11

22
module OpenApiSchema
33
class ResponseValidatorMiddleware
4+
# Initializes the middleware with the given Rack application and sets up the response validator.
5+
#
6+
# @param app [Object] The Rack application.
47
def initialize(app)
58
@app = app
69
@response_validator = Committee::Middleware::ResponseValidation.new(app, schema_path: "docs/openapi.json", strict_reference_validation: true)
710
end
811

9-
# Handles the middleware call to validate the schema if the "Validate-Schema" header is present.
10-
# If the header is set to "1", it validates the request and response schema.
11-
# Otherwise, it continues the request-response cycle as usual.
12+
# Handles the middleware call to validate the schema if the "VALIDATE_SCHEMA" header is present.
13+
# If the header is set to "1", it validates the response schema.
1214
#
1315
# @param env [Hash] The Rack environment hash.
14-
# @return [Array] The status, headers, and body of the response.
16+
# @return [Array] The status, headers, and response.
1517
def call(env)
1618
status, headers, response = @app.call(env)
1719

@@ -24,6 +26,10 @@ def call(env)
2426

2527
private
2628

29+
# Checks if the "Validate-Schema" header is present in the environment hash.
30+
#
31+
# @param env [Hash] The Rack environment hash.
32+
# @return [Boolean] True if the "Validate-Schema" header is present, false otherwise.
2733
def condition_for_response_validation?(env)
2834
env.key?("HTTP_VALIDATE_SCHEMA")
2935
end

0 commit comments

Comments
 (0)