Show additional fields in OpenAPI block (#2851)

This commit is contained in:
Nolann B.
2025-02-19 17:01:15 +01:00
committed by GitHub
parent aa6be381a4
commit 7419ee7dba
2 changed files with 20 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@gitbook/react-openapi': patch
---
Show additional fields in OpenAPI block
+15 -3
View File
@@ -397,7 +397,7 @@ export function getSchemaTitle(
let type = 'any';
if (schema.enum) {
type = 'enum';
type = `${schema.type} · enum`;
// check array AND schema.items as this is sometimes null despite what the type indicates
} else if (schema.type === 'array' && !!schema.items) {
type = `${getSchemaTitle(schema.items)}[]`;
@@ -407,7 +407,7 @@ export function getSchemaTitle(
type = schema.type ?? 'object';
if (schema.format) {
type += ` ${schema.format}`;
type += ` · ${schema.format}`;
}
} else if ('anyOf' in schema) {
type = 'any of';
@@ -419,8 +419,20 @@ export function getSchemaTitle(
type = 'not';
}
if (schema.minimum || schema.minLength) {
type += ` · min: ${schema.minimum || schema.minLength}`;
}
if (schema.maximum || schema.maxLength) {
type += ` · max: ${schema.maximum || schema.maxLength}`;
}
if (schema.default) {
type += ` · default: ${schema.default}`;
}
if (schema.nullable) {
type = `nullable ${type}`;
type = `${type} | nullable`;
}
return type;