Skip to content

Commit 19fec96

Browse files
committed
Fix circular schema labels for primitive refs
1 parent 4c207ed commit 19fec96

File tree

1 file changed

+6
-3
lines changed
  • packages/docusaurus-plugin-openapi-docs/src/markdown

1 file changed

+6
-3
lines changed

packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
import { SchemaObject } from "../openapi/types";
99

10-
function prettyName(schema: SchemaObject, circular?: boolean) {
10+
function prettyName(schema: SchemaObject | string, circular?: boolean) {
11+
if (typeof schema === "string") {
12+
return schema.startsWith("circular(") ? schema : "";
13+
}
1114
if (schema.format) {
1215
if (schema.type) {
1316
return `${schema.type}<${schema.format}>`;
@@ -51,10 +54,10 @@ function prettyName(schema: SchemaObject, circular?: boolean) {
5154
}
5255

5356
export function getSchemaName(
54-
schema: SchemaObject,
57+
schema: SchemaObject | string,
5558
circular?: boolean
5659
): string {
57-
if (schema.items) {
60+
if (typeof schema !== "string" && schema.items) {
5861
return prettyName(schema.items, circular) + "[]";
5962
}
6063

0 commit comments

Comments
 (0)