hotfix: docs build (#198)

* fix: build

* fix: build

* fix: build

* fix: build
This commit is contained in:
Sebastian Rindom
2021-03-10 16:15:06 +01:00
committed by GitHub
parent 82d2c352b2
commit 1e5a1398d8
20 changed files with 12875 additions and 328 deletions
+29 -38
View File
@@ -1,47 +1,38 @@
import React, { useState, useEffect } from "react"
const useSpec = raw => {
const [tags, setTags] = useState({})
const [spec, setSpec] = useState({})
let tags = {}
useEffect(() => {
setSpec(raw)
for (const [path, methods] of Object.entries(raw.paths)) {
for (const [method, specification] of Object.entries(methods)) {
for (const t of specification.tags) {
setTags(ts => {
if (t in ts) {
return {
...ts,
[t]: [
...ts[t],
{
method: method.toUpperCase(),
path,
...specification,
},
],
}
} else {
return {
...ts,
[t]: [
{
method: method.toUpperCase(),
path,
...specification,
},
],
}
}
})
for (const [path, methods] of Object.entries(raw.paths)) {
for (const [method, specification] of Object.entries(methods)) {
for (const t of specification.tags) {
if (t in tags) {
tags = {
...tags,
[t]: [
...tags[t],
{
method: method.toUpperCase(),
path,
...specification,
},
],
}
} else {
tags = {
...tags,
[t]: [
{
method: method.toUpperCase(),
path,
...specification,
},
],
}
}
}
}
}, [])
}
return { tags, spec }
return { tags, spec: raw }
}
export default useSpec