GithubHelp home page GithubHelp logo

justjavac / prism Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stoplightio/prism

1.0 2.0 0.0 8.66 MB

Turn any OpenAPI2/3 and Postman Collection file into an API server with mocking, transformations and validations.

Home Page: https://stoplight.io/prism

License: Apache License 2.0

JavaScript 0.51% TypeScript 98.61% Shell 0.18% Dockerfile 0.69%

prism's Introduction

Prism

CircleCI NPM Downloads Buy us a tree

Prism is a set of packages for API mocking with OpenAPI v2 (formerly known as Swagger) and OpenAPI v3.

For example, given an API description document you can spin up a mock HTTP server and respond realistically based on your requests

Demo of Prism Mock Server being called with curl from the CLI

Note: This branch refers to Prism 3.x, which is the current version most likely you will use. If you're looking for the 2.x version, look at the 2.x branch

Installation

Prism requires NodeJS >= 12 to properly work.

npm install -g @stoplight/prism-cli

# OR

yarn global add @stoplight/prism-cli

For more installation options, see our installation documentation.

Documentation

You can find Prism documentation on Stoplight.io.

What's next for Prism?

  • Content Negotiation
  • Security Validation
  • Custom Mocking
  • Validation Proxy
  • Recording / "Learning" mode to create spec files
  • Data Persistence (allow Prism act like a sandbox)

FAQs

Cannot access mock server when using docker?

Prism uses localhost by default, which usually means 127.0.0.1. When using docker the mock server will be unreachable outside of the container unless you run the mock command with -h 0.0.0.0.

Why am I getting 404 errors when I include my basePath?

OpenAPI v2.0 had a concept called "basePath", which was essentially part of the HTTP path the stuff after host name and protocol, and before query string. Unlike the paths in your paths object, this basePath was applied to every single URL, so Prism v2.x used to do the same. In OpenAPI v3.0 they merged the basePath concept in with the server.url, and Prism v3 has done the same.

We treat OAS2 host + basePath the same as OAS3 server.url, so we do not require them to go in the URL. If you have a base path of api/v1 and your path is defined as hello, then a request to http://localhost:4010/hello would work, but http://localhost:4010/api/v1/hello will fail. This confuses some, but the other way was confusing to others. Check the default output of Prism CLI to see what URLs you have available.

Contributing

If you are interested in contributing to Prism itself, check out our contributing docs โ‡— and code of conduct โ‡— to get started.

Thanks

Prism is built on top of lots of excellent packages, and here are a few we'd like to say a special thanks to.

Check these projects out!

prism's People

Contributors

acktsap avatar adriengibrat avatar binarymuse avatar chohmann avatar chris-miaskowski avatar clemblanco avatar codeasashu avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dmiyamoto avatar frangarcia avatar imsop avatar karol-maciaszek avatar lag-of-death avatar lottamus avatar mallachari avatar marcelltoth avatar mikelebeau avatar mrtnvh avatar nhuray avatar p0lip avatar pytlesk4 avatar rogersolsvik avatar sasakix avatar silvervest avatar tbarn avatar tdurtschi avatar xvincentx avatar

Stargazers

 avatar

Watchers

 avatar  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.