Create mock server from Openapi specification
- Randomly or statically generated response
- Request validation
- Load specification from local or remote
- Support specification in yaml or json format
Note: Only support json content type as of now
Install it with:
$ gem install fakeit
Or use the docker image
$ fakeit --spec <Local file or remote url>
Command line options:
$ fakeit --help
usage:
--spec spec file uri (required)
-p, --port custom port
-q, --quiet mute request and response log
--permissive log validation error as warning instead of denying request
--use-example use example provided in spec if exists
trial options:
--static generate static response
other options:
-v, --version
-h, --help
Notes:
- See here for Openapi properties supported in random response generation
- See here for default value in static response generation
- Regarding
--use-example
mode, property without example specified will still be randomly or statically generated - Random response generation can not handle recursive schema reference. If you do need it in your spec file, please provide
example
property for the recursive part of schema and specify--use-example
option.
After checking out the repo, run bundle install
to install dependencies. Then, run rake
to run the tests.
To install this gem onto your local machine, run bundle exec rake install
.
To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/JustinFeng/fakeit.
The gem is available as open source under the terms of the MIT License.