2017 © Pedro Peláez
 

library branda

API Description Mock Server

image

hmaus/branda

API Description Mock Server

  • Wednesday, October 26, 2016
  • by hendrikmaus
  • Repository
  • 3 Watchers
  • 2 Stars
  • 69 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Branda

An API description mock server., (*1)

Minimum PHP Version Build Status codecov Code Climate, (*2)

Note

Branda is currently experimental!
It only supports API Blueprint as we speak., (*3)

Installation And Usage

Docker

If you are familiar with docker, it is by far the most comfortable way to use branda:, (*4)

Mac users: make sure that your files can be made available to docker. E.g.: with docker-machine-nfs, mount the respective folder or you -v won't work with docker, (*5)

docker run -it --name "branda" --rm -p 8000:8000 \
  -v $(pwd):/appdata hendrikmaus/branda \
  mock 0.0.0.0 -f /appdata/your-service.apib

Let's get into the details of that command:, (*6)

  • docker run -it --name "branda" --rm, (*7)

    • -t Allocate a pseudo-tty
    • -i Keep STDIN open even if not attached
    • --name "branda" Name of the container
    • --rm Cleanup when the container exits
  • -p 8000:8000, (*8)

    • Port mapping
    • branda will listen on port 8000 by default, but you can change it using an option
    • Note for Mac users: you will expose the port on the IP of your vm solution, e.g. docker-machine
  • -v $(pwd):/appdata hendrikmaus/branda \, (*9)

    • -v Mount current working directory into /appdata folder inside the container
    • hendrikmaus/branda is the image name (and tag)
  • mock 0.0.0.0 -f /appdata/your-service.apib, (*10)

    These are the actual arguments and options passed to branda. make sure to listen on the public interface. When passing your file into it, remember it sits inside of /appdata in the container and /appdata is equal to the structure of your current working directory, (*11)

Stopping Branda

docker stop branda, (*12)

Source

Pre-Requisites:
Installing branda from source means your machine must have PHP >= 7 and Cpp tools to compile Drafter, (*13)

The recommended way to install branda is by using composer.
Since there currently is a dependency on drafter, you have to add this to your scripts section in composer.json:, (*14)

  "extra": {
    "drafter-installer-tag": "v3.1.3"
  },
  "scripts": {
    "install-drafter": "Hmaus\\Drafter\\Installer::installDrafter",
    "post-install-cmd": [
      "@install-drafter"
    ],
    "post-update-cmd": [
      "@install-drafter"
    ]
  }

Now you can require branda itself:, (*15)

composer require hmaus/branda

You have to require dev-master since there is no tag on the experimental version yet, (*16)

Usage

The simplest example to fire up a mock server:, (*17)

vendor/bin/branda mock --file "your-service.apib"

When installing using composer, branda will install to your bin folder, vendor/bin by default, (*18)

The Versions