Skip to content

Commit eee658a

Browse files
committed
chore: support markdown in all descriptions
1 parent f906a44 commit eee658a

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

components/ApiReference/ApiReferenceMethod/ApiReferenceMethod.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { OpenAPIV3 } from "@scalar/openapi-types";
22
import { useState } from "react";
3+
import Markdown from "react-markdown";
34

45
import { Endpoint } from "../../Endpoints";
56
import { ContentColumn, ExampleColumn, Section } from "../../ApiSections";
@@ -45,7 +46,7 @@ function ApiReferenceMethod({ methodName, methodType, endpoint }: Props) {
4546
return (
4647
<Section title={method.summary} slug={method.summary}>
4748
<ContentColumn>
48-
<p>{method.description}</p>
49+
<Markdown>{method.description}</Markdown>
4950

5051
<h3 className="!text-sm font-medium">Endpoint</h3>
5152

@@ -85,7 +86,7 @@ function ApiReferenceMethod({ methodName, methodType, endpoint }: Props) {
8586
<PropertyRow.Type>{responseSchema.title}</PropertyRow.Type>
8687
</PropertyRow.Header>
8788
<PropertyRow.Description>
88-
{responseSchema.description}
89+
<Markdown>{responseSchema.description}</Markdown>
8990
</PropertyRow.Description>
9091

9192
{responseSchema.properties && (

components/ApiReference/SchemaProperties/PropertyRow.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const Type = ({ children }) => (
3434
);
3535

3636
const Description = ({ children }) => (
37-
<div className="text-sm text-gray-500 dark:text-gray-300">{children}</div>
37+
<div className="text-sm text-gray-500 dark:text-gray-300 schema-property-description">
38+
{children}
39+
</div>
3840
);
3941

4042
const Required = () => (

components/ApiReference/SchemaProperties/SchemaProperty.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { OpenAPIV3 } from "@scalar/openapi-types";
22
import { PropertyRow } from "./PropertyRow";
33
import { useState } from "react";
4+
import Markdown from "react-markdown";
45
import {
56
getTypesForDisplay,
67
innerEnumSchema,
@@ -46,7 +47,9 @@ const SchemaProperty = ({ name, schema }: Props) => {
4647
<PropertyRow.Required>Required</PropertyRow.Required>
4748
)}
4849
</PropertyRow.Header>
49-
<PropertyRow.Description>{schema.description}</PropertyRow.Description>
50+
<PropertyRow.Description>
51+
<Markdown>{schema.description}</Markdown>
52+
</PropertyRow.Description>
5053

5154
{maybeEnum && (
5255
<>

styles/index.css

+12
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,15 @@ body {
159159
.prose-sm ul {
160160
list-style-type: disc;
161161
}
162+
163+
.schema-property-description p {
164+
margin-top: 0 !important;
165+
}
166+
167+
.schema-property-description p:last-child {
168+
margin-bottom: 0 !important;
169+
}
170+
171+
.schema-property-description code {
172+
font-size: 11px;
173+
}

0 commit comments

Comments
 (0)