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:
5
www/apps/api-reference/utils/base-path-url.ts
Normal file
5
www/apps/api-reference/utils/base-path-url.ts
Normal 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)
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -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}`)}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user