Mark OpenAPI properties as optional if not required (#3021)

This commit is contained in:
Greg Bergé
2025-03-21 15:28:53 +01:00
committed by GitHub
parent 6eae764b7c
commit d2facb2db1
3 changed files with 15 additions and 1 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"@gitbook/react-openapi": patch
"gitbook": patch
---
Mark properties as optional if not required
@@ -201,6 +201,10 @@
@apply text-warning-subtle text-[0.813rem];
}
.openapi-schema-optional {
@apply text-info-subtle text-[0.813rem];
}
.openapi-schema-readonly {
@apply text-primary-subtle/9 text-[0.813rem];
}
@@ -32,7 +32,11 @@ export function OpenAPISchemaName(props: OpenAPISchemaNameProps) {
) : null}
</span>
{schema?.readOnly ? <span className="openapi-schema-readonly">read-only</span> : null}
{required ? <span className="openapi-schema-required">required</span> : null}
{required ? (
<span className="openapi-schema-required">required</span>
) : (
<span className="openapi-schema-optional">optional</span>
)}
{schema?.deprecated ? <span className="openapi-deprecated">Deprecated</span> : null}
</div>
);