Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
SwagColorCodingConfig
} from "../../developer-documentation-vitepress/src/shopware/config";

import {navigation as apisNavigation} from "./navigation/apis";

const sections: SwagSectionsConfig[] = [
{
title: 'Frontends',
Expand Down Expand Up @@ -298,7 +300,12 @@ export default defineConfigWithTheme<ThemeConfig>({
ignoreDeadLinks: true,

themeConfig: {
...navigation, // add sidebar and nav config
sidebar: {
...navigation.sidebar,
...apisNavigation,
},
nav: navigation.nav,
// ...navigation, // add sidebar and nav config

algolia: {
indexName: "beta-developer-shopware",
Expand Down
4 changes: 4 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import {SWAGTheme} from "vitepress-shopware-docs";
import SwagRadialBg from "../../src/components/SwagRadialBg.vue";
import OpenApi from "../../src/components/OpenApi.vue";

export default {
...SWAGTheme({
slots: {
'layout-bottom': [
SwagRadialBg,
]
},
enhanceApp({app}) {
app.component('OpenApi', OpenApi);
}
}),
}
38 changes: 37 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/[api]-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ $params.api }}

<!-- @content -->
14 changes: 14 additions & 0 deletions src/[api]-api.paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
paths() {
return [
{
params: {api: 'store'},
content: 'This is content',
},
{
params: {api: 'admin'},
content: 'This is custom content',
}
]
}
}
9 changes: 9 additions & 0 deletions src/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
aside: false
sidebar: false
---
<script setup lang="ts">
import OpenApiViewer from "./components/OpenAPIViewer.vue";
</script>

<OpenApiViewer />
9 changes: 9 additions & 0 deletions src/api/admin/endpoint/[method]-[path].md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# {{ $params.slug }}

<OpenApi api="admin" :endpoint="$params.path" :method="$params.method" />

Test: {{ $params.slug }}

{{ $params }}

<!-- @content -->
7 changes: 7 additions & 0 deletions src/api/admin/endpoint/[method]-[path].paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {makePaths} from "../../helpers";

export default {
paths() {
return makePaths('admin');
}
}
3 changes: 3 additions & 0 deletions src/api/admin/scheme/[slug].md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ $params.api }}

<!-- @content -->
14 changes: 14 additions & 0 deletions src/api/admin/scheme/[slug].paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
paths() {
return [
{
params: {slug: 'store'},
content: 'This is content',
},
{
params: {slug: 'admin'},
content: 'This is custom content',
}
]
}
}
30 changes: 30 additions & 0 deletions src/api/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import adminApi from "../components/adminapi.json";
import storeApi from "../components/storeapi.json";

export const makePaths = (api: string) => {
const data = {
admin: adminApi,
store: storeApi,
}[api] || null;

if (!data) {
throw "Incorrect api";
}

return Object.keys(adminApi.paths)
.reduce((reduced, path) => {
return Object.keys(adminApi.paths[path])
.reduce((reduced, method) => {
reduced.push({
path: path.split('/')
.splice(1)
.join('-')
.replace('{', '')
.replace('}', ''),
method: method.toLowerCase(),
});
return reduced;
}, reduced);
}, [])
.map(route => ({params: {...route,}, content: ''}))
}
3 changes: 3 additions & 0 deletions src/api/store/endpoint/[slug].md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ $params.api }}

<!-- @content -->
14 changes: 14 additions & 0 deletions src/api/store/endpoint/[slug].paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
paths() {
return [
{
params: {slug: 'store'},
content: 'This is content',
},
{
params: {slug: 'admin'},
content: 'This is custom content',
}
]
}
}
3 changes: 3 additions & 0 deletions src/api/store/scheme/[slug].md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ $params.api }}

<!-- @content -->
14 changes: 14 additions & 0 deletions src/api/store/scheme/[slug].paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default {
paths() {
return [
{
params: {slug: 'store'},
content: 'This is content',
},
{
params: {slug: 'admin'},
content: 'This is custom content',
}
]
}
}
Loading