docs: update api-reference project for v2 (#7307)

* remove everything v1 and make v2 default

* move main v2 rewrites to book

* move rewrites to book + other fixes
This commit is contained in:
Shahed Nasser
2024-05-16 10:02:35 +03:00
committed by GitHub
parent 9b1998b9b2
commit 22f30f54fd
2148 changed files with 8965 additions and 140283 deletions

View File

@@ -0,0 +1,5 @@
import { getLinkWithBasePath } from "docs-ui"
export default function basePathUrl(path: string) {
return getLinkWithBasePath(path, process.env.NEXT_PUBLIC_BASE_PATH)
}

View File

@@ -1,7 +1,7 @@
import path from "path"
import { promises as fs } from "fs"
import type { OpenAPIV3 } from "openapi-types"
import type { Operation, Document, Version } from "@/types/openapi"
import type { Operation, Document } from "@/types/openapi"
import readSpecDocument from "./read-spec-document"
import getSectionId from "./get-section-id"
import OpenAPIParser from "@readme/openapi-parser"
@@ -12,15 +12,10 @@ type ParsedPathItemObject = OpenAPIV3.PathItemObject<Operation> & {
export default async function getPathsOfTag(
tagName: string,
area: string,
version: Version = "1"
area: string
): Promise<Document> {
// get path files
const basePath = path.join(
process.cwd(),
version === "1" ? "specs" : "specs-v2",
`${area}/paths`
)
const basePath = path.join(process.cwd(), "specs", `${area}/paths`)
const files = await fs.readdir(basePath)

View File

@@ -1,5 +1,6 @@
import { config } from "../config"
import basePathUrl from "./base-path-url"
export default function getUrl(area: string, tagName?: string): string {
return `${config.baseUrl}/api/${area}#${tagName}`
return `${config.baseUrl}${basePathUrl(`/api/${area}#${tagName}`)}`
}