-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
944c09e
commit ed9ff1a
Showing
26 changed files
with
618 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Playwright Tests | ||
on: | ||
push: | ||
branches: [ main, develop ] | ||
pull_request: | ||
branches: [ main, develop ] | ||
jobs: | ||
test: | ||
timeout-minutes: 60 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v4.0.0 | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build vitepress-openapi | ||
run: pnpm build | ||
|
||
- name: Install Playwright Browsers | ||
run: pnpm exec playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
run: pnpm exec playwright test | ||
|
||
- uses: actions/upload-artifact@v4 | ||
if: always() | ||
with: | ||
name: playwright-report | ||
path: | | ||
playwright-report/ | ||
test-results/ | ||
retention-days: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
dist | ||
.temp | ||
cache | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { fileURLToPath } from 'node:url' | ||
import { defineConfig } from 'vitepress' | ||
import { useSidebar } from 'vitepress-openapi' | ||
import spec from '../../../../docs/public/openapi.json' | ||
|
||
const sidebar = useSidebar({ | ||
spec, | ||
// Optionally, you can specify a link prefix for all generated sidebar items. | ||
linkPrefix: '/operations/', | ||
}) | ||
|
||
// refer https://vitepress.dev/reference/site-config for details | ||
export default defineConfig({ | ||
lang: 'en-US', | ||
title: 'VitePress OpenAPI', | ||
description: 'Generate documentation from OpenAPI specifications.', | ||
|
||
themeConfig: { | ||
nav: [{ text: 'API Reference', link: '/introduction' }], | ||
|
||
sidebar: [ | ||
{ | ||
text: 'By Tags', | ||
items: [ | ||
{ | ||
text: 'Introduction', | ||
link: '/introduction', | ||
}, | ||
...sidebar.itemsByTags(), | ||
], | ||
}, | ||
{ | ||
text: 'By Operations', | ||
items: [ | ||
...sidebar.generateSidebarGroups(), | ||
], | ||
}, | ||
{ | ||
text: 'By Paths', | ||
items: [ | ||
...sidebar.itemsByPaths(), | ||
], | ||
}, | ||
{ | ||
text: 'One Page', | ||
items: [ | ||
{ text: 'One Page', link: '/one-page' }, | ||
{ text: 'Without Sidebar', link: '/without-sidebar' }, | ||
], | ||
}, | ||
], | ||
}, | ||
|
||
vite: { | ||
resolve: { | ||
alias: { | ||
...(process.env.NODE_ENV === 'production' | ||
? {} | ||
: { | ||
'vitepress-openapi/client': fileURLToPath(new URL('../../../../src/client', import.meta.url)), | ||
'vitepress-openapi/dist/style.css': fileURLToPath(new URL('../../../../dist/vitepress-openapi.css', import.meta.url)), | ||
'vitepress-openapi': fileURLToPath(new URL('../../../../src/index', import.meta.url)), | ||
'@public': fileURLToPath(new URL('../../../../docs/public', import.meta.url)), | ||
}), | ||
}, | ||
}, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { Theme } from 'vitepress' | ||
import spec from '@public/openapi.json' | ||
|
||
import { theme, useOpenapi } from 'vitepress-openapi/client' | ||
import DefaultTheme from 'vitepress/theme' | ||
import 'vitepress-openapi/dist/style.css' | ||
|
||
export default { | ||
...DefaultTheme, | ||
async enhanceApp({ app, router, siteData }) { | ||
const openapi = useOpenapi({ | ||
spec, | ||
config: {}, | ||
}) | ||
|
||
theme.enhanceApp({ app, openapi }) | ||
}, | ||
} satisfies Theme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
layout: home | ||
|
||
hero: | ||
name: "VitePress OpenAPI" | ||
tagline: "Generate documentation from OpenAPI specifications." | ||
actions: | ||
- theme: brand | ||
text: API Reference | ||
link: /introduction | ||
- theme: alt | ||
text: Documentation | ||
link: https://vitepress-openapi.vercel.app/ | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
title: vitepress-openapi | ||
--- | ||
|
||
<OAInfo /> | ||
|
||
<OAServers /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
aside: false | ||
title: vitepress-openapi | ||
--- | ||
|
||
<script setup lang="ts"> | ||
import { useData } from 'vitepress' | ||
|
||
const { isDark } = useData() | ||
</script> | ||
|
||
<OASpec :isDark="isDark" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
aside: false | ||
outline: false | ||
title: vitepress-openapi | ||
--- | ||
|
||
<script setup lang="ts"> | ||
import { useRoute, useData } from 'vitepress' | ||
|
||
const route = useRoute() | ||
|
||
const { isDark } = useData() | ||
|
||
const operationId = route.data.params.operationId | ||
</script> | ||
|
||
<OAOperation :operationId="operationId" :isDark="isDark" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { usePaths } from 'vitepress-openapi' | ||
import spec from '../../../../docs/public/openapi.json' | ||
|
||
export default { | ||
paths() { | ||
return usePaths({ spec }) | ||
.getPathsByVerbs() | ||
.map(({ operationId, summary }) => { | ||
return { | ||
params: { | ||
operationId, | ||
pageTitle: `${summary} - vitepress-openapi`, | ||
}, | ||
} | ||
}) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
aside: false | ||
outline: false | ||
title: vitepress-openapi | ||
--- | ||
|
||
<script setup lang="ts"> | ||
import { useRoute, useData } from 'vitepress' | ||
|
||
const route = useRoute() | ||
|
||
const { isDark } = useData() | ||
|
||
const tag = route.data.params.tag | ||
</script> | ||
|
||
<OASpec :tags="[tag]" :isDark="isDark" hide-info hide-servers hide-paths-summary /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { usePaths } from 'vitepress-openapi' | ||
import spec from '../../../../docs/public/openapi.json' | ||
|
||
export default { | ||
paths() { | ||
return usePaths({ spec }) | ||
.getTags() | ||
.map(({ name }) => { | ||
return { | ||
params: { | ||
tag: name, | ||
pageTitle: `${name} - vitepress-openapi`, | ||
}, | ||
} | ||
}) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
sidebar: false | ||
aside: true | ||
outline: [1, 2] | ||
title: vitepress-openapi | ||
--- | ||
|
||
<script setup lang="ts"> | ||
import { useData } from 'vitepress' | ||
import spec from '@public/openapi.json' | ||
const { isDark } = useData() | ||
</script> | ||
|
||
<OASpec :spec="spec" :isDark="isDark" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vitepress dev docs", | ||
"build": "vitepress build docs", | ||
"preview": "vitepress preview docs", | ||
"start": "vitepress dev docs" | ||
}, | ||
"devDependencies": { | ||
"vitepress": "^1.6.3", | ||
"vitepress-openapi": "workspace:*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('home', async ({ page }) => { | ||
await page.goto('/') | ||
|
||
await expect(page).toHaveTitle(/VitePress OpenAPI/) | ||
await expect(page).toHaveScreenshot({ | ||
fullPage: true, | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('one-page', async ({ page }) => { | ||
await page.goto('/one-page') | ||
|
||
await expect(page).toHaveScreenshot({ | ||
fullPage: true, | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
const port = 4173 | ||
|
||
const url = `http://localhost:${port}` | ||
|
||
export default defineConfig({ | ||
testDir: './e2e', | ||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
/* Fail the build on CI if you accidentally left test.only in the source code. */ | ||
forbidOnly: !!process.env.CI, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
/* Opt out of parallel tests on CI. */ | ||
workers: process.env.CI ? 1 : undefined, | ||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */ | ||
reporter: 'html', | ||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
baseURL: url, | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
timeout: 60 * 1000, | ||
expect: { | ||
timeout: 30 * 1000, | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
|
||
{ | ||
name: 'firefox', | ||
use: { ...devices['Desktop Firefox'] }, | ||
}, | ||
|
||
// { | ||
// name: 'webkit', | ||
// use: { ...devices['Desktop Safari'] }, | ||
// }, | ||
|
||
/* Test against mobile viewports. */ | ||
// { | ||
// name: 'Mobile Chrome', | ||
// use: { ...devices['Pixel 5'] }, | ||
// }, | ||
// { | ||
// name: 'Mobile Safari', | ||
// use: { ...devices['iPhone 12'] }, | ||
// }, | ||
|
||
/* Test against branded browsers. */ | ||
// { | ||
// name: 'Microsoft Edge', | ||
// use: { ...devices['Desktop Edge'], channel: 'msedge' }, | ||
// }, | ||
// { | ||
// name: 'Google Chrome', | ||
// use: { ...devices['Desktop Chrome'], channel: 'chrome' }, | ||
// }, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
webServer: { | ||
command: 'pnpm e2e:dev', | ||
port, | ||
reuseExistingServer: !process.env.CI, | ||
}, | ||
}) |
Oops, something went wrong.