wedding-planner/spec/swagger_response_helper.rb
Manuel Bustillo 3d424c304e
All checks were successful
Check usage of free licenses / check-licenses (pull_request) Successful in 1m9s
Add copyright notice / copyright_notice (pull_request) Successful in 1m17s
Run unit tests / unit_tests (pull_request) Successful in 2m43s
Revert user authentication
This reverts commit b215e8a3b40be089e7359cfd424f807c2d54b1c2.
2024-11-30 10:45:17 +01:00

47 lines
900 B
Ruby

# Copyright (C) 2024 Manuel Bustillo
module SwaggerResponseHelper
def response_422
response(422, 'Validation errors in input parameters') do
produces 'application/json'
error_schema
xit
end
end
def response_empty_200
response(200, 'Success') do
produces 'application/json'
schema type: :object
xit
end
end
def response_empty_201
response(201, 'Created') do
produces 'application/json'
schema type: :object
xit
end
end
def response_404
response(404, 'Record not found') do
produces 'application/json'
error_schema
xit
end
end
private
def error_schema
schema type: :object,
required: %i[message errors],
properties: {
message: { type: :string },
errors: { type: :array, items: { type: :string } }
}
end
end