Skip to content

Commit 4991cf9

Browse files
committed
Add inline docs to middlewares
1 parent 759d561 commit 4991cf9

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

lib/openapi_first/middlewares/request_validation.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,19 @@
33
require 'rack'
44
module OpenapiFirst
55
module Middlewares
6-
# A Rack middleware to validate requests against an OpenAPI API description
6+
# A Rack middleware to validate requests against an OpenAPI API description.
7+
# All error responses can be customized via the +error_response:+ option.
8+
# === Request body validation
9+
#
10+
# * Returns +415+ if the request content-type does not match the OpenAPI description.
11+
# * Returns +400+ for invalid JSON, missing required fields, type/enum/schema violations, or +readOnly+ fields.
12+
# * Empty bodies are accepted when the body is optional in the spec.
13+
#
14+
# === Parameter validation
15+
#
16+
# Query, path, header, and cookie parameters are validated and type-converted against the spec.
17+
# Missing required parameters or type/format violations return +400+.
18+
#
719
class RequestValidation
820
# @param app The parent Rack application
921
# @param spec [String, Symbol, OpenapiFirst::Definition] Path to the OpenAPI file or an instance of Definition.

lib/openapi_first/middlewares/response_validation.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
module OpenapiFirst
66
module Middlewares
7-
# A Rack middleware to validate requests against an OpenAPI API description
7+
# A Rack middleware to validate requests against an OpenAPI API description.
8+
# You probably want to use +OpenapiFirst::Test+ instead of this middleware.
89
class ResponseValidation
910
# @param spec [String, Symbol, OpenapiFirst::Definition] Path to the OpenAPI file or an instance of Definition.
1011
# If you pass a Symbol, it will load the OAD registered via `OpenapiFirst.register`

0 commit comments

Comments
 (0)