Skip to content

Instantly share code, notes, and snippets.

@ikenna
ikenna / gist:22fcd79c76f0490326d2c61e2268be91
Last active February 5, 2024 13:14
Cursor based pagination
openapi: 3.0.0
info:
title: Cursor Pagination API
version: 1.0.0
paths:
/items:
get:
summary: Get a list of items
parameters:
- name: cursor
@ikenna
ikenna / only_one_2xx_response.js
Last active January 10, 2024 13:16
Redocly Linting rule to ensure that each operation has only one 2xx response.' (Generated from HuggingChat)
const { RuleTester } = require('eslint');
const openApiParser = require('openapi-parser');
// Define the linting rule
const rule = {
meta: {
docs: {
description: 'Ensure an API operation has at most one 2xx response',
category: 'Best Practices',
recommended: true,
@ikenna
ikenna / gist:37fa024a59ddf83a98ee45eeea144ed0
Last active June 5, 2023 14:33
Node script to ist files in a directory
const fs = require('fs');
const path = require('path');
function printFileNames(directory) {
fs.readdir(directory, (err, files) => {
if (err) {
console.error(`Error reading directory: ${err}`);
return;
}
@ikenna
ikenna / extract-endpoints.js
Created June 5, 2023 13:02
Extract endpoints from OpenAPI YAML file
const fs = require('fs');
const yaml = require('js-yaml');
function listEndpoints(openapiFile) {
try {
const openapiData = yaml.safeLoad(fs.readFileSync(openapiFile, 'utf8'));
const paths = openapiData.paths || {};
const endpoints = [];
for (const path in paths) {
# API Design Guidelines
# Introduction
The PayPal platform is a collection of reusable services that encapsulate well-defined business capabilities. Developers are encouraged to access these capabilities through Application Programming Interfaces (APIs) that enable consistent design patterns and principles. This facilitates a great developer experience and the ability to quickly compose complex business processes by combining multiple, complementary capabilities as building blocks.
PayPal APIs follow the [RESTful][0] architectural style as much as possible. To support our objectives, we have developed a set of rules, standards, and conventions that apply to the design of RESTful APIs. These have been used to help design and maintain hundreds of APIs and have evolved over several years to meet the needs of a wide variety of use cases.
We are sharing these guidelines to help propagate good API design practices in general. We have pulled extensively from the broader community and believe that it is importan
# Copied from https://github.com/columbia-it/django-jsonapi-training/blob/master/docs/schemas/openapi.yaml
openapi: 3.0.2
info:
version: 1.2.0
title: myapp
description: '![alt-text](https://cuit.columbia.edu/sites/default/files/logo/CUIT_Logo_286_web.jpg
"CUIT logo")
@ikenna
ikenna / jsonapi_oas.yml
Created September 8, 2022 05:12 — forked from naesean/jsonapi_oas.yml
OpenAPI 3.0 schemas that comply with the JSON:API 1.0 specification
JSONAPIObject:
description: Includes the current JSON:API version for this specification as well as optional meta information
type: object
required:
- version
properties:
version:
type: string
default: '1.0'
example: '1.0'
@ikenna
ikenna / api-product-profile.md
Last active December 31, 2021 19:04
API product profile example

Text Message API Product

No Aspect Description
1 API consumers Developers building enterprise applications that send text messages.
2 Core benefit Enables API consumers send and receive text messages.
3 Business capabilities 1) Send messags 2) Receive messages 3) Manage contacts 4) Query metadata information on sent and received messags 5) Create message templates
4 API product manger John Smith
5 API solution REST API. Connects to the Messaging, Contacts, Notification and Template microservices.
Tue Apr 7 19:37:54 UTC 2020

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x