Coder Social home page Coder Social logo

asaaki / mimicry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mimicry-tech/mimicry

0.0 1.0 0.0 1.12 MB

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

License: MIT License

Elixir 95.69% Dockerfile 1.32% Makefile 2.92% Shell 0.06%

mimicry's Introduction

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

mimicry's People

Contributors

asaaki avatar dependabot[bot] avatar floriank avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.