Module: Ronin::App::Schemas::Payloads

Defined in:
lib/ronin/app/schemas/payloads/build_schema.rb,
lib/ronin/app/schemas/payloads/encoders/encode_schema.rb

Overview

Contains class methods for building dry-schemas for the /payloads routes.

Defined Under Namespace

Modules: Encoders

Class Method Summary collapse

Class Method Details

.BuildSchema(payload_class) ⇒ Dry::Schema::Params

Builds a Dry::Schema::Params schema for the given payload class and for the POST /payloads/.../build route.

Parameters:

  • payload_class (Class<Ronin::Payloads::Payload>)

    The payload class to build the schema for.

Returns:

  • (Dry::Schema::Params)

    The built schema.



43
44
45
46
47
48
49
50
51
52
# File 'lib/ronin/app/schemas/payloads/build_schema.rb', line 43

def self.BuildSchema(payload_class)
  # dynamically build the dry-schema based on the payload's params
  params_schema = Schemas::ParamsSchema(payload_class.params)

  return Dry::Schema::Params() do
    unless payload_class.params.empty?
      required(:params).hash(params_schema)
    end
  end
end