/mockserver-client-ruby

A Ruby client for MockServer project. This client is code generated using the MockServer OpenAPI v3 specification.

Primary LanguageRuby

mockserver-client

MockServer - the Ruby gem for the MockServer API

MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby and a simple REST API (as shown below).

MockServer Proxy is a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding).

Both MockServer and the MockServer Proxy record all received requests so that it is possible to verify exactly what requests have been sent by the system under test.

This SDK is automatically generated by the OpenAPI Generator project:

  • API version: 5.13.2
  • Package version: 5.13.2
  • Build package: org.openapitools.codegen.languages.RubyClientCodegen

Installation

Build a gem

To build the Ruby code into a gem:

gem build mockserver-client.gemspec

Then either install the gem locally:

gem install ./mockserver-client-5.13.2.gem

(for development, run gem install --dev ./mockserver-client-5.13.2.gem to install the development dependencies)

or publish the gem to a gem hosting service, e.g. RubyGems.

Finally add this to the Gemfile:

gem 'mockserver-client', '~> 5.13.2'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:

gem 'mockserver-client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'

Include the Ruby code directly

Include the Ruby code directly using -I as follows:

ruby -Ilib script.rb

Getting Started

Please follow the installation procedure and then run the following code:

# Load the gem
require 'mockserver-client'

api_instance = MockServer::ControlApi.new
ports = MockServer::Ports.new # Ports | list of ports to bind to, where 0 indicates dynamically bind to any available port

begin
  #bind additional listening ports
  result = api_instance.mockserver_bind_put(ports)
  p result
rescue MockServer::ApiError => e
  puts "Exception when calling ControlApi->mockserver_bind_put: #{e}"
end

Documentation for API Endpoints

All URIs are relative to http://localhost:1080

Class Method HTTP request Description
MockServer::ControlApi mockserver_bind_put PUT /mockserver/bind bind additional listening ports
MockServer::ControlApi mockserver_clear_put PUT /mockserver/clear clears expectations and recorded requests that match the request matcher
MockServer::ControlApi mockserver_reset_put PUT /mockserver/reset clears all expectations and recorded requests
MockServer::ControlApi mockserver_retrieve_put PUT /mockserver/retrieve retrieve recorded requests, active expectations, recorded expectations or log messages
MockServer::ControlApi mockserver_status_put PUT /mockserver/status return listening ports
MockServer::ControlApi mockserver_stop_put PUT /mockserver/stop stop running process
MockServer::ExpectationApi mockserver_expectation_put PUT /mockserver/expectation create expectation
MockServer::ExpectationApi mockserver_openapi_put PUT /mockserver/openapi create expectations from OpenAPI or Swagger
MockServer::VerifyApi mockserver_verify_put PUT /mockserver/verify verify a request has been received a specific number of times
MockServer::VerifyApi mockserver_verify_sequence_put PUT /mockserver/verifySequence verify a sequence of request has been received in the specific order

Documentation for Models

Documentation for Authorization

All endpoints do not require authorization.