hotfix: docs build (#198)
* fix: build * fix: build * fix: build * fix: build
This commit is contained in:
+29
-38
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user