diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/__snapshots__/createSchema.test.ts.snap b/packages/docusaurus-plugin-openapi-docs/src/markdown/__snapshots__/createSchema.test.ts.snap index 3d4d9548d..7a93bdd73 100644 --- a/packages/docusaurus-plugin-openapi-docs/src/markdown/__snapshots__/createSchema.test.ts.snap +++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/__snapshots__/createSchema.test.ts.snap @@ -13,7 +13,7 @@ Array [
- Click the Send API Request button above and see
- the response here!
+ {translate({
+ id: OPENAPI_RESPONSE.PLACEHOLDER,
+ message:
+ "Click the Send API Request button above and see the response here!",
+ })}
- Click the Send API Request button above and see the
- response here!
+ {translate({
+ id: OPENAPI_RESPONSE.PLACEHOLDER,
+ message:
+ "Click the Send API Request button above and see the response here!",
+ })}
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
@@ -66,7 +89,13 @@ function SecuritySchemes(props: any) {
{Object.keys(rest).map((k, i) => {
return (
- {k}:
+
+ {translate({
+ id: `theme.authorization.${k}`,
+ message: k,
+ })}
+ :
+
{typeof rest[k] === "object"
? JSON.stringify(rest[k], null, 2)
: String(rest[k])}
@@ -89,16 +118,31 @@ function SecuritySchemes(props: any) {
}}
>
- name:{" "}
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.NAME,
+ message: "name:",
+ })}
+ {" "}
{name ?? key}
- type:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.TYPE,
+ message: "type:",
+ })}
+ {" "}
{type}
{scopes && scopes.length > 0 && (
- scopes:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.SCOPES,
+ message: "scopes:",
+ })}
+ {" "}
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
@@ -107,7 +151,13 @@ function SecuritySchemes(props: any) {
{Object.keys(rest).map((k, i) => {
return (
- {k}:
+
+ {translate({
+ id: `theme.authorization.${k}`,
+ message: k,
+ })}
+ :
+
{typeof rest[k] === "object"
? JSON.stringify(rest[k], null, 2)
: String(rest[k])}
@@ -128,15 +178,30 @@ function SecuritySchemes(props: any) {
}}
>
- name:{" "}
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.NAME,
+ message: "name:",
+ })}
+ {" "}
{auth.name ?? auth.key}
- type:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.TYPE,
+ message: "type:",
+ })}
+ {" "}
{auth.type}
- in:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.IN,
+ message: "in:",
+ })}
+ {" "}
{auth.in}
@@ -156,16 +221,31 @@ function SecuritySchemes(props: any) {
}}
>
- name:{" "}
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.NAME,
+ message: "name:",
+ })}
+ {" "}
{name ?? key}
- type:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.TYPE,
+ message: "type:",
+ })}
+ {" "}
{type}
{scopes && scopes.length > 0 && (
- scopes:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.SCOPES,
+ message: "scopes:",
+ })}
+ {" "}
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
@@ -174,7 +254,13 @@ function SecuritySchemes(props: any) {
{Object.keys(rest).map((k, i) => {
return (
- {k}:
+
+ {translate({
+ id: `theme.authorization.${k}`,
+ message: k,
+ })}
+ :
+
{typeof rest[k] === "object"
? JSON.stringify(rest[k], null, 2)
: String(rest[k])}
@@ -198,16 +284,31 @@ function SecuritySchemes(props: any) {
}}
>
- name:{" "}
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.NAME,
+ message: "name:",
+ })}
+ {" "}
{name ?? key}
- type:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.TYPE,
+ message: "type:",
+ })}
+ {" "}
{type}
{scopes && scopes.length > 0 && (
- scopes:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.SCOPES,
+ message: "scopes:",
+ })}
+ {" "}
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
@@ -216,7 +317,13 @@ function SecuritySchemes(props: any) {
{Object.keys(rest).map((k, i) => {
return (
- {k}:
+
+ {translate({
+ id: `theme.authorization.${k}`,
+ message: k,
+ })}
+ :
+
{typeof rest[k] === "object"
? JSON.stringify(rest[k], null, 2)
: String(rest[k])}
@@ -226,7 +333,12 @@ function SecuritySchemes(props: any) {
{flows && (
- flows:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.FLOWS,
+ message: "flows:",
+ })}
+ {" "}
{JSON.stringify(flows, null, 2)}
@@ -248,16 +360,31 @@ function SecuritySchemes(props: any) {
}}
>
- name:{" "}
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.NAME,
+ message: "name:",
+ })}
+ {" "}
{name ?? key}
- type:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.TYPE,
+ message: "type:",
+ })}
+ {" "}
{type}
{scopes && scopes.length > 0 && (
- scopes:
+
+ {translate({
+ id: OPENAPI_SECURITY_SCHEMES.SCOPES,
+ message: "scopes:",
+ })}
+ {" "}
{auth.scopes.length > 0 ? auth.scopes.toString() : "[]"}
@@ -266,7 +393,13 @@ function SecuritySchemes(props: any) {
{Object.keys(rest).map((k, i) => {
return (
- {k}:
+
+ {translate({
+ id: `theme.authorization.${k}`,
+ message: k,
+ })}
+ :
+
{typeof rest[k] === "object"
? JSON.stringify(rest[k], null, 2)
: String(rest[k])}
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx
index c627d463a..0777a6adb 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/ApiExplorer/Server/index.tsx
@@ -7,11 +7,13 @@
import React, { useState } from "react";
+import { translate } from "@docusaurus/Translate";
import FloatingButton from "@theme/ApiExplorer/FloatingButton";
import FormItem from "@theme/ApiExplorer/FormItem";
import FormSelect from "@theme/ApiExplorer/FormSelect";
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
+import { OPENAPI_SERVER } from "@theme/translationIds";
import { setServer, setServerVariable } from "./slice";
@@ -57,7 +59,10 @@ function Server() {
}
}
return (
- {defaultValue}
@@ -127,7 +147,12 @@ function ParamsItem({ param, ...rest }: Props) {
}
return (
{JSON.stringify(defaultValue)}
@@ -139,7 +164,12 @@ function ParamsItem({ param, ...rest }: Props) {
const renderExample = guard(toString(example), (example) => (
{exampleProperties.summary}
} {exampleProperties.description && (- Description: + + {translate({ + id: OPENAPI_SCHEMA_ITEM.DESCRIPTION, + message: "Description:", + })}{" "} + {exampleProperties.description}
)}
- Example:
+
+ {translate({
+ id: OPENAPI_SCHEMA_ITEM.EXAMPLE,
+ message: "Example:",
+ })}{" "}
+
{exampleProperties.value}
{defaultValue}
@@ -129,7 +153,12 @@ export default function SchemaItem(props: Props) {
}
return (
{JSON.stringify(defaultValue)}
@@ -144,7 +173,12 @@ export default function SchemaItem(props: Props) {
if (typeof example === "string") {
return (
{example}
@@ -153,7 +187,12 @@ export default function SchemaItem(props: Props) {
}
return (
{JSON.stringify(example)}
@@ -168,7 +207,12 @@ export default function SchemaItem(props: Props) {
if (typeof constValue === "string") {
return (
{constValue}
@@ -177,7 +221,12 @@ export default function SchemaItem(props: Props) {
}
return (
{JSON.stringify(constValue)}
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx
index e838e9897..da7ebf29f 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/StatusCodes/index.tsx
@@ -7,12 +7,15 @@
import React from "react";
+import { translate } from "@docusaurus/Translate";
+
import ApiTabs from "@theme/ApiTabs";
import Details from "@theme/Details";
import Markdown from "@theme/Markdown";
import ResponseHeaders from "@theme/ResponseHeaders";
import ResponseSchema from "@theme/ResponseSchema";
import TabItem from "@theme/TabItem";
+import { OPENAPI_STATUS_CODES } from "@theme/translationIds";
import { ApiItem } from "docusaurus-plugin-openapi-docs/lib/types";
interface Props {
@@ -51,7 +54,12 @@ const StatusCodes: React.FC