All checks were successful
		
		
	
	Check usage of free licenses / check-licenses (pull_request) Successful in 1m38s
				
			Add copyright notice / copyright_notice (pull_request) Successful in 3m16s
				
			Run unit tests / unit_tests (pull_request) Successful in 5m31s
				
			Build Nginx-based docker image / build-static-assets (pull_request) Successful in 41m31s
				
			
		
			
				
	
	
		
			71 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
# Copyright (C) 2024-2025 LibreWeddingPlanner contributors
 | 
						|
 | 
						|
# frozen_string_literal: true
 | 
						|
 | 
						|
module SwaggerResponseHelper
 | 
						|
  TIMESTAMP_FORMAT = '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z'
 | 
						|
  TIMESTAMP_EXAMPLE = Time.zone.now.iso8601(3)
 | 
						|
 | 
						|
  TIMESTAMP = { type: :string, pattern: TIMESTAMP_FORMAT, example: TIMESTAMP_EXAMPLE }.freeze
 | 
						|
  PASSWORD = { type: :string, minLength: User.password_length.begin, maxLength: User.password_length.end }.freeze
 | 
						|
 | 
						|
  def regular_api_responses
 | 
						|
    response401
 | 
						|
  end
 | 
						|
 | 
						|
  def response422
 | 
						|
    response(422, 'Validation errors in input parameters') do
 | 
						|
      produces 'application/json'
 | 
						|
      error_schema
 | 
						|
      xit
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  def response_empty200
 | 
						|
    response(200, 'Success') do
 | 
						|
      produces 'application/json'
 | 
						|
      schema type: :object
 | 
						|
      xit
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  def response_empty201
 | 
						|
    response(201, 'Created') do
 | 
						|
      produces 'application/json'
 | 
						|
      schema type: :object
 | 
						|
      xit
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  def response404
 | 
						|
    response(404, 'Record not found') do
 | 
						|
      produces 'application/json'
 | 
						|
      error_schema
 | 
						|
      xit
 | 
						|
    end
 | 
						|
  end
 | 
						|
 | 
						|
  def response401(message: nil)
 | 
						|
    response(401, 'Unauthorized') do
 | 
						|
      produces 'application/json'
 | 
						|
      schema type: :object,
 | 
						|
             required: %i[error],
 | 
						|
             properties: {
 | 
						|
               error: { type: :string, example: message || 'You need to sign in or sign up before continuing.' }
 | 
						|
             }
 | 
						|
      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
 |