Skip to content
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
9 changes: 4 additions & 5 deletions packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { translate } from "@docusaurus/Translate";

import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds";
import { SchemaObject } from "../types";

/**
Expand Down Expand Up @@ -130,7 +129,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
}

let message = `**${translate({
id: OPENAPI_SCHEMA_ITEM.POSSIBLE_VALUES,
id: "theme.openapi.schemaItem.possibleValues",
message: "Possible values:",
})}** `;

Expand All @@ -149,11 +148,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
let minLength;
let maxLength;
const charactersMessage = translate({
id: OPENAPI_SCHEMA_ITEM.CHARACTERS,
id: "theme.openapi.schemaItem.characters",
message: "characters",
});
const nonEmptyMessage = translate({
id: OPENAPI_SCHEMA_ITEM.NON_EMPTY,
id: "theme.openapi.schemaItem.nonEmpty",
message: "non-empty",
});
if (schema.minLength && schema.minLength > 1) {
Expand Down Expand Up @@ -218,7 +217,7 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {

if (schema.pattern) {
const expressionMessage = translate({
id: OPENAPI_SCHEMA_ITEM.EXPRESSION,
id: "theme.openapi.schemaItem.expression",
message: "Value must match regular expression",
});
qualifierGroups.push(`${expressionMessage} \`${schema.pattern}\``);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ 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_AUTH } from "@theme/translationIds";

import { setAuthData, setSelectedAuth } from "./slice";

Expand All @@ -37,7 +36,7 @@ function Authorization() {
<FormItem>
<FormSelect
label={translate({
id: OPENAPI_AUTH.SECURITY_SCHEME,
id: "theme.openapi.auth.securityScheme",
message: "Security Scheme",
})}
options={optionKeys}
Expand All @@ -54,11 +53,11 @@ function Authorization() {
<FormItem key={a.key + "-bearer"}>
<FormTextInput
label={translate({
id: OPENAPI_AUTH.BEARER_TOKEN,
id: "theme.openapi.auth.bearerToken",
message: "Bearer Token",
})}
placeholder={translate({
id: OPENAPI_AUTH.BEARER_TOKEN,
id: "theme.openapi.auth.bearerToken",
message: "Bearer Token",
})}
password
Expand All @@ -83,11 +82,11 @@ function Authorization() {
<FormItem key={a.key + "-oauth2"}>
<FormTextInput
label={translate({
id: OPENAPI_AUTH.BEARER_TOKEN,
id: "theme.openapi.auth.bearerToken",
message: "Bearer Token",
})}
placeholder={translate({
id: OPENAPI_AUTH.BEARER_TOKEN,
id: "theme.openapi.auth.bearerToken",
message: "Bearer Token",
})}
password
Expand All @@ -113,11 +112,11 @@ function Authorization() {
<FormItem>
<FormTextInput
label={translate({
id: OPENAPI_AUTH.USERNAME,
id: "theme.openapi.auth.username",
message: "Username",
})}
placeholder={translate({
id: OPENAPI_AUTH.USERNAME,
id: "theme.openapi.auth.username",
message: "Username",
})}
value={data[a.key].username ?? ""}
Expand All @@ -136,11 +135,11 @@ function Authorization() {
<FormItem>
<FormTextInput
label={translate({
id: OPENAPI_AUTH.PASSWORD,
id: "theme.openapi.auth.password",
message: "Password",
})}
placeholder={translate({
id: OPENAPI_AUTH.PASSWORD,
id: "theme.openapi.auth.password",
message: "Password",
})}
password
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
import Markdown from "@theme/Markdown";
import SchemaTabs from "@theme/SchemaTabs";
import TabItem from "@theme/TabItem";
import { OPENAPI_BODY, OPENAPI_REQUEST } from "@theme/translationIds";
import { sampleFromSchema } from "docusaurus-plugin-openapi-docs/lib/openapi/createSchemaExample";
import type { RequestBodyObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
import format from "xml-formatter";
Expand Down Expand Up @@ -292,7 +291,10 @@ function Body({
<FormFileUpload
placeholder={
schema.description ||
translate({ id: OPENAPI_REQUEST.BODY_TITLE, message: "Body" })
translate({
id: "theme.openapi.request.body.title",
message: "Body",
})
}
onChange={(file: any) => {
if (file === undefined) {
Expand Down Expand Up @@ -322,7 +324,7 @@ function Body({
{/* @ts-ignore */}
<TabItem
label={translate({
id: OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
id: "theme.openapi.body.exampleFromSchema",
message: "Example (from schema)",
})}
value="Example (from schema)"
Expand Down Expand Up @@ -412,7 +414,7 @@ function Body({
{/* @ts-ignore */}
<TabItem
label={translate({
id: OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
id: "theme.openapi.body.exampleFromSchema",
message: "Example (from schema)",
})}
value="Example (from schema)"
Expand Down Expand Up @@ -453,7 +455,7 @@ function Body({
{/* @ts-ignore */}
<TabItem
label={translate({
id: OPENAPI_BODY.EXAMPLE_FROM_SCHEMA,
id: "theme.openapi.body.exampleFromSchema",
message: "Example (from schema)",
})}
value="Example (from schema)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import React from "react";

import { translate } from "@docusaurus/Translate";
import fileSaver from "file-saver";

const saveFile = (url: string) => {
Expand All @@ -24,7 +25,7 @@ function Export({ url, proxy }: any) {
className="dropdown dropdown--hoverable dropdown--right"
>
<button className="export-button button button--sm button--secondary">
Export
{translate({ id: "theme.openapi.export.button", message: "Export" })}
</button>
<ul className="export-dropdown dropdown__menu">
<li>
Expand All @@ -36,7 +37,10 @@ function Export({ url, proxy }: any) {
className="dropdown__link"
href={`${url}`}
>
OpenAPI Spec
{translate({
id: "theme.openapi.export.openapiSpec",
message: "OpenAPI Spec",
})}
</a>
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import React, { useState } from "react";

import { translate } from "@docusaurus/Translate";
import FloatingButton from "@theme/ApiExplorer/FloatingButton";
import { OPENAPI_FORM_FILE_UPLOAD } from "@theme/translationIds";
import MagicDropzone from "react-magic-dropzone";

type PreviewFile = { preview: string } & File;
Expand Down Expand Up @@ -105,7 +104,7 @@ function FormFileUpload({ placeholder, onChange }: Props) {
}}
>
{translate({
id: OPENAPI_FORM_FILE_UPLOAD.CLEAR_BUTTON,
id: "theme.openapi.formFileUpload.clearButton",
message: "Clear",
})}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import React from "react";

import { translate } from "@docusaurus/Translate";
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";

export interface Props {
htmlFor?: string;
Expand All @@ -31,7 +30,7 @@ function FormLabel({ htmlFor, label, type, required }: Props) {
{required && (
<span className="openapi-schema__required">
{translate({
id: OPENAPI_SCHEMA_ITEM.REQUIRED,
id: "theme.openapi.schemaItem.required",
message: "required",
})}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import React, { useId } from "react";
import { translate } from "@docusaurus/Translate";
import { ErrorMessage } from "@hookform/error-message";
import FormLabel from "@theme/ApiExplorer/FormLabel";
import { OPENAPI_FORM } from "@theme/translationIds";
import clsx from "clsx";
import { useFormContext } from "react-hook-form";

Expand Down Expand Up @@ -59,7 +58,7 @@ function FormTextInput({
{...register(paramName, {
required: isRequired
? translate({
id: OPENAPI_FORM.FIELD_REQUIRED,
id: "theme.openapi.form.fieldRequired",
message: "This field is required",
})
: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { usePrismTheme } from "@docusaurus/theme-common";
import { translate } from "@docusaurus/Translate";
import useIsBrowser from "@docusaurus/useIsBrowser";
import { ErrorMessage } from "@hookform/error-message";
import { OPENAPI_FORM } from "@theme/translationIds";
import clsx from "clsx";
import { Controller, useFormContext } from "react-hook-form";
import { LiveProvider, LiveEditor, withLive } from "react-live";
Expand Down Expand Up @@ -89,7 +88,7 @@ function App({
required:
isRequired && !code
? translate({
id: OPENAPI_FORM.FIELD_REQUIRED,
id: "theme.openapi.form.fieldRequired",
message: "This field is required",
})
: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import FormSelect from "@theme/ApiExplorer/FormSelect";
import FormTextInput from "@theme/ApiExplorer/FormTextInput";
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
import { useTypedDispatch } from "@theme/ApiItem/hooks";
import { OPENAPI_FORM } from "@theme/translationIds";
import { Controller, useFormContext } from "react-hook-form";

export interface ParamProps {
Expand Down Expand Up @@ -138,7 +137,7 @@ export default function ParamArrayFormItem({
rules={{
required: param.required
? translate({
id: OPENAPI_FORM.FIELD_REQUIRED,
id: "theme.openapi.form.fieldRequired",
message: "This field is required",
})
: false,
Expand Down Expand Up @@ -177,7 +176,10 @@ export default function ParamArrayFormItem({
className="openapi-explorer__thin-btn"
onClick={handleAddItem}
>
Add item
{translate({
id: "theme.openapi.paramArray.addItem",
message: "Add item",
})}
</button>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { ErrorMessage } from "@hookform/error-message";
import FormSelect from "@theme/ApiExplorer/FormSelect";
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
import { useTypedDispatch } from "@theme/ApiItem/hooks";
import { OPENAPI_FORM } from "@theme/translationIds";
import { Controller, useFormContext } from "react-hook-form";

export interface ParamProps {
Expand Down Expand Up @@ -60,7 +59,7 @@ export default function ParamBooleanFormItem({
rules={{
required: param.required
? translate({
id: OPENAPI_FORM.FIELD_REQUIRED,
id: "theme.openapi.form.fieldRequired",
message: "This field is required",
})
: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import FormMultiSelect from "@theme/ApiExplorer/FormMultiSelect";
import { getSchemaEnum } from "@theme/ApiExplorer/ParamOptions";
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
import { OPENAPI_FORM } from "@theme/translationIds";
import { Controller, useFormContext } from "react-hook-form";

export interface ParamProps {
Expand Down Expand Up @@ -75,7 +74,7 @@ export default function ParamMultiSelectFormItem({
rules={{
required: param.required
? translate({
id: OPENAPI_FORM.FIELD_REQUIRED,
id: "theme.openapi.form.fieldRequired",
message: "This field is required",
})
: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import FormSelect from "@theme/ApiExplorer/FormSelect";
import { getSchemaEnum } from "@theme/ApiExplorer/ParamOptions";
import { Param, setParam } from "@theme/ApiExplorer/ParamOptions/slice";
import { useTypedDispatch } from "@theme/ApiItem/hooks";
import { OPENAPI_FORM } from "@theme/translationIds";
import { Controller, useFormContext } from "react-hook-form";

export interface ParamProps {
Expand Down Expand Up @@ -58,7 +57,7 @@ export default function ParamSelectFormItem({
rules={{
required: param.required
? translate({
id: OPENAPI_FORM.FIELD_REQUIRED,
id: "theme.openapi.form.fieldRequired",
message: "This field is required",
})
: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import ParamMultiSelectFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormI
import ParamSelectFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamSelectFormItem";
import ParamTextFormItem from "@theme/ApiExplorer/ParamOptions/ParamFormItems/ParamTextFormItem";
import { useTypedSelector } from "@theme/ApiItem/hooks";
import { OPENAPI_PARAM_OPTIONS } from "@theme/translationIds";

import { Param } from "./slice";

Expand Down Expand Up @@ -207,11 +206,11 @@ function ParamOptions() {
</span>
{showOptional
? translate({
id: OPENAPI_PARAM_OPTIONS.HIDE_OPTIONAL,
id: "theme.openapi.paramOptions.hideOptional",
message: "Hide optional parameters",
})
: translate({
id: OPENAPI_PARAM_OPTIONS.SHOW_OPTIONAL,
id: "theme.openapi.paramOptions.showOptional",
message: "Show optional parameters",
})}
</button>
Expand Down
Loading
Loading