mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 15:22:56 +00:00
Validate response headers based on specified header
Add validate_headers step in response validator. Using JSON::Validator with validate header value with swagger header object.
This commit is contained in:
@@ -17,6 +17,10 @@ class BlogsController < ApplicationController
|
||||
# GET /blogs/1
|
||||
def show
|
||||
@blog = Blog.find_by_id(params[:id])
|
||||
|
||||
fresh_when(@blog)
|
||||
return unless stale?(@blog)
|
||||
|
||||
respond_with @blog, status: :not_found and return unless @blog
|
||||
respond_with @blog
|
||||
end
|
||||
|
||||
@@ -50,6 +50,10 @@ describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
|
||||
produces 'application/json'
|
||||
|
||||
response '200', 'blog found' do
|
||||
header 'ETag', type: :string
|
||||
header 'Last-Modified', type: :string
|
||||
header 'Cache-Control', type: :string
|
||||
|
||||
schema '$ref' => '#/definitions/blog'
|
||||
|
||||
response_examples 'application/json' => {
|
||||
|
||||
@@ -89,8 +89,26 @@
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "blog found",
|
||||
"headers": {
|
||||
"ETag": {
|
||||
"type": "string"
|
||||
},
|
||||
"Last-Modified": {
|
||||
"type": "string"
|
||||
},
|
||||
"Cache-Control": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"$ref": "#/definitions/blog"
|
||||
},
|
||||
"examples": {
|
||||
"application/json": {
|
||||
"id": 1,
|
||||
"title": "Hello world!",
|
||||
"content": "Hello world and hello universe. Thank you all very much!!!"
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
|
||||
Reference in New Issue
Block a user