Skip to content

Instantly share code, notes, and snippets.

View JamesMessinger's full-sized avatar

James Messinger JamesMessinger

View GitHub Profile
@JamesMessinger
JamesMessinger / swagger.yaml
Created October 21, 2014 03:30
Demonstrating reusing a Swagger operation definition for multiple paths
swagger: "2.0"
info:
version: "1.0.0"
title: CORS demo
description: Demonstrating reusing an operation definition for multiple paths
definitions:
CORS:
summary: CORS Preflight request
tags: [CORS]
responses:
@JamesMessinger
JamesMessinger / asyncForEach.js
Last active August 29, 2015 14:17
Async for loop in JavaScript
/**
* An asynchronous for-each loop
*
* @param {array} array The array to loop through
*
* @param {function} done Callback function (when the loop is finished or an error occurs)
*
* @param {function} iterator
* The logic for each iteration. Signature is `function(item, index, next)`.
* Call `next()` to continue to the next item. Call `next(Error)` to throw an error and cancel the loop.
@JamesMessinger
JamesMessinger / circular-refs.js
Created July 16, 2015 03:31
JSON Schema Circular $Refs
{
"definitions": {
"thing": {
"$ref": "#/definitions/thing" // circular reference to self
},
"person": {
"properties": {
"name": {
"type": "string"
},
@JamesMessinger
JamesMessinger / json-pointer-example-1.yaml
Created April 15, 2016 15:25
This example demonstrates a simple URL-encoded JSON Pointer in a Swagger 2.0 API definition
swagger: "2.0"
info:
version: 1.0.0
title: Example
paths:
"/foo":
get:
responses:
200:
@JamesMessinger
JamesMessinger / json-pointer-example-2.yaml
Created April 15, 2016 15:27
This example demonstrates a URL-encoded JSON Pointer in a Swagger 2.0 API definition
swagger: "2.0"
info:
version: 1.0.0
title: Blog
paths:
"/blogs/{id}/posts":
parameters:
- name: "id"
in: "path"
type: "integer"

SailsJS v1.0

This is just a list of changes that I would like to see in SailsJS v1.0. Many of these are breaking changes, but this is a major version bump, so now is the time to make these changes. It’s worth the upgrade pain to make some much-needed improvements to the framework and remove some legacy bloat and code smell.

Top Priorities:

Upgrade to Express 4.0

  • Or Express 5.0, if it’s at least in beta by then

Trim-down SailsJS Core by moving a bunch of stuff to plug-ins (hooks)

  • Remove Grunt, EJS, and LESS from SailsJS Core
@JamesMessinger
JamesMessinger / NewsArticle.yaml
Last active July 31, 2018 09:13
Example of using `allOf` to extend an object in a Swagger API
swagger: "2.0"
info:
version: "1.0.0"
title: minimal
description: News Articles ftw
paths:
/users:
get:
responses:
"200":
@JamesMessinger
JamesMessinger / json-schema.js
Created July 27, 2017 19:19
Using JSON Schema in Postman
// Define the JSON Schema
const customerSchema = {
"required": ["id"],
"properties": {
"id": {
"type": "integer",
"minimum": 100,
"maximum": 1000
},
"name": {
@JamesMessinger
JamesMessinger / reuse-code.js
Created July 27, 2017 19:23
Reusing code in Postman
// First, run the common tests
eval(globals.commonTests)();
// Then run any request-specific tests
tests["Status code is 200"] = responseCode.code === 200;
@JamesMessinger
JamesMessinger / postman-bdd.js
Created July 27, 2017 19:22
Postman BDD example
describe('Get customer info', () => {
it('should return a valid response', () => {
response.should.have.status(200);
response.should.be.json;
response.body.should.not.be.empty;
});
it('should set the Location header', () => {
response.should.have.header('Location');