Skip to content

Commit d2facb2

Browse files
authored
Mark OpenAPI properties as optional if not required (#3021)
1 parent 6eae764 commit d2facb2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

.changeset/new-squids-approve.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@gitbook/react-openapi": patch
3+
"gitbook": patch
4+
---
5+
6+
Mark properties as optional if not required

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

+4
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@
201201
@apply text-warning-subtle text-[0.813rem];
202202
}
203203

204+
.openapi-schema-optional {
205+
@apply text-info-subtle text-[0.813rem];
206+
}
207+
204208
.openapi-schema-readonly {
205209
@apply text-primary-subtle/9 text-[0.813rem];
206210
}

packages/react-openapi/src/OpenAPISchemaName.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export function OpenAPISchemaName(props: OpenAPISchemaNameProps) {
3232
) : null}
3333
</span>
3434
{schema?.readOnly ? <span className="openapi-schema-readonly">read-only</span> : null}
35-
{required ? <span className="openapi-schema-required">required</span> : null}
35+
{required ? (
36+
<span className="openapi-schema-required">required</span>
37+
) : (
38+
<span className="openapi-schema-optional">optional</span>
39+
)}
3640
{schema?.deprecated ? <span className="openapi-deprecated">Deprecated</span> : null}
3741
</div>
3842
);

0 commit comments

Comments
 (0)