Skip to content

Instantly share code, notes, and snippets.

View erunion's full-sized avatar
⛑️
doing my best

Jon Ursenbach erunion

⛑️
doing my best
View GitHub Profile

We use Spectral at ReadMe and love that it's done to help clean up some API documentation of ours that had become a bit messy over the years. Here's the config file we use and some custom plugins I've written that help to ensure that we have: consistent sentence punctuation in descriptions, consistent usage of slug terminology, and incorporating Alex to ensure that our API docs have considerate and inclusive language.

const fetch = require('node-fetch');
const cheerio = require('cheerio');
const path = require('path');
const token = '<TMDB API KEY>';
const args = process.argv.slice(2);
const year = args.length ? args[0] : undefined;
if (!year) {
console.error(`USAGE: node ${path.basename(process.argv[1])} <YEAR>`);
{
"openapi" : "3.0.1",
"info" : {
"title" : "Find_Jobs",
"version" : "v2"
},
"servers" : [ {
"url" : "https://httpbin.org"
}],
"security" : [ {
@erunion
erunion / UserController.php
Last active December 12, 2018 18:11
Example API controller documented with vimeo/mill
<?php
namespace Vimeo\Controllers\Api;
use Vimeo\Api\Response\UserResponse;
class UserController extends \Vimeo\Controller
{
/**
* @api-label Get a user
* @api-operationId get_user
<?php
/**
* Safely get a value by key from an array (without creating a notice)
* @param array|object $array - can be an array or object
* @param int|string|array $keys - if array, performs a deep fetch on a multidemensional array|object
* @param mixed $default - if $keys do not exist in $array, this value is returned
* @return mixed - The value at $keys, or else $default
* @throws Exception if $keys is not a scalar or array
*/
@erunion
erunion / LintCommand.php
Last active August 29, 2015 14:13
PHP linter command for Laravel 4.2.*
<?php
class Lint extends \Illuminate\Console\Command {
/**
* The console command name.
*
* @var string
*/
protected $name = 'command:lint';
{
"description": "This is my Vagrant box, it's an example of what you can do with a custom Vagrant Cloud.",
"short_description": "This is my Vagrant box.",
"name": "myorg/mybox",
"versions": [
{
"version": "1.0.0",
"status": "active",
"description_html": null,
"description_markdown": "",
my.customcloud/myorg/mybox
my.customcloud/myorg/mybox.json
my.customcloud/myorg/mybox/version
my.customcloud/myorg/mybox/version/1
my.customcloud/myorg/mybox/version/1/provider
my.customcloud/myorg/mybox/version/1/provider/virtualbox.box
@erunion
erunion / countSelectors.php
Last active October 7, 2015 02:07
PHP function to parse a blob of CSS and count up the total number of selectors present. Useful if you need/want to factor this into your test suite to make sure your CSS files never reach the 4095 limit in IE9 and lower.
<?php
/**
* Parse out a given string containing CSS and count up the total number of
* selectors that are present in it.
*
* @return integer
*/
function countSelectors($css) {
$css = preg_replace('/\{(.*?)\}/s', '', $css);