Skip to content

Commit 3e5e458

Browse files
authored
Handle isArray schema type (#2815)
1 parent 0510b6f commit 3e5e458

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

.changeset/empty-pianos-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@gitbook/react-openapi': patch
3+
---
4+
5+
Handle isArray schema type

packages/gitbook/src/components/DocumentView/OpenAPI/style.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636

3737
.openapi-description.openapi-markdown {
38-
@apply prose-sm text-[15px];
38+
@apply prose-sm text-[0.938rem];
3939
}
4040

4141
.openapi-description.openapi-markdown code {
@@ -207,11 +207,11 @@
207207
}
208208

209209
.openapi-schema-required {
210-
@apply text-amber-600 text-[13px];
210+
@apply text-amber-600 text-[0.813rem];
211211
}
212212

213213
.openapi-schema-type {
214-
@apply text-tint select-text text-[13px] font-mono;
214+
@apply text-tint select-text text-[0.813rem] font-mono [word-spacing:-0.25rem];
215215
}
216216

217217
.openapi-schema-type:only-child {
@@ -338,7 +338,7 @@
338338
}
339339

340340
.openapi-response-description.openapi-markdown {
341-
@apply prose-sm text-[13px] h-auto relative leading-[18px] text-tint !font-normal truncate select-text prose-strong:font-semibold prose-strong:text-inherit;
341+
@apply prose-sm text-[0.813rem] h-auto relative leading-[1.125rem] text-tint !font-normal truncate select-text prose-strong:font-semibold prose-strong:text-inherit;
342342
}
343343

344344
.openapi-response-description.openapi-markdown::-webkit-scrollbar {
@@ -398,7 +398,7 @@
398398
}
399399

400400
.openapi-path .openapi-method {
401-
@apply text-[13px] m-0 px-1;
401+
@apply text-[0.813rem] m-0 px-1;
402402
}
403403

404404
.openapi-path-title {
@@ -504,7 +504,7 @@
504504
}
505505

506506
.openapi-tabs-tab {
507-
@apply hover:bg-primary-hover font-mono font-normal tabular-nums hover:text-primary cursor-pointer transition-all relative text-[13px] text-tint px-1 border border-transparent rounded;
507+
@apply hover:bg-primary-hover font-mono font-normal tabular-nums hover:text-primary cursor-pointer transition-all relative text-[0.813rem] text-tint px-1 border border-transparent rounded;
508508
}
509509

510510
.openapi-tabs-tab[aria-selected='true'] {
@@ -516,7 +516,7 @@
516516
}
517517

518518
.openapi-tabs-footer {
519-
@apply px-3 py-2 pt-2.5 border-t border-tint-subtle text-[13px] text-tint;
519+
@apply px-3 py-2 pt-2.5 border-t border-tint-subtle text-[0.813rem] text-tint;
520520
}
521521

522522
/* Disclosure group */
@@ -576,7 +576,7 @@
576576

577577
/* Disclosure */
578578
.openapi-disclosure-trigger {
579-
@apply transition-all duration-300 hover:text-tint-strong rounded-2xl border border-tint-subtle px-2.5 py-1 text-[13px] text-tint flex flex-row items-center gap-1.5 -outline-offset-1;
579+
@apply transition-all duration-300 hover:text-tint-strong rounded-2xl border border-tint-subtle px-2.5 py-1 text-[0.813rem] text-tint flex flex-row items-center gap-1.5 -outline-offset-1;
580580
}
581581

582582
.openapi-disclosure svg {

packages/react-openapi/src/OpenAPISchema.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ export function getSchemaTitle(
409409
// check array AND schema.items as this is sometimes null despite what the type indicates
410410
} else if (schema.type === 'array' && !!schema.items) {
411411
type = `${getSchemaTitle(noReference(schema.items))}[]`;
412+
} else if (Array.isArray(schema.type)) {
413+
type = schema.type.join(' | ');
412414
} else if (schema.type || schema.properties) {
413415
type = schema.type ?? 'object';
414416

0 commit comments

Comments
 (0)