wedding-planner/spec/swagger_response_helper.rb
Manuel Bustillo a8c9c051f0
Some checks failed
Add copyright notice / copyright_notice (pull_request) Failing after 8m14s
Check usage of free licenses / check-licenses (pull_request) Failing after 7m54s
Run unit tests / unit_tests (pull_request) Failing after 6m48s
Add copyright notice
2024-11-16 01:52:48 +00:00

39 lines
757 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_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