Skip to content

A server to create small on demand mock servers for OpenAPIv3 powered JSON APIs and GraphQL

License

Notifications You must be signed in to change notification settings

floriank/mimicry

 
 

Repository files navigation

Mimicry

Elixir CI

A small server for generating ad hoc mock servers based on an OpenAPIv3 specification.

For architecture details, see ARCHITECTURE

⚠️ This is an idea at the moment, which I invest some free time into. Come back later, if you like 😉 - A lot of stuff is in progress or just scribbled on a napkin right now.

Usage

Docker

To try it out quickly:

$ docker pull floriank/mimicry

and a

$ docker run -p 8080:8080 floriank/mimicry

Inspecting running mimic servers

By default, servers are available under the special __mimicry path:

$ curl --header "Content-Type: application/json" \ 
       http://localhost:8080/__mimicry

Creating a new mimic server

If you'd like to try out how it works, post a valid OpenAPIv3 to create a mock server:

$ curl --header "Content-Type: application/json" \ 
       --request POST \
       --data '{"spec": { /* your OpenAPIv3 Spec */ }}'' \
       http://localhost:8080/__mimicry

Following up with a

# The host you're using needs to be part of your OpenAPIv3 Specification in info.servers[]
$ curl --header "X-Mimicry-Host: https://my.production.api.info" \
       http://localhost:8080/

should return you the specification.

NOTE: Mimicry uses the title and version fields to generate an id for your particular spec. the URL passed to X-Mimicry-Host is one of the server URLs defined in your specification.

Preloading a specification

You can add a set of specifications upon startup:

$ docker run -v `pwd`/my-specs:/specifications -p 8080:8080 floriank/mimicry

Development

The project comes with a small docker-compose setup. You can use make to get started:

# to get the local image built
$ make setup

# to start the local development server
$ make up

You should be able to reach mimicry at localhost:4000. Have a look at config/dev.exs if you wish to change ports.

Non-docker

Not recommended, but mimicry is just a Phoenix powered Elixir Application with no dependencies. So you can always run:

# copy over the config sample
$ cp ./config/dev.exs.sample ./config/dev.exs

# get the deps
$ mix deps.get

# run the server directly
$ mix phx.serve

Some ways to customizing your iex experience are included in this mode.

Logo

The logo was designed by the most excellent Agatha Schnips. It's released under CC BY 4.0. You may use, change and alter it, as long as you attribute the original author and indicate changes made.

List of planned capabilities

  • Coverage of most of the OpenAPIv3 specification, offering opinionated servers
  • Allow for creating simple GraphQL endpoints based on the schemata provided
  • Simple installation/running via docker container

About

A server to create small on demand mock servers for OpenAPIv3 powered JSON APIs and GraphQL

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 95.5%
  • Makefile 3.0%
  • Dockerfile 1.4%
  • Shell 0.1%