Skip to content

Commit

Permalink
chore: update vitepress-theme-openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
enzonotario committed Sep 13, 2024
1 parent e0aad91 commit d1fe041
Show file tree
Hide file tree
Showing 28 changed files with 2,052 additions and 2,098 deletions.
7 changes: 2 additions & 5 deletions .vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { URL, fileURLToPath } from 'node:url'
import { defineConfig } from 'vitepress'
import { useSidebar, useOpenapi } from 'vitepress-theme-openapi'
import { useSidebar } from 'vitepress-theme-openapi'
import { collect } from 'collect.js'
import regions from './regions.json' assert { type: 'json' }
import spec from '../public/argentina/openapi.json' assert { type: 'json' }

const openapi = useOpenapi()
openapi.setSpec(spec)

const sidebar = useSidebar()
const sidebar = useSidebar({ spec })

function addRegionPrefixToSidebarItems(prefix, items) {
return {
Expand Down
6 changes: 1 addition & 5 deletions .vitepress/scripts/templates/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/REPLACE_REGION/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
28 changes: 10 additions & 18 deletions .vitepress/scripts/templates/operations/[operationId].paths.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { useOpenapi } from 'vitepress-theme-openapi'
import { OpenApi } from 'vitepress-theme-openapi'
import spec from '../../public/REPLACE_REGION/openapi.json' assert { type: 'json' }

export default {
paths() {
const openapi = useOpenapi()
openapi.setSpec(spec)
const openapi = OpenApi({ spec })

if (!openapi?.spec?.paths) {
return []
}

return Object.keys(openapi.spec.paths)
.map((path) => {
const { operationId } = openapi.spec.paths[path].get
const summary = openapi.spec.paths[path].get.summary
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
return openapi.getPathsByVerbs().map(({ operationId, summary }) => {
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
},
}
2 changes: 2 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default {
enhanceApp({ app, router, siteData }) {
const themeConfig = useTheme()
themeConfig.setLocale('es')
themeConfig.setJsonViewerDeep(1)
themeConfig.setSchemaViewerDeep(1)

theme.enhanceApp({ app })
}
Expand Down
6 changes: 1 addition & 5 deletions argentina/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/argentina/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
28 changes: 10 additions & 18 deletions argentina/operations/[operationId].paths.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { useOpenapi } from 'vitepress-theme-openapi'
import { OpenApi } from 'vitepress-theme-openapi'
import spec from '../../public/argentina/openapi.json' assert { type: 'json' }

export default {
paths() {
const openapi = useOpenapi()
openapi.setSpec(spec)
const openapi = OpenApi({ spec })

if (!openapi?.spec?.paths) {
return []
}

return Object.keys(openapi.spec.paths)
.map((path) => {
const { operationId } = openapi.spec.paths[path].get
const summary = openapi.spec.paths[path].get.summary
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
return openapi.getPathsByVerbs().map(({ operationId, summary }) => {
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
},
}
6 changes: 1 addition & 5 deletions bolivia/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/bolivia/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
28 changes: 10 additions & 18 deletions bolivia/operations/[operationId].paths.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { useOpenapi } from 'vitepress-theme-openapi'
import { OpenApi } from 'vitepress-theme-openapi'
import spec from '../../public/bolivia/openapi.json' assert { type: 'json' }

export default {
paths() {
const openapi = useOpenapi()
openapi.setSpec(spec)
const openapi = OpenApi({ spec })

if (!openapi?.spec?.paths) {
return []
}

return Object.keys(openapi.spec.paths)
.map((path) => {
const { operationId } = openapi.spec.paths[path].get
const summary = openapi.spec.paths[path].get.summary
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
return openapi.getPathsByVerbs().map(({ operationId, summary }) => {
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
},
}
6 changes: 1 addition & 5 deletions brazil/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/brazil/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
28 changes: 10 additions & 18 deletions brazil/operations/[operationId].paths.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { useOpenapi } from 'vitepress-theme-openapi'
import { OpenApi } from 'vitepress-theme-openapi'
import spec from '../../public/brazil/openapi.json' assert { type: 'json' }

export default {
paths() {
const openapi = useOpenapi()
openapi.setSpec(spec)
const openapi = OpenApi({ spec })

if (!openapi?.spec?.paths) {
return []
}

return Object.keys(openapi.spec.paths)
.map((path) => {
const { operationId } = openapi.spec.paths[path].get
const summary = openapi.spec.paths[path].get.summary
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
return openapi.getPathsByVerbs().map(({ operationId, summary }) => {
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
},
}
6 changes: 1 addition & 5 deletions chile/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/chile/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
28 changes: 10 additions & 18 deletions chile/operations/[operationId].paths.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { useOpenapi } from 'vitepress-theme-openapi'
import { OpenApi } from 'vitepress-theme-openapi'
import spec from '../../public/chile/openapi.json' assert { type: 'json' }

export default {
paths() {
const openapi = useOpenapi()
openapi.setSpec(spec)
const openapi = OpenApi({ spec })

if (!openapi?.spec?.paths) {
return []
}

return Object.keys(openapi.spec.paths)
.map((path) => {
const { operationId } = openapi.spec.paths[path].get
const summary = openapi.spec.paths[path].get.summary
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
return openapi.getPathsByVerbs().map(({ operationId, summary }) => {
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
},
}
6 changes: 1 addition & 5 deletions colombia/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/colombia/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
28 changes: 10 additions & 18 deletions colombia/operations/[operationId].paths.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
import { useOpenapi } from 'vitepress-theme-openapi'
import { OpenApi } from 'vitepress-theme-openapi'
import spec from '../../public/colombia/openapi.json' assert { type: 'json' }

export default {
paths() {
const openapi = useOpenapi()
openapi.setSpec(spec)
const openapi = OpenApi({ spec })

if (!openapi?.spec?.paths) {
return []
}

return Object.keys(openapi.spec.paths)
.map((path) => {
const { operationId } = openapi.spec.paths[path].get
const summary = openapi.spec.paths[path].get.summary
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
return openapi.getPathsByVerbs().map(({ operationId, summary }) => {
return {
params: {
operationId,
pageTitle: `${summary} - CriptoYa API`,
},
}
})
},
}
6 changes: 1 addition & 5 deletions mexico/operations/[operationId].md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ title: vitepress-theme-openapi

<script setup lang="ts">
import { useRoute, useData } from 'vitepress'
import { useOpenapi } from 'vitepress-theme-openapi'
import spec from '../../public/mexico/openapi.json'

const route = useRoute()

const { isDark } = useData()

const openapi = useOpenapi()
openapi.setSpec(spec)

const operationId = route.data.params.operationId
</script>

<OAOperation :operationId="operationId" :isDark="isDark"></OAOperation>
<OAOperation :spec="spec" :operationId="operationId" :isDark="isDark"></OAOperation>
Loading

0 comments on commit d1fe041

Please sign in to comment.