Skip to content

Instantly share code, notes, and snippets.

View marbemac's full-sized avatar

Marc MacLeod marbemac

View GitHub Profile
{
"steps": [
{
"functions": [
{
"input": {
"request": {
"postData": {
"text": "{\n \"foo\": \"bar\"\n}"
},
@marbemac
marbemac / gist:8ab63f09d04073bb4f8c17de91d3a585
Created October 13, 2016 19:55
random github gist flow
{
"name": "Random Github Gist",
"steps": [
{
"functions": [
{
"name": "List gists and save random id",
"input": {
"request": {
"method": "get",
{
"name": "Retweet Stoplight's latest tweet",
"description": "This scenario will grab the latest Stoplight tweet, and retweet it. The twitter API requires that requests be authenticated with oauth1. Before you can run this scenario, you must fill out the variables below.\n\n1. Create a new app at [https://apps.twitter.com](https://apps.twitter.com). No callback url needed.\n2. Navigate to the keys and access tokens tab of your app (see screenshot), and copy paste the tokens and secrets below.\n3. Click run scenario above!\n\n![](http://i.imgur.com/I6Eg08M.png)",
"steps": [
{
"functions": [
{
"name": "Get latest tweet",
"input": {
"authorization": {
@marbemac
marbemac / swagger.json
Last active June 28, 2017 17:54
Stoplight To-do Demo Swagger
{
"swagger": "2.0",
"info": {
"version": "1.0",
"title": "To-do Demo",
"description": "## Welcome\n\nThis is a place to put general notes and extra information, for internal use.\n\nTo get started designing/documenting this API, select a version on the left."
},
"host": "todos.stoplight.io",
"schemes": [
"http"
{
"swagger": "2.0",
"schemes": [
"http"
],
"basePath": "/api",
"host": "localhost:3000",
"info": {
"version": "",
@marbemac
marbemac / spec.json
Last active March 18, 2016 00:19
A barebones swagger example, that includes the StopLight extension to instruct Prism to validate and add a response header to all requests.
{
"swagger": "2.0",
"host": "myapi.com",
"schemes": ["http"],
"info": {},
"paths": {},
"definitions": {},
"x-stoplight": {
"beforeScript": "function(ctx, request) {}",
"afterScript": "function(ctx, request, response) { // messages contain any warnings or errors var messages = response.validate(); var isValid = response.valid.get(); // Set a header here, so that your testing tools can throw errors appropriately if (isValid) { response.header.set('Validation', 'Passed'); } else { response.header.set('Validation', 'Failed'); } }",
@marbemac
marbemac / config.json
Last active March 17, 2016 19:02
The default Prism config file.
{
"port": "4010",
"forwardHost": null,
"basePath": null,
"log": false,
"logLocation": "https://api.stoplight.io/v1",
"debug": true,
"mock": {
"enabled": false,
| files.readFile 3 ms (3)
| files.exists 1 ms (4)
| files.writeFileAtomically.....................................2,958 ms (2)
| ├─ files.writeFile 2,953 ms (2)
| └─ files.rename 5 ms (2)
| Rebuild App.................................................102,326 ms (1)
| ├─ compiler.compile(the app)....................................142 ms (1)
| │ └─ compileUnibuild (the app).................................142 ms (2)
| │ ├─ files.readdir 19 ms (126)
| │ ├─ files.stat 9 ms (813)
@marbemac
marbemac / main.js
Created September 8, 2015 06:25
Simple node server returning file
// Load the http module to create an http server.
var http = require('http');
var largeResponse = require('./large_response.json')
largeResponse = JSON.stringify(largeResponse)
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "application/json"});
@marbemac
marbemac / main.go
Created September 8, 2015 06:22
Simple go proxy, copying body
package main
import (
"bytes"
"io/ioutil"
"log"
"net/http"
"net/http/httputil"
"net/url"
)