Skip to content

Instantly share code, notes, and snippets.

View philsturgeon's full-sized avatar
🌳
Planting Trees

Phil Sturgeon philsturgeon

🌳
Planting Trees
View GitHub Profile
@philsturgeon
philsturgeon / .spectral.yaml
Created May 17, 2020 10:16
cache control rule
rules:
cache-control-undocumented:
description: |-
Cache usage MUST be extensively detailed in the `description` property
to avoid data leaks or the usage of stale data.
This rule should ensure in some way that the api provider
documented extensively the cache usage to avoid data leaks
or usage of stale data.
@philsturgeon
philsturgeon / giphy.bundled.yaml
Last active March 10, 2020 11:37
OpenAPI $ref Resolution: Bundling vs Dereferencing
swagger: '2.0'
schemes:
- https
host: api.giphy.com
basePath: /v1
info:
contact:
email: support@giphy.com
description: Giphy API phantom change
termsOfService: 'https://developers.giphy.com/'

Treeware

You're free to use this package, but if it makes it to your production environment you are required to buy the world a tree.

It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to plant trees. If you support this package and contribute to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.

You can buy trees here offset.earth/treeware

Read more about Treeware at treeware.earth

@philsturgeon
philsturgeon / cloudSettings
Last active May 29, 2020 11:26
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-05-29T11:26:30.695Z","extensionVersion":"v3.4.3"}
@philsturgeon
philsturgeon / gist.md
Last active November 14, 2021 00:08
OpenAPI specifications style guide / file format

API Specs & Docs

Style Guide

A lot of this information has been used to create linting rules for [Speccy], so just run the linter with --rules=strict for advice. It will be updated over time, as new rules are created.

File Structure

OpenAPI supports JSON Pointer via $ref keys, even when you’re writing in YAML. Swagger.io has a great guide for $ref and JSON Pointer.

@philsturgeon
philsturgeon / Gemfile
Created December 14, 2017 17:48
Faraday Adapters Benchmark
source 'https://rubygems.org'
gem 'faraday'
gem 'net-http-persistent'
gem 'typhoeus'
gem 'patron'
gem 'httpclient'
gem 'net-http2'
@philsturgeon
philsturgeon / wtf.md
Last active December 7, 2017 18:44
Postman disagrees with itself

Hey, I’m super lost.

Currently im trying to make API Flow work:

luckymarmot/API-Flow#149

There is an output.json which is a test case, and accoring to Postmans JSON Schema it is invalid.

I'm fixing a few (headers cannot have a null value) but the auth section is triggering errors. It looks like this:

@philsturgeon
philsturgeon / gist:bfabe7461ec6faf9457b6a75f25c0d9c
Created August 7, 2017 20:29
The most basic-ass presenter ever
class Api::V3::CompanyPresenter
attr_accessor :company, :includes
def initialize(company, includes: [])
@company = company
@includes = Array(includes)
end
def as_json
{
@philsturgeon
philsturgeon / gist:64f7b611a035084b39673853c7e43f0d
Last active June 8, 2017 16:54
Janky Quick Example of RPC API being cool

POST /check-v1

Request

{
  "user_uuid" : "12345",
  "policy_action" : "do-a-thing"
}

Taken verbatim from https://www.congress.gov/bill/114th-congress/house-bill/2029/text

   TITLE <<NOTE: Visa Waiver Program Improvement and Terrorist Travel 
  Prevention Act of 2015.>>  II--TERRORIST TRAVEL PREVENTION AND VISA 
WAIVER PROGRAM REFORM
SEC. 201. <<NOTE: 8 USC 1101 note.>> SHORT TITLE.

    This title may be cited as the ``Visa Waiver Program Improvement and 
Terrorist Travel Prevention Act of 2015''.