hmaus / branda
API Description Mock Server
Requires
- php: >=7.0
- hmaus/drafter-installer: ^1.0
- hmaus/drafter-php: ^4.0
- hmaus/spas-parser: ^1.0.0
- hmaus/spas-parser-apib: ^1.0.0
- psr/log: ^1.0
- react/http: ^0.4.1
- rize/uri-template: ^0.3.0
- symfony/config: ^3.1
- symfony/console: ^3.1
- symfony/dependency-injection: ^3.1
- symfony/event-dispatcher: ^3.1
- symfony/filesystem: ^3.1
- symfony/http-foundation: ^3.1
Requires (Dev)
- codeclimate/php-test-reporter: ^0.3
- phpunit/phpunit: ^5.0
- symfony/var-dumper: ^3.1
This package is not auto-updated.
Last update: 2022-02-01 13:01:12 UTC
README
An API description mock server.
Note
Branda is currently experimental!
It only supports API Blueprint as we speak.
Installation And Usage
Docker
If you are familiar with docker, it is by far the most comfortable way to use branda:
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
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:
-
docker run -it --name "branda" --rm
-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
- 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 \
-v
Mount current working directory into/appdata
folder inside the containerhendrikmaus/branda
is the image name (and tag)
-
mock 0.0.0.0 -f /appdata/your-service.apib
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
Stopping Branda
docker stop branda
Source
Pre-Requisites:
Installing branda from source means your machine must have PHP >= 7 and Cpp tools to compile Drafter
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:
"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:
composer require hmaus/branda
You have to require dev-master since there is no tag on the experimental version yet
Usage
The simplest example to fire up a mock server:
vendor/bin/branda mock --file "your-service.apib"
When installing using composer, branda will install to your
bin
folder,vendor/bin
by default