Skip to content

Commit 2d33c7f

Browse files
committedSep 22, 2022
Initial commit
0 parents  commit 2d33c7f

File tree

13 files changed

+4447
-0
lines changed

13 files changed

+4447
-0
lines changed
 

‎.eslintrc.cjs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
extends: [
4+
"plugin:prettier/recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
],
7+
plugins: ["eslint-plugin-simple-import-sort"],
8+
rules: {
9+
"@typescript-eslint/explicit-module-boundary-types": "off",
10+
"@typescript-eslint/no-explicit-any": "off",
11+
"prefer-const": ["error", { destructuring: "all" }],
12+
"simple-import-sort/imports": "error",
13+
"simple-import-sort/exports": "error",
14+
curly: ["error", "multi-line", "consistent"],
15+
"@typescript-eslint/no-unused-vars": [
16+
"error",
17+
{
18+
ignoreRestSiblings: true,
19+
varsIgnorePattern: "^_",
20+
argsIgnorePattern: "^_",
21+
},
22+
],
23+
},
24+
};

‎.github/actions/setup-node/action.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# see https://docs.github.com/en/actions/creating-actions/creating-a-composite-action#creating-an-action-metadata-file
2+
name: 'Setup Node'
3+
description: 'Setup node and install dependencies (with cache)'
4+
5+
inputs:
6+
node-version: # id of input
7+
description: 'What node version to use'
8+
required: false
9+
default: '18.x'
10+
11+
runs:
12+
using: 'composite'
13+
steps:
14+
- name: Setup Node ${{ inputs.node-version }}
15+
uses: actions/setup-node@v3
16+
with:
17+
node-version: ${{ inputs.node-version }}
18+
19+
- name: Cache node modules
20+
id: cache
21+
uses: actions/cache@v2
22+
with:
23+
path: node_modules
24+
key: ${{ runner.os }}-node_modules-${{ hashFiles('yarn.lock') }}
25+
26+
- name: Install Dependencies
27+
if: steps.cache.outputs.cache-hit != 'true'
28+
shell: bash
29+
run: yarn --frozen-lockfile

‎.github/workflows/openapi.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: openapi
2+
on: [push]
3+
4+
jobs:
5+
validate:
6+
runs-on: ubuntu-latest
7+
8+
steps:
9+
- uses: actions/checkout@v3
10+
- name: setup node
11+
uses: ./.github/actions/setup-node
12+
- name: validate openapi spec
13+
run: yarn validate

‎.gitignore

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port

‎.husky/pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged
5+
yarn validate

‎.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"tabWidth": 2,
6+
"semi": true
7+
}

‎LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 MagicBell
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

‎README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# MagicBell's OpenAPI Specification
2+
3+
This repository contains [OpenAPI specifications][openapi] for the MagicBell REST API.
4+
5+
[Changelog](https://github.com/magicbell/openapi/releases/)
6+
7+
8+
Files can be found in the [/spec](/spec) directory:
9+
10+
* `openapi.json,yaml:` OpenAPI 3.0 spec matching the public MagicBell API.
11+
12+
## Development
13+
14+
Run the test suite:
15+
16+
```shell
17+
# clone the repo
18+
git clone git@github.com:magicbell-io/openapi.git
19+
cd openapi
20+
21+
# install dependencies
22+
yarn
23+
24+
# validate the current spec
25+
yarn validate
26+
```
27+
28+
## Code Quality
29+
30+
We're using pre-commit hooks to maintain consistency in code style for scripts in [/scripts](/scripts), and to verify
31+
that the openapi spec is valid according to openapi schemas. Please keep them enabled.
32+
33+
[openapi]: https://www.openapis.org/

‎package.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "openapi",
3+
"version": "1.0.0",
4+
"description": "An OpenAPI specification for the MagicBell API",
5+
"repository": "git@github.com:magicbell-io/openapi.git",
6+
"author": "Stephan Meijer <stephan.meijer@gmail.com>",
7+
"license": "MIT",
8+
"private": true,
9+
"type": "module",
10+
"scripts": {
11+
"validate": "tsx scripts/validate.ts",
12+
"prepare": "husky install",
13+
"lint": "eslint --fix ."
14+
},
15+
"lint-staged": {
16+
"*.{md,json,yml,yaml}": [
17+
"prettier -w"
18+
],
19+
"*.{js,jsx,ts,tsx}": [
20+
"eslint --fix"
21+
]
22+
},
23+
"dependencies": {
24+
"@apidevtools/swagger-parser": "^10.1.0",
25+
"@types/node": "^18.7.18",
26+
"@typescript-eslint/eslint-plugin": "^5.38.0",
27+
"@typescript-eslint/parser": "^5.38.0",
28+
"ast-types": "^0.14.2",
29+
"eslint": "^8.23.1",
30+
"eslint-config-prettier": "^8.5.0",
31+
"eslint-plugin-prettier": "^4.2.1",
32+
"eslint-plugin-simple-import-sort": "^8.0.0",
33+
"husky": "^8.0.0",
34+
"json5": "^2.2.1",
35+
"lint-staged": "^13.0.3",
36+
"openapi-types": "^12.0.2",
37+
"prettier": "^2.7.1",
38+
"recast": "^0.21.2",
39+
"tsx": "^3.9.0",
40+
"typescript": "^4.8.3",
41+
"zx": "^7.0.8"
42+
}
43+
}

‎scripts/validate.ts

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env zx
2+
import 'zx/globals';
3+
4+
import swagger from '@apidevtools/swagger-parser';
5+
6+
const showHelp = argv.help;
7+
const specFile = argv.spec || 'spec/openapi.json';
8+
9+
if (showHelp) {
10+
console.log('Usage: yarn validate [--spec <spec-file>]');
11+
process.exit(0);
12+
}
13+
14+
try {
15+
const spec = await fs.readJSON(path.resolve(specFile));
16+
const { info } = await swagger.validate(spec as any);
17+
console.log(`API name: ${info.title}, version: ${info.version}`);
18+
} catch (error) {
19+
console.error(`Error: ${specFile} did not pass swagger validation!`, error.message);
20+
}

‎spec/openapi.json

+2,323
Large diffs are not rendered by default.

‎tsconfig.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ESNext",
4+
"module": "ESNext",
5+
"resolveJsonModule": true,
6+
"moduleResolution": "node",
7+
"allowSyntheticDefaultImports": true
8+
}
9+
}

‎yarn.lock

+1,816
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.