Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for example summaries #898

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions demo/examples/petstore.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,8 @@ paths:
type: string
examples:
response:
summary: |
This is an example of using **Docusaurus** `markdown` in a summary. Note that admonitions are not fully supported.
value: OK
application/xml:
schema:
Expand Down Expand Up @@ -1194,6 +1196,7 @@ components:
title: Pettie
- $ref: "#/components/schemas/Pet"
example:
summary: A great example!
category:
name: Great Dane
sub:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ export function createResponseExamples(
value: `${exampleName}`,
children: [
guard(exampleValue.summary, (summary) => [
create("Markdown", {
children: ` ${summary}`,
create("div", {
children: `${summary}`,
className: "openapi-example__summary",
}),
]),
create("ResponseSamples", {
Expand All @@ -143,8 +144,9 @@ export function createResponseExamples(
value: `${exampleName}`,
children: [
guard(exampleValue.summary, (summary) => [
create("Markdown", {
children: ` ${summary}`,
create("div", {
children: `${summary}`,
className: "openapi-example__summary",
}),
]),
create("ResponseSamples", {
Expand All @@ -171,8 +173,9 @@ export function createResponseExample(responseExample: any, mimeType: string) {
value: `Example`,
children: [
guard(responseExample.summary, (summary) => [
create("Markdown", {
children: ` ${summary}`,
create("div", {
children: `${summary}`,
className: "openapi-example__summary",
}),
]),
create("ResponseSamples", {
Expand All @@ -187,8 +190,9 @@ export function createResponseExample(responseExample: any, mimeType: string) {
value: `Example`,
children: [
guard(responseExample.summary, (summary) => [
create("Markdown", {
children: ` ${summary}`,
create("div", {
children: `${summary}`,
className: "openapi-example__summary",
}),
]),
create("ResponseSamples", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export function createApiPageMD({
`import ResponseSamples from "@theme/ResponseSamples";\n`,
`import SchemaItem from "@theme/SchemaItem";\n`,
`import SchemaTabs from "@theme/SchemaTabs";\n`,
`import Markdown from "@theme/Markdown";\n`,
`import Heading from "@theme/Heading";\n`,
`import OperationTabs from "@theme/OperationTabs";\n`,
`import TabItem from "@theme/TabItem";\n\n`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import FormSelect from "@theme/ApiExplorer/FormSelect";
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
import LiveApp from "@theme/ApiExplorer/LiveEditor";
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
import Markdown from "@theme/Markdown";
import SchemaTabs from "@theme/SchemaTabs";
import TabItem from "@theme/TabItem";
import { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
Expand Down Expand Up @@ -304,7 +303,7 @@ function Body({
</TabItem>
{/* @ts-ignore */}
<TabItem label="Example" value="example">
{example.summary && <Markdown children={example.summary} />}
{example.summary && <div>{example.summary}</div>}
{exampleBody && (
<LiveApp
action={dispatch}
Expand Down Expand Up @@ -342,7 +341,7 @@ function Body({
value={example.label}
key={example.label}
>
{example.summary && <Markdown children={example.summary} />}
{example.summary && <div>{example.summary}</div>}
{example.body && (
<LiveApp action={dispatch} language={language}>
{example.body}
Expand Down
Loading