[WIP] prism overview article (#161)
* - prism overview article * Update overview.md * Update overview.md * - cleaning up prism introduction article * - need to add related links * - add prism helpers * Update introduction.md * - add images/gifs to the prism introduction
This commit is contained in:
committed by
Robert Wallach
parent
1afe7ad92e
commit
3c5d9bf54e
@@ -1,43 +1,43 @@
|
|||||||
# Personal Billing Overview
|
# Personal Billing Overview
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Platform Plans
|
## Platform Plans
|
||||||
|
|
||||||
### Open Source
|
### Open Source
|
||||||
- Price: Free
|
- Price: Free
|
||||||
- Features:
|
- Features:
|
||||||
- API Modeling
|
- API Modeling
|
||||||
- Documentation
|
- Documentation
|
||||||
- Mocking
|
- Mocking
|
||||||
- Testing
|
- Testing
|
||||||
|
|
||||||
### Developer
|
### Developer
|
||||||
- Price: $9/month
|
- Price: $9/month
|
||||||
- Features:
|
- Features:
|
||||||
- Unlimited Private Projects
|
- Unlimited Private Projects
|
||||||
- Coming Soon: Github Integration
|
- Coming Soon: Github Integration
|
||||||
|
|
||||||
## Documentation Plans
|
## Documentation Plans
|
||||||
|
|
||||||
### Basic
|
### Basic
|
||||||
- Price: Free
|
- Price: Free
|
||||||
- Features:
|
- Features:
|
||||||
- Unlimited Visits
|
- Unlimited Visits
|
||||||
- Publish to .docs.stoplight.io
|
- Publish to .docs.stoplight.io
|
||||||
- Docs & OpenAPI Editors
|
- Docs & OpenAPI Editors
|
||||||
|
|
||||||
### Essential
|
### Essential
|
||||||
- Price: $79/month
|
- Price: $79/month
|
||||||
- Features:
|
- Features:
|
||||||
- Publish to your Domain (1 domain)
|
- Publish to your Domain (1 domain)
|
||||||
- Theming
|
- Theming
|
||||||
- Build History & Instant Rollbacks
|
- Build History & Instant Rollbacks
|
||||||
|
|
||||||
### Standard
|
### Standard
|
||||||
- Price: $179/month
|
- Price: $179/month
|
||||||
- Features:
|
- Features:
|
||||||
- Publish to your Domain (10 domains)
|
- Publish to your Domain (10 domains)
|
||||||
- Custom CSS
|
- Custom CSS
|
||||||
- White Label
|
- White Label
|
||||||
- Basic Auth & Auth0 Integration
|
- Basic Auth & Auth0 Integration
|
||||||
|
|||||||
61
articles/prism/introduction.md
Normal file
61
articles/prism/introduction.md
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# Introduction
|
||||||
|
|
||||||
|
Prism is a proxy and API server toolkit that helps you test, mock, validate, and orchestrate your online applications. We rebuilt Prism from the ground up to be performant, powerful, and programmable while still being practical. Prism enables teams to work in parallel and iterate faster with less errors. The Stoplight Platform integrates tightly with Prism to generate test coverage of your API automatically, build tests visually, and create mock and contract servers instantly.
|
||||||
|
|
||||||
|
Prism has first class support for the OpenAPI Specification (aka OAS) and Stoplight Scenarios. OAS is machine readable documentation of your API that Prism can read and understand. Scenarios tell Prism how to orchestrate your API. When you use them together you can easily assert, transform, and validate your API against your OAS. Prism also allows your front-end team to work in tandem with your back-end team. While the back-end team implements your API, your front-end teams can implement against a mock server that can return static examples, dynamic data, or replay actual traffic from your API.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* Act as a mock server, routing incoming requests to example responses, or dynamically generating examples on the fly
|
||||||
|
* Act as a transformation layer, manipulating incoming requests and outgoing responses
|
||||||
|
* Act as a validation layer, validating incoming requests, and outgoing responses
|
||||||
|
* Contract test your APIs
|
||||||
|
* Extend existing APIs with new endpoints or capabilities
|
||||||
|
* Act as a system-wide proxy, blocking traffic to particular websites or endpoints
|
||||||
|
|
||||||
|
## Conduct vs Serve
|
||||||
|
|
||||||
|
Conduct and Serve are important concepts to understand when using Prism.
|
||||||
|
|
||||||
|
* Conduct is an isolated scenario run. You tell Prism what scenarios you want to run, give it an environment to run against, and Prism will generate a report of the run
|
||||||
|
|
||||||
|
* Serving, on the other hand, is a long running instance of Prism that applies scenarios to HTTP traffic
|
||||||
|
|
||||||
|
### Conduct Use Cases
|
||||||
|
|
||||||
|
1. Debugging your API implementation or specification
|
||||||
|
2. Integrating with your CI/CD Environment: Catch bugs before they get to your actual API Consumers
|
||||||
|
3. Webhooks: Generate your OAS from code, automatically upload it to Stoplight
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Serve Use Cases
|
||||||
|
|
||||||
|
1. Mocking back one or more specifications: Useful to help teams work in parallel and simplify testing dependencies.
|
||||||
|
2. Validating live traffic between your client/backend.
|
||||||
|
3. Your API, your workflow, your Prism. Prism is very flexible. You can easily create an instance that will record your API traffic, save it to S3, and then create another instance that will replay that API traffic.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### Stoplight Prism Helpers
|
||||||
|
|
||||||
|
The [Prism Helpers](https://next.stoplight.io/stoplight/prism) project is a collection of scenarios, specifications, and Prism instances that illustrate how to use Prism effectively. Please go [here](https://community.stoplight.io) and let us know what you would like to see.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Related Articles**
|
||||||
|
|
||||||
|
* [Javascript Runtime Refrence](/runtime.md)
|
||||||
|
* [Passing Data Between Steps](/testing/getting-started/passing-data-between-steps)
|
||||||
|
* [Running Tests In Stoplight](/testing/running-tests/in-stoplight)
|
||||||
|
* [Running Tests in the Terminal](/testing/running-tests/in-the-terminal)
|
||||||
|
* [Running Tests Triggered by URL](/testing/running-tests/triggering-by-url)
|
||||||
|
* [Using Variables Overview](/testing/using-variables/overview)
|
||||||
|
* [$$.env (Environment)](/testing/using-variables/environment)
|
||||||
|
* [$.ctx(Context)](/testing/using-variables/context)
|
||||||
|
* [Sending HTTP Requests](/testing/sending-http-requests/overview)
|
||||||
|
* [Referencing other Scenarios](/testing/referencing-other-scenarios/overview)
|
||||||
|
* [Contract Testing](testing/leveraging-openapi/contract-testing)
|
||||||
|
* [Integrating in Continuous Integration](/testing/continuous-integration/overview)
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
# Mocking with Prism
|
|
||||||
|
|
||||||
Prism is a performant, dependency free server, built specifically to work with web APIs.
|
|
||||||
|
|
||||||
### Features
|
|
||||||
- Act as a mock server, routing incoming requests to example repsonses, or dynamically generating examples on the fly.
|
|
||||||
- Act as a transformation layer, manipulating incoming requests and outgoing responses.
|
|
||||||
- Act as a validation layer, validating incoming requests and outgoing responses.
|
|
||||||
- Contract test your APIs, given an OAS(Swagger 2) file.
|
|
||||||
- Log all or a subset of traffic to configurable locations.
|
|
||||||
- Extend existing APIs with new endpoints or capabilites.
|
|
||||||
- Act as a system-wide proxy, blocking traffic to particular websites or endpoints.
|
|
||||||
|
|
||||||
### Simplicity Redefined
|
|
||||||
Run it anywhere. It runs on OS X, Windows, and Linux, with no external dependencies. It is a single, self-contained binary file, that you can easily run from your terminal with a single command.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
#### macOS and Linux
|
|
||||||
|
|
||||||
```# Install Prism
|
|
||||||
curl https://raw.githubusercontent.com/stoplightio/prism/master.install.sh | sh
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Windows
|
|
||||||
Download the appropriate binary from [here](https://github.com/stoplightio/prism/releases). Unzip the binary file, then navigate in your terminal to the folder where you extracted Prism.
|
|
||||||
|
|
||||||
### Run a Simple Mock Server
|
|
||||||
Prism understands OAS(Swagger 2), so let's get started by spinning up a quick mock server for the popular Petstore API. To do this, run the following command in your terminal:
|
|
||||||
|
|
||||||
```# os x / linux
|
|
||||||
prism run --mock --list --spec http://petstore.swagger.io/v2/swagger.json
|
|
||||||
|
|
||||||
# windows
|
|
||||||
path/to/prism.exe run --mock --list --spec http://petstore.swagger.io/v2/swagger.json
|
|
||||||
```
|
|
||||||
|
|
||||||
Here, you are using the "run" command to run a server based on the spec file passed in via the --spec argument. The spec location can be the filepath to a file on your computer, or the URL to a publicly hosted file. The mock argument tells Prism to mock all incoming requests, instead of forwarding them to the API host described in the spec file. The list argument is a convenience, and tells Prism to print out the endpoints in the spec on startup.
|
|
||||||
|
|
||||||
Prism starts on port 4010 by default - try visiting ```http://localhost:4010/v2/pet/findByStatus``` in your browser. This is one of the endpoints described in the petstore spec you passed in. You'll notice that it returns an error about a required query string parameter "status". This is the automatic request validation at work! The swagger spec specifies that a query string parameter names "status" is required for this endpoint so Prism simulates a 400 response for you. Reload the page with a query string parameter, and you will see the dynamically generated mock response ```http://localhost:4010/v2/pet/findByStatus?status=available```.
|
|
||||||
|
|
||||||
Tada! With a single command you have started a validating, dynamically mocking version of the Swagger petstore API.
|
|
||||||
|
|
||||||
### Run some Contract Tests
|
|
||||||
|
|
||||||
Prism consumes OAS(Swagger 2) files. OAS provides the contract for your API. If your OAS file contains the x-tests extension (generated automatically if you use the Stoplight app to manage your OAS and tests) then you can run tests with Prism.
|
|
||||||
|
|
||||||
Check out [this specification](https://goo.gl/jniYmw). If you scroll past all the regular OAS properties, you will notice a ```x-tests``` extension near the bottom of the file. Inside of that property, we have a few test cases defined. This OAS file, along with its tests, is managed in the Stoplight app (we export our API from within the app to produce this file).
|
|
||||||
|
|
||||||
#### To Run the Contract Tests
|
|
||||||
```
|
|
||||||
# os x / linux
|
|
||||||
prism test --spec https://goo.gl/jniYmw
|
|
||||||
|
|
||||||
# windows
|
|
||||||
path/to/prism.exe test --spec https://goo.gl/jniYmw
|
|
||||||
```
|
|
||||||
|
|
||||||
You should see some nice output to your terminal detailing the tests and assertions that are run. These tests take our OAS contract and apply it to your API. They act as a sort of sync manager.
|
|
||||||
|
|
||||||
> If a test fails, it means one of two things - your API is broken or, our OAS contract is out of date / incorrect
|
|
||||||
|
Before Width: | Height: | Size: 871 KiB After Width: | Height: | Size: 871 KiB |
BIN
assets/gifs/prism-introduction-conduct.gif
Normal file
BIN
assets/gifs/prism-introduction-conduct.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 MiB |
BIN
assets/gifs/prism-introduction-mock.gif
Normal file
BIN
assets/gifs/prism-introduction-mock.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 MiB |
BIN
assets/images/prism-introduction-help.png
Normal file
BIN
assets/images/prism-introduction-help.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 253 KiB |
Reference in New Issue
Block a user