Sha256: eb2588b144f24778ece0685378d94e4e438a1d4f11cf561afb4770081a5abbc2

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

require 'dry-validation'
require 'pact_broker/hash_refinements'
require 'pact_broker/api/contracts/dry_validation_workarounds'
require 'pact_broker/api/contracts/dry_validation_predicates'

module PactBroker
  module Api
    module Contracts
      class VerifiablePactsJSONQuerySchema
        extend DryValidationWorkarounds
        using PactBroker::HashRefinements

        SCHEMA = Dry::Validation.Schema do
          configure do
            predicates(DryValidationPredicates)
          end
          optional(:providerVersionTags).maybe(:array?)
          optional(:consumerVersionSelectors).each do
            schema do
              required(:tag).filled(:str?)
              optional(:latest).filled(included_in?: [true, false])
            end
          end
          optional(:includePendingStatus).filled(included_in?: [true, false])
          optional(:includeWipPactsSince).filled(:date?)
        end

        def self.call(params)
          select_first_message(flatten_indexed_messages(SCHEMA.call(params&.symbolize_keys).messages(full: true)))
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pact_broker-2.47.1 lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb
pact_broker-2.47.0 lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb
pact_broker-2.46.0 lib/pact_broker/api/contracts/verifiable_pacts_json_query_schema.rb