mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
OpenAPI: tolerate array schema without items type
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-openapi': patch
|
||||
---
|
||||
|
||||
tolerate array schema without `items` type
|
||||
@@ -2,11 +2,12 @@ import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { dirname, join, parse } from 'node:path';
|
||||
import fg from 'fast-glob';
|
||||
import {
|
||||
generatePages,
|
||||
generateAll,
|
||||
type GenerateOptions,
|
||||
type GeneratePageOutput,
|
||||
generatePages,
|
||||
generateTags,
|
||||
} from './generate';
|
||||
import { generateAll, generateTags } from './generate';
|
||||
|
||||
export interface Config extends GenerateOptions {
|
||||
/**
|
||||
@@ -195,12 +196,7 @@ function getOutputPathFromRoute(path: string): string {
|
||||
}
|
||||
|
||||
function getFilename(s: string): string {
|
||||
return s
|
||||
.replace(/[A-Z]/g, (match, idx: number) =>
|
||||
idx === 0 ? match : `-${match.toLowerCase()}`,
|
||||
)
|
||||
.replace(/\s+/g, '-')
|
||||
.toLowerCase();
|
||||
return s.replace(/\s+/g, '-').toLowerCase();
|
||||
}
|
||||
|
||||
async function write(path: string, content: string): Promise<void> {
|
||||
|
||||
@@ -31,7 +31,9 @@ export interface GenerateOptions {
|
||||
) => Record<string, unknown>;
|
||||
|
||||
/**
|
||||
* Add description to document body
|
||||
* Add description to document body.
|
||||
*
|
||||
* We recommend but don't enable it by default because some OpenAPI schemas have invalid description that breaks MDX syntax.
|
||||
*
|
||||
* @defaultValue false
|
||||
*/
|
||||
|
||||
@@ -167,7 +167,7 @@ export function Schema({
|
||||
const mentionedObjectTypes = [
|
||||
...(schema.anyOf ?? schema.oneOf ?? []),
|
||||
...(schema.not ? [schema.not] : []),
|
||||
...(schema.type === 'array' ? [schema.items] : []),
|
||||
...(schema.type === 'array' && schema.items ? [schema.items] : []),
|
||||
].filter((s) => isComplexType(s) && !stack.includes(s));
|
||||
|
||||
footer = mentionedObjectTypes.map((s, idx) => {
|
||||
@@ -240,7 +240,7 @@ function getSchemaType(
|
||||
if (schema.title) return schema.title;
|
||||
|
||||
if (schema.type === 'array')
|
||||
return `array<${getSchemaType(schema.items, ctx)}>`;
|
||||
return `array<${schema.items ? getSchemaType(schema.items, ctx) : 'unknown'}>`;
|
||||
|
||||
if (schema.oneOf)
|
||||
return schema.oneOf
|
||||
|
||||
Reference in New Issue
Block a user