Skip to content

Commit

Permalink
🚀 feat: add swagger ui/redoc documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
kms0219kms committed Nov 10, 2024
0 parents commit 209ba66
Show file tree
Hide file tree
Showing 19 changed files with 489 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"root": true,
"env": { "browser": true, "es2020": true },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:prettier/recommended"
],
"ignorePatterns": ["dist", ".eslintrc"],
"parser": "@typescript-eslint/parser",
"plugins": ["react-refresh", "prettier"],
"rules": {
"react-refresh/only-export-components": [
"warn",
{ "allowConstantExport": true }
],
"prettier/prettier": "error"
}
}
45 changes: 45 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Deploy to GitHub Pages

on:
push:
branches: ['web']

workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: 'pages'
cancel-in-progress: false

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup bun
uses: oven-sh/setup-bun@v1

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Install Required Libraries
run: bun install

- name: Build
run: bun run build

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
24 changes: 24 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# dependencies
/node_modules

# production
/dist

*.js
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "avoid",
"proseWrap": "never",
"endOfLine": "auto"
}
Binary file added bun.lockb
Binary file not shown.
29 changes: 29 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/variable/pretendardvariable-dynamic-subset.min.css" />
<link rel="stylesheet" href="https://font.elice.io/css?family=Elice+Digital+Coding" />

<title>Musixmatch OpenAPI - OAS 3.0</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>

<script>
;(function (l) {
if (l.search[1] === '/') {
var decoded = l.search
.slice(1)
.split('&')
.map(function (s) {
return s.replace(/~and~/g, '&')
})
.join('?')
window.history.replaceState(null, null, l.pathname.slice(0, -1) + decoded + l.hash)
}
})(window.location)
</script>
</body>
</html>
41 changes: 41 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "musixmatch-oas",
"private": true,
"version": "1.0.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@tanstack/react-query": "^5.18.1",
"core-js": "^3.35.1",
"gh-pages": "^6.1.1",
"mobx": "^6.12.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.0",
"redoc": "^2.1.3",
"styled-components": "^6.1.8",
"swagger-ui-dist": "^5.11.3",
"yaml": "^2.3.4"
},
"devDependencies": {
"@types/react": "^18.2.55",
"@types/react-dom": "^18.2.19",
"@types/swagger-ui-dist": "^3.30.4",
"@vitejs/plugin-react": "^4.2.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.5",
"prettier": "^3.2.5",
"typescript": "^5.3.3",
"vite": "^5.1.0",
"vite-plugin-html": "^3.2.2",
"vite-tsconfig-paths": "^4.3.1"
}
}
31 changes: 31 additions & 0 deletions public/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ayaan-fonts/[email protected]/fonts/webfonts/Paperlogy-dynamic-subset.css" />
<link rel="stylesheet" href="https://font.elice.io/css?family=Elice+Digital+Coding" />

<title>Musixmatch OpenAPI - OAS 3.0</title>
</head>
<body>
<script>
var pathSegmentsToKeep = 1

var l = window.location
l.replace(
l.protocol +
'//' +
l.hostname +
(l.port ? ':' + l.port : '') +
l.pathname
.split('/')
.slice(0, 1 + pathSegmentsToKeep)
.join('/') +
'/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash,
)
</script>
</body>
</html>
14 changes: 14 additions & 0 deletions public/swagger-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
configUrl: '/musixmatch-oas/swagger-config.yaml'

docExpansion: none
tagsSorter: alpha
operationsSorter: alpha
displayOperationId: false
persistAuthorization: true
displayRequestDuration: true

urls:
- url: 'https://raw.githubusercontent.com/lunaiz-corp/musixmatch-oas/main/openapi.yaml'
name: Version 1.1.0

validatorUrl: ''
28 changes: 28 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}

*,
*:before,
*:after {
box-sizing: inherit;
}

body {
margin: 0;
background: #fafafa;
}

body * {
font-family: 'Pretendard Variable', sans-serif !important;
}

code,
code *,
.redoc-wrap .redoc-json *,
.redoc-wrap .property-name,
.swagger-ui .opblock-summary-path * {
font-family: 'Elice Digital Coding', 'monospace' !important;
}
31 changes: 31 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import { createBrowserRouter, RouterProvider } from 'react-router-dom'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

import './index.css'
import { Swagger, Redocly } from './routes'

const queryClient = new QueryClient()

const router = createBrowserRouter(
[
{
path: '/',
element: <Swagger />,
},
{
path: '/redoc',
element: <Redocly />,
},
],
{ basename: '/musixmatch-oas' },
)

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
<React.StrictMode>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
</QueryClientProvider>
</React.StrictMode>,
)
2 changes: 2 additions & 0 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as Swagger } from './swagger'
export { default as Redocly } from './redocly'
Loading

0 comments on commit 209ba66

Please sign in to comment.