docs: add prepare script to generate sidebar (#11894)
This commit is contained in:
1 parent
eb2aa8da3c
commit
9ead47c51e
72 files changed
+1709
-295
No files matched your search
@@ -1,11 +1,11 @@
|
||||
"use server"
|
||||
|
||||
import type { OpenAPIV3 } from "openapi-types"
|
||||
import type { OpenAPI } from "types"
|
||||
import Section from "../Section"
|
||||
import MDXContentServer from "../MDXContent/Server"
|
||||
|
||||
export type DescriptionProps = {
|
||||
specs: OpenAPIV3.Document
|
||||
specs: OpenAPI.OpenAPIV3.Document
|
||||
}
|
||||
|
||||
const Description = ({ specs }: DescriptionProps) => {
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
"use client"
|
||||
|
||||
import { useScrollController, useSidebar, H2 as UiH2 } from "docs-ui"
|
||||
import { getSectionId } from "docs-utils"
|
||||
import { useEffect, useMemo, useRef, useState } from "react"
|
||||
import getSectionId from "../../../utils/get-section-id"
|
||||
import { Sidebar } from "types"
|
||||
|
||||
type H2Props = React.HTMLAttributes<HTMLHeadingElement>
|
||||
|
||||
const H2 = ({ children, ...props }: H2Props) => {
|
||||
const headingRef = useRef<HTMLHeadingElement>(null)
|
||||
const { activePath, addItems, removeItems, shownSidebar } = useSidebar()
|
||||
const { activePath } = useSidebar()
|
||||
const { scrollableElement, scrollToElement } = useScrollController()
|
||||
const [scrolledFirstTime, setScrolledFirstTime] = useState(false)
|
||||
|
||||
@@ -28,30 +27,6 @@ const H2 = ({ children, ...props }: H2Props) => {
|
||||
setScrolledFirstTime(scrolledFirstTime)
|
||||
}, [scrollableElement, headingRef, id])
|
||||
|
||||
useEffect(() => {
|
||||
if (!shownSidebar) {
|
||||
return
|
||||
}
|
||||
const items: Sidebar.SidebarItem[] = [
|
||||
{
|
||||
type: "link",
|
||||
path: `${id}`,
|
||||
title: children as string,
|
||||
loaded: true,
|
||||
},
|
||||
]
|
||||
addItems(items, {
|
||||
sidebar_id: shownSidebar.sidebar_id,
|
||||
})
|
||||
|
||||
return () => {
|
||||
removeItems({
|
||||
items,
|
||||
sidebar_id: shownSidebar.sidebar_id,
|
||||
})
|
||||
}
|
||||
}, [id, shownSidebar?.sidebar_id])
|
||||
|
||||
return (
|
||||
<UiH2 {...props} id={id} passRef={headingRef}>
|
||||
{children}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { MDXContentClientProps } from "@/components/MDXContent/Client"
|
||||
import type { MDXContentServerProps } from "@/components/MDXContent/Server"
|
||||
import type { SecuritySchemeObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import getSecuritySchemaTypeName from "@/utils/get-security-schema-type-name"
|
||||
import clsx from "clsx"
|
||||
import { Loading } from "docs-ui"
|
||||
@@ -21,7 +21,7 @@ const MDXContentServer = dynamic<MDXContentServerProps>(
|
||||
) as React.FC<MDXContentServerProps>
|
||||
|
||||
export type SecurityDescriptionProps = {
|
||||
securitySchema: SecuritySchemeObject
|
||||
securitySchema: OpenAPI.SecuritySchemeObject
|
||||
isServer?: boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import dynamic from "next/dynamic"
|
||||
import type { OpenAPIV3 } from "openapi-types"
|
||||
import type { OpenAPI } from "types"
|
||||
import type { SecurityDescriptionProps } from "./Description"
|
||||
import { Fragment } from "react"
|
||||
|
||||
@@ -8,7 +8,7 @@ const SecurityDescription = dynamic<SecurityDescriptionProps>(
|
||||
) as React.FC<SecurityDescriptionProps>
|
||||
|
||||
type SecurityProps = {
|
||||
specs?: OpenAPIV3.Document
|
||||
specs?: OpenAPI.OpenAPIV3.Document
|
||||
}
|
||||
|
||||
const Security = ({ specs }: SecurityProps) => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { MDXComponents } from "mdx/types"
|
||||
import Security from "./Security"
|
||||
import type { OpenAPIV3 } from "openapi-types"
|
||||
import type { OpenAPI } from "types"
|
||||
import H2 from "./H2"
|
||||
import { Link, MDXComponents as UiMDXComponents } from "docs-ui"
|
||||
|
||||
export type ScopeType = {
|
||||
specs?: OpenAPIV3.Document
|
||||
specs?: OpenAPI.OpenAPIV3.Document
|
||||
addToSidebar?: boolean
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import type { Code } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import { CodeBlock, CodeTab, CodeTabs } from "docs-ui"
|
||||
import slugify from "slugify"
|
||||
|
||||
export type TagOperationCodeSectionRequestSamplesProps = {
|
||||
codeSamples: Code[]
|
||||
codeSamples: OpenAPI.Code[]
|
||||
}
|
||||
|
||||
const TagOperationCodeSectionRequestSamples = ({
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
import { CodeBlock } from "docs-ui"
|
||||
import type { ExampleObject, ResponseObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import { useEffect, useState } from "react"
|
||||
import useSchemaExample from "../../../../../../hooks/use-schema-example"
|
||||
|
||||
export type TagsOperationCodeSectionResponsesSampleProps = {
|
||||
response: ResponseObject
|
||||
response: OpenAPI.ResponseObject
|
||||
} & React.AllHTMLAttributes<HTMLDivElement>
|
||||
|
||||
const TagsOperationCodeSectionResponsesSample = ({
|
||||
@@ -20,7 +20,7 @@ const TagsOperationCodeSectionResponsesSample = ({
|
||||
schemaExamples: contentSchema?.examples,
|
||||
})
|
||||
const [selectedExample, setSelectedExample] = useState<
|
||||
ExampleObject | undefined
|
||||
OpenAPI.ExampleObject | undefined
|
||||
>()
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Operation } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagsOperationCodeSectionResponsesSampleProps } from "./Sample"
|
||||
import { Badge } from "docs-ui"
|
||||
@@ -9,7 +9,7 @@ const TagsOperationCodeSectionResponsesSample =
|
||||
) as React.FC<TagsOperationCodeSectionResponsesSampleProps>
|
||||
|
||||
type TagsOperationCodeSectionResponsesProps = {
|
||||
operation: Operation
|
||||
operation: OpenAPI.Operation
|
||||
}
|
||||
|
||||
const TagsOperationCodeSectionResponses = ({
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import MethodLabel from "@/components/MethodLabel"
|
||||
import type { Operation } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import TagsOperationCodeSectionResponses from "./Responses"
|
||||
import type { TagOperationCodeSectionRequestSamplesProps } from "./RequestSamples"
|
||||
import dynamic from "next/dynamic"
|
||||
@@ -15,7 +15,7 @@ const TagOperationCodeSectionRequestSamples =
|
||||
) as React.FC<TagOperationCodeSectionRequestSamplesProps>
|
||||
|
||||
export type TagOperationCodeSectionProps = {
|
||||
operation: Operation
|
||||
operation: OpenAPI.Operation
|
||||
method: string
|
||||
endpointPath: string
|
||||
} & React.HTMLAttributes<HTMLDivElement>
|
||||
|
||||
+5
-5
@@ -1,24 +1,24 @@
|
||||
import type { Parameter, SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import TagOperationParameters from "../../Parameters"
|
||||
|
||||
export type TagsOperationDescriptionSectionParametersProps = {
|
||||
parameters: Parameter[]
|
||||
parameters: OpenAPI.Parameter[]
|
||||
}
|
||||
|
||||
const TagsOperationDescriptionSectionParameters = ({
|
||||
parameters,
|
||||
}: TagsOperationDescriptionSectionParametersProps) => {
|
||||
const pathParameters: SchemaObject = {
|
||||
const pathParameters: OpenAPI.SchemaObject = {
|
||||
type: "object",
|
||||
required: [],
|
||||
properties: {},
|
||||
}
|
||||
const queryParameters: SchemaObject = {
|
||||
const queryParameters: OpenAPI.SchemaObject = {
|
||||
type: "object",
|
||||
required: [],
|
||||
properties: {},
|
||||
}
|
||||
const headerParameters: SchemaObject = {
|
||||
const headerParameters: OpenAPI.SchemaObject = {
|
||||
type: "object",
|
||||
required: [],
|
||||
properties: {},
|
||||
|
||||
+2
-2
@@ -1,9 +1,9 @@
|
||||
import type { RequestObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import TagOperationParameters from "../../Parameters"
|
||||
import { DetailsSummary } from "docs-ui"
|
||||
|
||||
export type TagsOperationDescriptionSectionRequestProps = {
|
||||
requestBody: RequestObject
|
||||
requestBody: OpenAPI.RequestObject
|
||||
}
|
||||
|
||||
const TagsOperationDescriptionSectionRequest = ({
|
||||
|
||||
+2
-2
@@ -1,11 +1,11 @@
|
||||
import type { ResponsesObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import clsx from "clsx"
|
||||
import TagOperationParameters from "../../Parameters"
|
||||
import { Fragment } from "react"
|
||||
import { Badge, Details, DetailsSummary } from "docs-ui"
|
||||
|
||||
export type TagsOperationDescriptionSectionResponsesProps = {
|
||||
responses: ResponsesObject
|
||||
responses: OpenAPI.ResponsesObject
|
||||
}
|
||||
|
||||
const TagsOperationDescriptionSectionResponses = ({
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
import { useBaseSpecs } from "@/providers/base-specs"
|
||||
import type { OpenAPIV3 } from "openapi-types"
|
||||
import type { OpenAPI } from "types"
|
||||
import { Card } from "docs-ui"
|
||||
import { useMemo } from "react"
|
||||
|
||||
export type TagsOperationDescriptionSectionSecurityProps = {
|
||||
security: OpenAPIV3.SecurityRequirementObject[]
|
||||
security: OpenAPI.OpenAPIV3.SecurityRequirementObject[]
|
||||
}
|
||||
|
||||
const TagsOperationDescriptionSectionSecurity = ({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import type { Operation } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import type { TagsOperationDescriptionSectionSecurityProps } from "./Security"
|
||||
import type { TagsOperationDescriptionSectionRequestProps } from "./RequestBody"
|
||||
import type { TagsOperationDescriptionSectionResponsesProps } from "./Responses"
|
||||
@@ -33,7 +33,7 @@ const TagsOperationDescriptionSectionWorkflowBadge =
|
||||
) as React.FC<TagsOperationDescriptionSectionWorkflowBadgeProps>
|
||||
|
||||
type TagsOperationDescriptionSectionProps = {
|
||||
operation: Operation
|
||||
operation: OpenAPI.Operation
|
||||
}
|
||||
const TagsOperationDescriptionSection = ({
|
||||
operation,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import MDXContentClient from "@/components/MDXContent/Client"
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import clsx from "clsx"
|
||||
import dynamic from "next/dynamic"
|
||||
import { Fragment } from "react"
|
||||
@@ -10,7 +10,7 @@ const InlineCode = dynamic<InlineCodeProps>(
|
||||
) as React.FC<InlineCodeProps>
|
||||
|
||||
type TagOperationParametersDescriptionProps = {
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
}
|
||||
|
||||
const TagOperationParametersDescription = ({
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import { Badge, ExpandableNotice, FeatureFlagNotice } from "docs-ui"
|
||||
import { Fragment } from "react"
|
||||
|
||||
export type TagOperationParametersNameProps = {
|
||||
name: string
|
||||
isRequired?: boolean
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
}
|
||||
|
||||
const TagOperationParametersName = ({
|
||||
@@ -94,7 +94,7 @@ const TagOperationParametersName = ({
|
||||
|
||||
export default TagOperationParametersName
|
||||
|
||||
function formatArrayDescription(schema?: SchemaObject) {
|
||||
function formatArrayDescription(schema?: OpenAPI.SchemaObject) {
|
||||
if (!schema) {
|
||||
return "Array"
|
||||
}
|
||||
@@ -107,7 +107,7 @@ function formatArrayDescription(schema?: SchemaObject) {
|
||||
return `Array of ${type}`
|
||||
}
|
||||
|
||||
function formatUnionDescription(arr?: SchemaObject[]) {
|
||||
function formatUnionDescription(arr?: OpenAPI.SchemaObject[]) {
|
||||
const types = [...new Set(arr?.map((type) => type.type || "object"))]
|
||||
return <>{types.join(" or ")}</>
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import clsx from "clsx"
|
||||
import type { TagOperationParametersProps } from ".."
|
||||
import dynamic from "next/dynamic"
|
||||
@@ -14,7 +14,7 @@ const TagOperationParameters = dynamic<TagOperationParametersProps>(
|
||||
type TagsOperationParametersSectionProps = {
|
||||
header?: string
|
||||
contentType?: string
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
}
|
||||
|
||||
const TagsOperationParametersSection = ({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagOperationParametersDefaultProps } from "../Default"
|
||||
import type { TagOperationParametersProps } from "../.."
|
||||
@@ -22,7 +22,7 @@ const TagOperationParameters = dynamic<TagOperationParametersProps>(
|
||||
|
||||
export type TagOperationParametersArrayProps = {
|
||||
name: string
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
isRequired?: boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import TagOperationParametersDescription from "../../Description"
|
||||
import clsx from "clsx"
|
||||
import TagOperationParametersName from "../../Name"
|
||||
|
||||
export type TagOperationParametersDefaultProps = {
|
||||
name?: string
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
isRequired?: boolean
|
||||
className?: string
|
||||
expandable?: boolean
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import TagOperationParametersDefault from "../Default"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagOperationParametersProps } from "../.."
|
||||
@@ -33,7 +33,7 @@ const Details = dynamic<DetailsProps>(
|
||||
|
||||
export type TagOperationParametersObjectProps = {
|
||||
name?: string
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
isRequired?: boolean
|
||||
topLevel?: boolean
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import clsx from "clsx"
|
||||
import dynamic from "next/dynamic"
|
||||
import { useState } from "react"
|
||||
@@ -31,7 +31,7 @@ const TagsOperationParametersNested =
|
||||
) as React.FC<TagsOperationParametersNestedProps>
|
||||
|
||||
export type TagOperationParamatersOneOfProps = {
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
isRequired?: boolean
|
||||
isNested?: boolean
|
||||
}
|
||||
@@ -43,7 +43,7 @@ const TagOperationParamatersOneOf = ({
|
||||
}: TagOperationParamatersOneOfProps) => {
|
||||
const [activeTab, setActiveTab] = useState<number>(0)
|
||||
|
||||
const getName = (item: SchemaObject): string => {
|
||||
const getName = (item: OpenAPI.SchemaObject): string => {
|
||||
if (item.title) {
|
||||
return item.title
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagOperationParametersDefaultProps } from "../Default"
|
||||
import { TagOperationParametersObjectProps } from "../Object"
|
||||
@@ -22,7 +22,7 @@ const TagOperationParametersDefault =
|
||||
|
||||
export type TagOperationParametersUnionProps = {
|
||||
name: string
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
isRequired?: boolean
|
||||
topLevel?: boolean
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagOperationParametersObjectProps } from "./Types/Object"
|
||||
import type { TagOperationParametersDefaultProps } from "./Types/Default"
|
||||
@@ -41,7 +41,7 @@ const TagOperationParamatersOneOf = dynamic<TagOperationParamatersOneOfProps>(
|
||||
) as React.FC<TagOperationParamatersOneOfProps>
|
||||
|
||||
export type TagOperationParametersProps = {
|
||||
schemaObject: SchemaObject
|
||||
schemaObject: OpenAPI.SchemaObject
|
||||
topLevel?: boolean
|
||||
className?: string
|
||||
isRequired?: boolean
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import type { Operation } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import clsx from "clsx"
|
||||
import type { OpenAPIV3 } from "openapi-types"
|
||||
import getSectionId from "@/utils/get-section-id"
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react"
|
||||
import dynamic from "next/dynamic"
|
||||
import { InView } from "react-intersection-observer"
|
||||
@@ -21,15 +19,16 @@ import { useRouter } from "next/navigation"
|
||||
import checkElementInViewport from "../../../utils/check-element-in-viewport"
|
||||
import DividedLoading from "../../DividedLoading"
|
||||
import SectionContainer from "../../Section/Container"
|
||||
import { getSectionId } from "docs-utils"
|
||||
|
||||
const TagOperationCodeSection = dynamic<TagOperationCodeSectionProps>(
|
||||
async () => import("./CodeSection")
|
||||
) as React.FC<TagOperationCodeSectionProps>
|
||||
|
||||
export type TagOperationProps = {
|
||||
operation: Operation
|
||||
operation: OpenAPI.Operation
|
||||
method?: string
|
||||
tag: OpenAPIV3.TagObject
|
||||
tag: OpenAPI.OpenAPIV3.TagObject
|
||||
endpointPath: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import type { Operation, PathsObject, TagObject } from "@/types/openapi"
|
||||
import type { OpenAPI } from "types"
|
||||
import { findSidebarItem, useSidebar } from "docs-ui"
|
||||
import { Fragment, Suspense, useEffect } from "react"
|
||||
import dynamic from "next/dynamic"
|
||||
@@ -16,8 +16,8 @@ const TagOperation = dynamic<TagOperationProps>(
|
||||
) as React.FC<TagOperationProps>
|
||||
|
||||
export type TagPathsProps = {
|
||||
tag: TagObject
|
||||
paths: PathsObject
|
||||
tag: OpenAPI.TagObject
|
||||
paths: OpenAPI.PathsObject
|
||||
} & React.HTMLAttributes<HTMLDivElement>
|
||||
|
||||
const TagPaths = ({ tag, className, paths }: TagPathsProps) => {
|
||||
@@ -50,6 +50,7 @@ const TagPaths = ({ tag, className, paths }: TagPathsProps) => {
|
||||
path: "",
|
||||
changeLoaded: true,
|
||||
},
|
||||
indexPosition: tag["x-associatedSchema"] ? 1 : 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -66,7 +67,7 @@ const TagPaths = ({ tag, className, paths }: TagPathsProps) => {
|
||||
([method, operation], operationIndex) => (
|
||||
<TagOperation
|
||||
method={method}
|
||||
operation={operation as Operation}
|
||||
operation={operation as OpenAPI.Operation}
|
||||
tag={tag}
|
||||
key={`${pathIndex}-${operationIndex}`}
|
||||
endpointPath={endpointPath}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { Suspense, useEffect, useMemo } from "react"
|
||||
import { SchemaObject } from "../../../../types/openapi"
|
||||
import { OpenAPI } from "types"
|
||||
import TagOperationParameters from "../../Operation/Parameters"
|
||||
import {
|
||||
Badge,
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
useScrollController,
|
||||
useSidebar,
|
||||
} from "docs-ui"
|
||||
import getSectionId from "../../../../utils/get-section-id"
|
||||
import DividedLayout from "../../../../layouts/Divided"
|
||||
import SectionContainer from "../../../Section/Container"
|
||||
import useSchemaExample from "../../../../hooks/use-schema-example"
|
||||
@@ -22,14 +21,15 @@ import checkElementInViewport from "../../../../utils/check-element-in-viewport"
|
||||
import { singular } from "pluralize"
|
||||
import clsx from "clsx"
|
||||
import { useArea } from "../../../../providers/area"
|
||||
import { getSectionId } from "docs-utils"
|
||||
|
||||
export type TagSectionSchemaProps = {
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
tagName: string
|
||||
}
|
||||
|
||||
const TagSectionSchema = ({ schema, tagName }: TagSectionSchemaProps) => {
|
||||
const { addItems, setActivePath, activePath, shownSidebar } = useSidebar()
|
||||
const { setActivePath, activePath, shownSidebar, updateItems } = useSidebar()
|
||||
const { displayedArea } = useArea()
|
||||
const formattedName = useMemo(
|
||||
() => singular(tagName).replaceAll(" ", ""),
|
||||
@@ -56,34 +56,6 @@ const TagSectionSchema = ({ schema, tagName }: TagSectionSchemaProps) => {
|
||||
return isElmWindow(scrollableElement) ? document.body : scrollableElement
|
||||
}, [isBrowser, scrollableElement])
|
||||
|
||||
useEffect(() => {
|
||||
if (!shownSidebar) {
|
||||
return
|
||||
}
|
||||
addItems(
|
||||
[
|
||||
{
|
||||
type: "link",
|
||||
path: schemaSlug,
|
||||
title: `${formattedName} Object`,
|
||||
additionalElms: <Badge variant="neutral">Schema</Badge>,
|
||||
loaded: true,
|
||||
},
|
||||
],
|
||||
{
|
||||
sidebar_id: shownSidebar.sidebar_id,
|
||||
parent: {
|
||||
type: "category",
|
||||
title: tagName,
|
||||
path: "",
|
||||
changeLoaded: true,
|
||||
},
|
||||
indexPosition: 0,
|
||||
}
|
||||
)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [formattedName, shownSidebar?.sidebar_id])
|
||||
|
||||
useEffect(() => {
|
||||
if (!isBrowser) {
|
||||
return
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"use client"
|
||||
|
||||
import getSectionId from "@/utils/get-section-id"
|
||||
import { InView } from "react-intersection-observer"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import {
|
||||
@@ -22,15 +21,16 @@ import SectionDivider from "../../Section/Divider"
|
||||
import clsx from "clsx"
|
||||
import { Feedback, Loading, Link } from "docs-ui"
|
||||
import { usePathname, useRouter } from "next/navigation"
|
||||
import { PathsObject, SchemaObject, TagObject } from "@/types/openapi"
|
||||
import { OpenAPI } from "types"
|
||||
import TagSectionSchema from "./Schema"
|
||||
import checkElementInViewport from "../../../utils/check-element-in-viewport"
|
||||
import TagPaths from "../Paths"
|
||||
import useSWR from "swr"
|
||||
import basePathUrl from "../../../utils/base-path-url"
|
||||
import { getSectionId } from "docs-utils"
|
||||
|
||||
export type TagSectionProps = {
|
||||
tag: TagObject
|
||||
tag: OpenAPI.TagObject
|
||||
} & React.HTMLAttributes<HTMLDivElement>
|
||||
|
||||
const Section = dynamic<SectionProps>(
|
||||
@@ -62,7 +62,7 @@ const TagSectionComponent = ({ tag }: TagSectionProps) => {
|
||||
return isElmWindow(scrollableElement) ? document.body : scrollableElement
|
||||
}, [scrollableElement, isBrowser])
|
||||
const { data: schemaData } = useSWR<{
|
||||
schema: SchemaObject
|
||||
schema: OpenAPI.SchemaObject
|
||||
}>(
|
||||
loadData && tag["x-associatedSchema"]
|
||||
? basePathUrl(
|
||||
@@ -75,7 +75,7 @@ const TagSectionComponent = ({ tag }: TagSectionProps) => {
|
||||
}
|
||||
)
|
||||
const { data: pathsData } = useSWR<{
|
||||
paths: PathsObject
|
||||
paths: OpenAPI.PathsObject
|
||||
}>(
|
||||
loadData ? basePathUrl(`/tag?tagName=${slugTagName}&area=${area}`) : null,
|
||||
swrFetcher,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { OpenAPIV3 } from "openapi-types"
|
||||
import { OpenAPI } from "types"
|
||||
import { TagSectionProps } from "./Section"
|
||||
import dynamic from "next/dynamic"
|
||||
import { Suspense } from "react"
|
||||
@@ -8,7 +8,7 @@ const TagSection = dynamic<TagSectionProps>(
|
||||
) as React.FC<TagSectionProps>
|
||||
|
||||
type TagsProps = {
|
||||
tags?: OpenAPIV3.TagObject[]
|
||||
tags?: OpenAPI.OpenAPIV3.TagObject[]
|
||||
}
|
||||
|
||||
const Tags = ({ tags }: TagsProps) => {
|
||||
|
||||
Reference in new issue
Block a user