mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Show additional fields in OpenAPI block (#2851)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'@gitbook/react-openapi': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Show additional fields in OpenAPI block
|
||||||
@@ -397,7 +397,7 @@ export function getSchemaTitle(
|
|||||||
let type = 'any';
|
let type = 'any';
|
||||||
|
|
||||||
if (schema.enum) {
|
if (schema.enum) {
|
||||||
type = 'enum';
|
type = `${schema.type} · enum`;
|
||||||
// check array AND schema.items as this is sometimes null despite what the type indicates
|
// check array AND schema.items as this is sometimes null despite what the type indicates
|
||||||
} else if (schema.type === 'array' && !!schema.items) {
|
} else if (schema.type === 'array' && !!schema.items) {
|
||||||
type = `${getSchemaTitle(schema.items)}[]`;
|
type = `${getSchemaTitle(schema.items)}[]`;
|
||||||
@@ -407,7 +407,7 @@ export function getSchemaTitle(
|
|||||||
type = schema.type ?? 'object';
|
type = schema.type ?? 'object';
|
||||||
|
|
||||||
if (schema.format) {
|
if (schema.format) {
|
||||||
type += ` ${schema.format}`;
|
type += ` · ${schema.format}`;
|
||||||
}
|
}
|
||||||
} else if ('anyOf' in schema) {
|
} else if ('anyOf' in schema) {
|
||||||
type = 'any of';
|
type = 'any of';
|
||||||
@@ -419,8 +419,20 @@ export function getSchemaTitle(
|
|||||||
type = 'not';
|
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) {
|
if (schema.nullable) {
|
||||||
type = `nullable ${type}`;
|
type = `${type} | nullable`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
Reference in New Issue
Block a user