Skip to content

Instantly share code, notes, and snippets.

View acunniffe's full-sized avatar
🏁
finishing things

Aidan Cunniffe acunniffe

🏁
finishing things
View GitHub Profile

import { Callout } from "nextra-theme-docs";

Capturing Traffic

Optic Capture helps create OpenAPI specifications and keep them up to date by examining the traffic to your API. Under the hood the following happens when running Capture,

  • Your API is started via a command you provide.
  • A reverse proxy is configured to send traffic to your API.
  • A command or set of requests you provide is run, generating traffic to the proxy.
  • Optic observes the traffic as it passes through the proxy.
@acunniffe
acunniffe / changelog-select.ts
Created January 5, 2022 13:24
changelog-select.ts (tmp till open source next week)
import {
ConceptualLocation,
IChange,
IPathComponent,
OpenApiFact,
OpenApiKind,
OpenApiOperationFact,
OpenApiRequestParameterFact,
} from '../types';
import equals from 'lodash.isequal';
@acunniffe
acunniffe / docs.md
Last active December 1, 2021 17:03
Using "@useoptic/openapi-utilities" to produce changelogs

At Optic we work with a lot of different kinds of diffs. We call a diff between traffic and a spec, a "diff" and a diff between two versions of an OpenAPI document a "changelog"

Optic CI rules take advantage of this pipeline, which, also can support producing changelogs between any two OpenAPI files

  1. reads your disk / git repo to get the full spec, with all refs resolved
  2. compute facts about the API specification that are true, independent of formatting, ordering, etc. Notice how if you change the order of Operations in optic-ci there's no changelog, even though there's a git diff. This is essential to making a real changelog, that works across a variety of use cases
  3. facts are then compared to produce changes
  4. Optic CI Rules look for changes they care about and execute to give you results

If you stop at step 3, you have a changelog between the two files.

[{
"url": "https://api.stripe.com/v1/balance_transactions",
"method": "GET",
"request": {
"headers_shape_hash": "286b9d7d500fd5de10ce6614a011a8ec0ea38102",
"body": {
"content-type": "application/json",
"shape_hash": "421e6d804647dccef9e26bde65d120689ff2b28c"
}
},
What is the distribution of licesne fields?
Sampling 355 APIs
NONE : 276
Apache 2.0 : 15
MIT : 12
Apache 2.0 License : 3
Terms and Conditions : 2
Creative Commons : 2
@acunniffe
acunniffe / mattermost-learned-spec.json
Created May 5, 2019 22:38
Mattermost Spec (Learned from Tests)
This file has been truncated, but you can view the full file.
{
"swagger": "2.0",
"info": {
"title": "undefined/mattermost-api4",
"version": "2.0.0"
},
"basePath": "/api/v4",
"paths": {
"/actions/dialogs/open": {
"post": {
@acunniffe
acunniffe / mattermost-dereffed-oas.json
Created May 5, 2019 22:37
Mattermost OAS Dereffed
{
"swagger": "2.0",
"info": {
"description": "There is also a work-in-progress [Postman API reference](https://documenter.getpostman.com/view/4508214/RW8FERUn).\n",
"version": "4.0.0",
"title": "Mattermost API Reference",
"termsOfService": "https://about.mattermost.com/default-terms/",
"contact": {
"email": "[email protected]"
},
@acunniffe
acunniffe / gsn.c
Created March 5, 2019 01:10
Basic GSR Logger for Arduino
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
@acunniffe
acunniffe / gist:031caf85261a790b7406e1c0f5658605
Last active October 21, 2018 18:40
Glue Lang (Abstract)

Problems:

  • a lot of the complexity in modern programming comes from connecting various systems together & current paradigms aren't well suited for this kind of work
  • it's easy to share code, but much harder to package up & share features seamlessly

Key Idea: Compile graphs should be shared between projects so compilers can understand how to connect to the higher level interfaces a program exposes.

The Paradox

General purpose programming languages have a wide range of uses because they are built on foundational abstractions. But this flexibility comes at a cost: there's a lot of distance between those higher level abstractions that we deal with (APIs, queries, data models, streams, HTTP requests, etc) and the language itself. This distance is the reason it's ridiculously hard to do something like code completion or compile-time-feedback for a higher order construct like a request to a specific endpoint.

It's easy to code complete a function because it's represented by a FunctionNode in the A

Ambasador Joseph P. Kennedy Sr. + Rose Fitzgerald
- Joseph P Kennedy Jr.
- John F. Kennedy + Jackie Bouvier
- Amb. Caroline Kennedy
- JFK Jr.
- Rosemary Kennedy
- Kathleen Kennedy
- Eunice Kennedy + Amb. Sargent Shiver
- Maria Shiver
- Patricia Kennedy