Skip to content

Commit

Permalink
revert isURL and support relative or abs downloadUrl path
Browse files Browse the repository at this point in the history
  • Loading branch information
sserrata committed Jul 2, 2024
1 parent dd1ea9c commit 5723b57
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions packages/docusaurus-plugin-openapi-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import type {
SchemaPageMetadata,
} from "./types";

export function isUrlOrPath(str: string): boolean {
return /^(https?:\/\/|\/[\w-]+).*$/i.test(str);
export function isURL(str: string): boolean {
return /^(https?:)\/\//m.test(str);
}

export function getDocsPluginConfig(
Expand Down Expand Up @@ -133,7 +133,7 @@ export default function pluginOpenAPIDocs(
docPath = docData ? (docData.path ? docData.path : "docs") : undefined;
}

const contentPath = isUrlOrPath(specPath)
const contentPath = isURL(specPath)
? specPath
: path.resolve(siteDir, specPath);

Expand Down Expand Up @@ -312,7 +312,7 @@ custom_edit_url: null

loadedApi.map(async (item) => {
if (item.type === "info") {
if (downloadUrl && isUrlOrPath(downloadUrl)) {
if (downloadUrl) {
item.downloadUrl = downloadUrl;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import sdk from "postman-collection";
import { sampleRequestFromSchema } from "./createRequestExample";
import { OpenApiObject, TagGroupObject, TagObject } from "./types";
import { loadAndResolveSpec } from "./utils/loadAndResolveSpec";
import { isUrlOrPath } from "../index";
import { isURL } from "../index";
import {
ApiMetadata,
APIOptions,
Expand Down Expand Up @@ -547,7 +547,7 @@ interface OpenApiFiles {
export async function readOpenapiFiles(
openapiPath: string
): Promise<OpenApiFiles[]> {
if (!isUrlOrPath(openapiPath)) {
if (!isURL(openapiPath)) {
const stat = await fs.lstat(openapiPath);
if (stat.isDirectory()) {
// TODO: Add config for inlcude/ignore
Expand Down

0 comments on commit 5723b57

Please sign in to comment.