Module: Verquest

Defined in:
lib/verquest.rb,
lib/verquest/base.rb,
lib/verquest/result.rb,
lib/verquest/version.rb,
lib/verquest/versions.rb,
lib/verquest/properties.rb,
lib/verquest/transformer.rb,
lib/verquest/configuration.rb,
lib/verquest/properties/base.rb,
lib/verquest/properties/enum.rb,
lib/verquest/properties/array.rb,
lib/verquest/properties/const.rb,
lib/verquest/properties/field.rb,
lib/verquest/version_resolver.rb,
lib/verquest/properties/object.rb,
lib/verquest/properties/reference.rb,
lib/verquest/properties/collection.rb,
lib/verquest/base/helper_class_methods.rb,
lib/verquest/base/public_class_methods.rb,
lib/verquest/base/private_class_methods.rb,
lib/verquest/helper_methods/required_properties.rb

Overview

Verquest is a Ruby gem for versioning API requests

Verquest allows you to define and manage versioned API request schemas, handle parameter mapping between different versions, validate incoming parameters against schemas, and generate documentation.

Examples:

Basic usage

class UserCreateRequest < Verquest::Base
  description "User Create Request"
  schema_options additional_properties: false

  version "2025-06" do
    field :email, type: :string, required: true, format: "email"
    field :name, type: :string

    object :address do
      field :street, type: :string, map: "/address_street"
      field :city, type: :string, required: true, map: "/address_city"
      field :zip_code, type: :string, map: "/address_zip_code"
    end
  end

  version "2025-08", exclude_properties: %i[name] do
    field :name, type: :string, required: true
  end
end

# Map and validate parameters for a specific version
result = UserCreateRequest.map(params, version: "2025-07", validate: true)

if result.success?
  process_user(result.value)
else
  handle_errors(result.errors)
end

See Also:

Defined Under Namespace

Modules: HelperMethods, Properties Classes: Base, Configuration, Result, Transformer, Version, VersionResolver, Versions

Constant Summary collapse

Error =

Base error class for all Verquest-related errors

Class.new(StandardError)
VersionNotFoundError =

Error raised when a requested version cannot be found

Class.new(Verquest::Error)
PropertyNotFoundError =

Error raised when a requested property cannot be found in a version

Class.new(Verquest::Error)
MappingError =

Error raised when there are issues with property mappings

Class.new(Verquest::Error)
InvalidParamsError =

Error raised when parameters do not match the expected schema

Class.new(Verquest::Error) do
  attr_reader :errors

  # @param message [String] error message
  # @param errors [Array] validation errors
  def initialize(message, errors:)
    super(message)
    @errors = errors
  end
end

Class Method Summary collapse

Class Method Details

.configurationVerquest::Configuration

Returns the global configuration for Verquest

Returns:

See Also:



87
88
89
# File 'lib/verquest.rb', line 87

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ void

This method returns an undefined value.

Configure Verquest with the given block

Examples:

Verquest.configure do |config|
  config.validate_params = true
  config.current_version = -> { "2023-06" }
end

Yields:

Yield Parameters:



102
103
104
# File 'lib/verquest.rb', line 102

def configure
  yield(configuration)
end