diff --git a/demo/docusaurus.config.ts b/demo/docusaurus.config.ts
index b4a1baffb..5b27f4d69 100644
--- a/demo/docusaurus.config.ts
+++ b/demo/docusaurus.config.ts
@@ -22,6 +22,11 @@ const config: Config = {
organizationName: "PaloAltoNetworks",
projectName: "docusaurus-openapi-docs",
+ i18n: {
+ defaultLocale: "en",
+ locales: ["en", "ja"],
+ },
+
presets: [
[
"classic",
diff --git a/demo/i18n/en/code.json b/demo/i18n/en/code.json
new file mode 100644
index 000000000..204377bcc
--- /dev/null
+++ b/demo/i18n/en/code.json
@@ -0,0 +1,238 @@
+{
+ "theme.openapi.response.title": {
+ "message": "Response",
+ "description": "The label for response title"
+ },
+ "theme.openapi.response.clear": {
+ "message": "Clear",
+ "description": "The label for clear response button"
+ },
+ "theme.openapi.response.placeholder": {
+ "message": "Click the Send API Request button above and see the response here!",
+ "description": "The placeholder for response area"
+ },
+ "theme.openapi.response.headersTab": {
+ "message": "Headers",
+ "description": "The label for response headers tab"
+ },
+ "theme.openapi.tabs.responses.label": {
+ "message": "Responses",
+ "description": "The label for responses tab"
+ },
+ "theme.openapi.request.body.title": {
+ "message": "Body",
+ "description": "The title for request body section"
+ },
+ "theme.openapi.request.accept.title": {
+ "message": "Accept",
+ "description": "The title for accept header"
+ },
+ "theme.openapi.request.sendButton": {
+ "message": "Send API Request",
+ "description": "The label for send request button"
+ },
+ "theme.openapi.request.requiredLabel": {
+ "message": "required",
+ "description": "The label for required fields"
+ },
+ "theme.openapi.request.title": {
+ "message": "Request",
+ "description": "The title for request section"
+ },
+ "theme.openapi.request.collapseAll": {
+ "message": "Collapse all",
+ "description": "The label for collapse all button"
+ },
+ "theme.openapi.request.expandAll": {
+ "message": "Expand all",
+ "description": "The label for expand all button"
+ },
+ "theme.openapi.request.baseUrl.title": {
+ "message": "Base URL",
+ "description": "The title for base URL section"
+ },
+ "theme.openapi.request.auth.title": {
+ "message": "Auth",
+ "description": "The title for authentication section"
+ },
+ "theme.openapi.request.parameters.title": {
+ "message": "Parameters",
+ "description": "The title for parameters section"
+ },
+ "theme.openapi.request.fetchingMessage": {
+ "message": "Fetching...",
+ "description": "The message shown while fetching"
+ },
+ "theme.openapi.request.connectionFailed": {
+ "message": "Connection failed",
+ "description": "The message shown when connection fails"
+ },
+ "theme.openapi.server.editButton": {
+ "message": "Edit",
+ "description": "The label for edit server button"
+ },
+ "theme.openapi.server.hideButton": {
+ "message": "Hide",
+ "description": "The label for hide server button"
+ },
+ "theme.openapi.paramOptions.showOptional": {
+ "message": "Show optional parameters",
+ "description": "The label for show optional parameters button"
+ },
+ "theme.openapi.paramOptions.hideOptional": {
+ "message": "Hide optional parameters",
+ "description": "The label for hide optional parameters button"
+ },
+ "theme.openapi.formFileUpload.clearButton": {
+ "message": "Clear",
+ "description": "The label for clear file upload button"
+ },
+ "theme.openapi.form.fieldRequired": {
+ "message": "This field is required",
+ "description": "The message for required field validation"
+ },
+ "theme.openapi.auth.bearerToken": {
+ "message": "Bearer Token",
+ "description": "The label for bearer token"
+ },
+ "theme.openapi.auth.username": {
+ "message": "Username",
+ "description": "The label for username"
+ },
+ "theme.openapi.auth.password": {
+ "message": "Password",
+ "description": "The label for password"
+ },
+ "theme.openapi.auth.securityScheme": {
+ "message": "Security Scheme",
+ "description": "The label for security scheme"
+ },
+ "theme.openapi.responseExamples.example": {
+ "message": "Example",
+ "description": "The label for example"
+ },
+ "theme.openapi.responseExamples.autoExample": {
+ "message": "Example (auto)",
+ "description": "The label for auto-generated example"
+ },
+ "theme.openapi.body.exampleFromSchema": {
+ "message": "Example (from schema)",
+ "description": "The label for example from schema"
+ },
+ "theme.openapi.statusCodes.responseHeaders": {
+ "message": "Response Headers",
+ "description": "The label for response headers"
+ },
+ "theme.openapi.statusCodes.schemaTitle": {
+ "message": "Schema",
+ "description": "The title for schema section"
+ },
+ "theme.openapi.schema.noSchema": {
+ "message": "No schema",
+ "description": "The message when no schema is available"
+ },
+ "theme.openapi.schemaItem.required": {
+ "message": "required",
+ "description": "The label for required schema item"
+ },
+ "theme.openapi.schemaItem.deprecated": {
+ "message": "deprecated",
+ "description": "The label for deprecated schema item"
+ },
+ "theme.openapi.schemaItem.nullable": {
+ "message": "nullable",
+ "description": "The label for nullable schema item"
+ },
+ "theme.openapi.schemaItem.defaultValue": {
+ "message": "Default value:",
+ "description": "The label for default value"
+ },
+ "theme.openapi.schemaItem.example": {
+ "message": "Example:",
+ "description": "The label for example"
+ },
+ "theme.openapi.schemaItem.examples": {
+ "message": "Examples",
+ "description": "The label for examples"
+ },
+ "theme.openapi.schemaItem.description": {
+ "message": "Description",
+ "description": "The label for description"
+ },
+ "theme.openapi.schemaItem.constantValue": {
+ "message": "Constant value:",
+ "description": "The label for constant value"
+ },
+ "theme.openapi.schemaItem.enumValue": {
+ "message": "Enum Value",
+ "description": "The label for enum value"
+ },
+ "theme.openapi.schemaItem.enumDescription": {
+ "message": "Description",
+ "description": "The label for enum description"
+ },
+ "theme.openapi.schemaItem.possibleValues": {
+ "message": "Possible values:",
+ "description": "The label for possible values"
+ },
+ "theme.openapi.schemaItem.oneOf": {
+ "message": "oneOf",
+ "description": "The label for oneOf"
+ },
+ "theme.openapi.schemaItem.anyOf": {
+ "message": "anyOf",
+ "description": "The label for anyOf"
+ },
+ "theme.openapi.paramsDetails.parametersTitle": {
+ "message": "Parameters",
+ "description": "The title for parameters section"
+ },
+ "theme.openapi.securitySchemes.name": {
+ "message": "name:",
+ "description": "The label for security scheme name"
+ },
+ "theme.openapi.securitySchemes.type": {
+ "message": "type:",
+ "description": "The label for security scheme type"
+ },
+ "theme.openapi.securitySchemes.scopes": {
+ "message": "scopes:",
+ "description": "The label for security scheme scopes"
+ },
+ "theme.openapi.securitySchemes.in": {
+ "message": "in:",
+ "description": "The label for security scheme location"
+ },
+ "theme.openapi.securitySchemes.flows": {
+ "message": "flows:",
+ "description": "The label for security scheme flows"
+ },
+ "theme.openapi.securitySchemes.description": {
+ "message": "description:",
+ "description": "The label for security scheme description"
+ },
+ "theme.openapi.securitySchemes.scheme": {
+ "message": "scheme:",
+ "description": "The label for security scheme"
+ },
+ "theme.openapi.securitySchemes.bearerFormat": {
+ "message": "bearerFormat:",
+ "description": "The label for bearer format"
+ },
+ "theme.openapi.securitySchemes.openIdConnectUrl": {
+ "message": "openIdConnectUrl:",
+ "description": "The label for OpenID Connect URL"
+ },
+ "theme.openapi.schemaItem.expression": {
+ "message": "Value must match regular expression",
+ "description": "The label for expression"
+ },
+ "theme.openapi.schemaItem.characters": {
+ "message": "characters",
+ "description": "The label for characters"
+ },
+ "theme.openapi.schemaItem.nonEmpty": {
+ "message": "non-empty",
+ "description": "The label for non-empty"
+ }
+}
diff --git a/demo/i18n/ja/code.json b/demo/i18n/ja/code.json
new file mode 100644
index 000000000..7d183cd1b
--- /dev/null
+++ b/demo/i18n/ja/code.json
@@ -0,0 +1,238 @@
+{
+ "theme.openapi.response.title": {
+ "message": "レスポンス",
+ "description": "The label for response title"
+ },
+ "theme.openapi.response.clear": {
+ "message": "クリア",
+ "description": "The label for clear response button"
+ },
+ "theme.openapi.response.placeholder": {
+ "message": "レスポンスがここに表示されます",
+ "description": "The placeholder for response area"
+ },
+ "theme.openapi.response.headersTab": {
+ "message": "ヘッダー",
+ "description": "The label for response headers tab"
+ },
+ "theme.openapi.tabs.responses.label": {
+ "message": "レスポンス",
+ "description": "The label for responses tab"
+ },
+ "theme.openapi.request.body.title": {
+ "message": "ボディ",
+ "description": "The title for request body section"
+ },
+ "theme.openapi.request.accept.title": {
+ "message": "Accept",
+ "description": "The title for accept header"
+ },
+ "theme.openapi.request.sendButton": {
+ "message": "送信",
+ "description": "The label for send request button"
+ },
+ "theme.openapi.request.requiredLabel": {
+ "message": "必須",
+ "description": "The label for required fields"
+ },
+ "theme.openapi.request.title": {
+ "message": "リクエスト",
+ "description": "The title for request section"
+ },
+ "theme.openapi.request.collapseAll": {
+ "message": "すべて折りたたむ",
+ "description": "The label for collapse all button"
+ },
+ "theme.openapi.request.expandAll": {
+ "message": "すべて展開",
+ "description": "The label for expand all button"
+ },
+ "theme.openapi.request.baseUrl.title": {
+ "message": "ベースURL",
+ "description": "The title for base URL section"
+ },
+ "theme.openapi.request.auth.title": {
+ "message": "認証",
+ "description": "The title for authentication section"
+ },
+ "theme.openapi.request.parameters.title": {
+ "message": "パラメータ",
+ "description": "The title for parameters section"
+ },
+ "theme.openapi.request.fetchingMessage": {
+ "message": "リクエスト送信中...",
+ "description": "The message shown while fetching"
+ },
+ "theme.openapi.request.connectionFailed": {
+ "message": "接続に失敗しました",
+ "description": "The message shown when connection fails"
+ },
+ "theme.openapi.server.editButton": {
+ "message": "編集",
+ "description": "The label for edit server button"
+ },
+ "theme.openapi.server.hideButton": {
+ "message": "非表示",
+ "description": "The label for hide server button"
+ },
+ "theme.openapi.paramOptions.showOptional": {
+ "message": "オプションを表示",
+ "description": "The label for show optional parameters button"
+ },
+ "theme.openapi.paramOptions.hideOptional": {
+ "message": "オプションを非表示",
+ "description": "The label for hide optional parameters button"
+ },
+ "theme.openapi.formFileUpload.clearButton": {
+ "message": "クリア",
+ "description": "The label for clear file upload button"
+ },
+ "theme.openapi.form.fieldRequired": {
+ "message": "このフィールドは必須です",
+ "description": "The message for required field validation"
+ },
+ "theme.openapi.auth.bearerToken": {
+ "message": "Bearer Token",
+ "description": "The label for bearer token"
+ },
+ "theme.openapi.auth.username": {
+ "message": "ユーザー名",
+ "description": "The label for username"
+ },
+ "theme.openapi.auth.password": {
+ "message": "パスワード",
+ "description": "The label for password"
+ },
+ "theme.openapi.auth.securityScheme": {
+ "message": "セキュリティスキーム",
+ "description": "The label for security scheme"
+ },
+ "theme.openapi.responseExamples.example": {
+ "message": "例",
+ "description": "The label for example"
+ },
+ "theme.openapi.responseExamples.autoExample": {
+ "message": "例(自動)",
+ "description": "The label for auto-generated example"
+ },
+ "theme.openapi.body.exampleFromSchema": {
+ "message": "スキーマから生成された例",
+ "description": "The label for example from schema"
+ },
+ "theme.openapi.statusCodes.responseHeaders": {
+ "message": "レスポンスヘッダー",
+ "description": "The label for response headers"
+ },
+ "theme.openapi.statusCodes.schemaTitle": {
+ "message": "Schema",
+ "description": "The title for schema section"
+ },
+ "theme.openapi.schema.noSchema": {
+ "message": "スキーマがありません",
+ "description": "The message when no schema is available"
+ },
+ "theme.openapi.schemaItem.required": {
+ "message": "必須",
+ "description": "The label for required schema item"
+ },
+ "theme.openapi.schemaItem.deprecated": {
+ "message": "非推奨",
+ "description": "The label for deprecated schema item"
+ },
+ "theme.openapi.schemaItem.nullable": {
+ "message": "null許容",
+ "description": "The label for nullable schema item"
+ },
+ "theme.openapi.schemaItem.defaultValue": {
+ "message": "デフォルト値",
+ "description": "The label for default value"
+ },
+ "theme.openapi.schemaItem.example": {
+ "message": "例",
+ "description": "The label for example"
+ },
+ "theme.openapi.schemaItem.examples": {
+ "message": "例",
+ "description": "The label for examples"
+ },
+ "theme.openapi.schemaItem.description": {
+ "message": "説明",
+ "description": "The label for description"
+ },
+ "theme.openapi.schemaItem.constantValue": {
+ "message": "定数値",
+ "description": "The label for constant value"
+ },
+ "theme.openapi.schemaItem.enumValue": {
+ "message": "列挙値",
+ "description": "The label for enum value"
+ },
+ "theme.openapi.schemaItem.enumDescription": {
+ "message": "列挙値の説明",
+ "description": "The label for enum description"
+ },
+ "theme.openapi.schemaItem.possibleValues": {
+ "message": "使用可能な値",
+ "description": "The label for possible values"
+ },
+ "theme.openapi.schemaItem.oneOf": {
+ "message": "いずれか1つ",
+ "description": "The label for oneOf"
+ },
+ "theme.openapi.schemaItem.anyOf": {
+ "message": "いずれか",
+ "description": "The label for anyOf"
+ },
+ "theme.openapi.paramsDetails.parametersTitle": {
+ "message": "パラメータ",
+ "description": "The title for parameters section"
+ },
+ "theme.openapi.securitySchemes.name": {
+ "message": "名前",
+ "description": "The label for security scheme name"
+ },
+ "theme.openapi.securitySchemes.type": {
+ "message": "タイプ",
+ "description": "The label for security scheme type"
+ },
+ "theme.openapi.securitySchemes.scopes": {
+ "message": "スコープ",
+ "description": "The label for security scheme scopes"
+ },
+ "theme.openapi.securitySchemes.in": {
+ "message": "場所",
+ "description": "The label for security scheme location"
+ },
+ "theme.openapi.securitySchemes.flows": {
+ "message": "フロー",
+ "description": "The label for security scheme flows"
+ },
+ "theme.openapi.securitySchemes.description": {
+ "message": "説明",
+ "description": "The label for security scheme description"
+ },
+ "theme.openapi.securitySchemes.scheme": {
+ "message": "スキーム",
+ "description": "The label for security scheme"
+ },
+ "theme.openapi.securitySchemes.bearerFormat": {
+ "message": "Bearerフォーマット",
+ "description": "The label for bearer format"
+ },
+ "theme.openapi.securitySchemes.openIdConnectUrl": {
+ "message": "OpenID Connect URL",
+ "description": "The label for OpenID Connect URL"
+ },
+ "theme.openapi.schemaItem.expression": {
+ "message": "正規表現に一致する値",
+ "description": "The label for expression"
+ },
+ "theme.openapi.schemaItem.characters": {
+ "message": "文字",
+ "description": "The label for characters"
+ },
+ "theme.openapi.schemaItem.nonEmpty": {
+ "message": "空でない文字列",
+ "description": "The label for non-empty"
+ }
+}
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..62c94cc32 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
@@ -22,7 +22,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`nose\`]\\"}
schema={{ type: \\"string\\", enum: [\\"nose\\"] }}
>
@@ -32,7 +31,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`mouth\`]\\"}
schema={{ type: \\"string\\", enum: [\\"mouth\\"] }}
>
@@ -42,7 +40,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`eyes\`]\\"}
schema={{ type: \\"string\\", enum: [\\"eyes\\"] }}
>
@@ -61,7 +57,6 @@ Array [
name={\\"description\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{
type: \\"string\\",
description: \\"Description of the body part.\\",
@@ -102,7 +97,6 @@ Array [
name={\\"a\\"}
required={false}
schemaName={\\"\\"}
- qualifierMessage={undefined}
schema={\\"string\\"}
>
@@ -137,7 +130,6 @@ Array [
name={\\"property name*\\"}
required={false}
schemaName={\\"boolean\\"}
- qualifierMessage={undefined}
schema={{ type: \\"boolean\\" }}
collapsible={false}
discriminator={false}
@@ -152,7 +144,6 @@ Array [
name={\\"property name*\\"}
required={false}
schemaName={\\"integer\\"}
- qualifierMessage={undefined}
schema={{ type: \\"integer\\" }}
collapsible={false}
discriminator={false}
@@ -167,7 +158,6 @@ Array [
name={\\"property name*\\"}
required={false}
schemaName={\\"number\\"}
- qualifierMessage={undefined}
schema={{ type: \\"number\\" }}
collapsible={false}
discriminator={false}
@@ -182,7 +172,6 @@ Array [
name={\\"property name*\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
collapsible={false}
discriminator={false}
@@ -197,7 +186,6 @@ Array [
name={\\"property name*\\"}
required={false}
schemaName={\\"any\\"}
- qualifierMessage={undefined}
schema={{ type: \\"object\\", additionalProperties: {} }}
collapsible={false}
discriminator={false}
@@ -214,7 +202,6 @@ Array [
name={\\"property name*\\"}
required={false}
schemaName={\\"any\\"}
- qualifierMessage={undefined}
schema={{ type: \\"object\\", additionalProperties: true }}
collapsible={false}
discriminator={false}
@@ -239,7 +226,6 @@ Array [
name={\\"innerProp1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -264,7 +249,6 @@ Array [
name={\\"sharedProp\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -273,7 +257,6 @@ Array [
name={\\"anotherProp\\"}
required={true}
schemaName={\\"number\\"}
- qualifierMessage={undefined}
schema={{ type: \\"number\\" }}
>;
",
@@ -296,7 +279,6 @@ Array [
name={\\"innerProp1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -317,7 +299,6 @@ Array [
name={\\"innerProp2\\"}
required={false}
schemaName={\\"number\\"}
- qualifierMessage={undefined}
schema={{ type: \\"number\\" }}
>
@@ -334,7 +315,6 @@ Array [
name={\\"parentProp1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -343,7 +323,6 @@ Array [
name={\\"parentProp2\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -352,7 +331,6 @@ Array [
name={\\"allOfProp1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -361,7 +339,6 @@ Array [
name={\\"allOfProp2\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -370,7 +347,6 @@ Array [
name={\\"parentProp1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -379,7 +355,6 @@ Array [
name={\\"parentProp2\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -486,7 +461,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -504,7 +477,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -529,9 +500,6 @@ Array [
string
-
- **Possible values:** [\`typeA\`, \`typeB\`]
-
@@ -563,7 +531,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -581,7 +547,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -601,7 +565,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -621,7 +584,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -639,7 +600,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -659,7 +618,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -673,7 +631,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -688,7 +645,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -706,7 +661,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -726,7 +679,6 @@ Array [
name={\\"sharedProp\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -735,7 +687,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -754,9 +705,6 @@ Array [
string
-
- **Possible values:** [\`typeA\`, \`typeB\`]
-
@@ -783,7 +731,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -801,7 +747,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -821,7 +765,6 @@ Array [
name={\\"sharedProp\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -835,9 +778,6 @@ Array [
string
-
- **Possible values:** [\`typeA\`, \`typeB\`]
-
@@ -869,7 +809,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -886,7 +825,6 @@ Array [
name={\\"propA1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -907,7 +844,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -924,7 +860,6 @@ Array [
name={\\"propB1\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -947,7 +881,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -967,7 +900,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -985,7 +916,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -1005,7 +934,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -1025,7 +953,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -1043,7 +969,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -1068,9 +992,6 @@ Array [
string
-
- **Possible values:** [\`typeA\`, \`typeB\`]
-
@@ -1102,7 +1023,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -1120,7 +1039,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -1140,7 +1057,6 @@ Array [
name={\\"type\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -1149,7 +1065,6 @@ Array [
name={\\"sharedProp\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -1169,7 +1084,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeA\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeA\\"] }}
>
@@ -1187,7 +1100,6 @@ Array [
name={\\"type\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={\\"**Possible values:** [\`typeB\`]\\"}
schema={{ type: \\"string\\", enum: [\\"typeB\\"] }}
>
@@ -1212,9 +1123,6 @@ Array [
string
-
- **Possible values:** [\`typeA\`, \`typeB\`]
-
@@ -1235,7 +1143,6 @@ Array [
name={\\"sharedProp\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -1270,7 +1177,6 @@ Array [
name={\\"noseLength\\"}
required={true}
schemaName={\\"number\\"}
- qualifierMessage={undefined}
schema={{ type: \\"number\\" }}
>
@@ -1424,7 +1330,6 @@ Array [
name={\\"objectProp\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -1527,7 +1432,6 @@ Array [
name={\\"requiredPropA\\"}
required={true}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -1537,7 +1441,6 @@ Array [
name={\\"requiredPropB\\"}
required={true}
schemaName={\\"number\\"}
- qualifierMessage={undefined}
schema={{ type: \\"number\\" }}
>
@@ -1557,7 +1460,6 @@ Array [
name={\\"sharedProp\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>;
",
@@ -1581,7 +1483,6 @@ Array [
name={\\"specificPropA\\"}
required={false}
schemaName={\\"string\\"}
- qualifierMessage={undefined}
schema={{ type: \\"string\\" }}
>
@@ -1591,7 +1492,6 @@ Array [
name={\\"specificPropB\\"}
required={false}
schemaName={\\"number\\"}
- qualifierMessage={undefined}
schema={{ type: \\"number\\" }}
>
diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts
index 7315baa6b..3b4fca0a9 100644
--- a/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts
+++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/createSchema.ts
@@ -17,7 +17,7 @@ import {
import { createDescription } from "./createDescription";
import { createDetails } from "./createDetails";
import { createDetailsSummary } from "./createDetailsSummary";
-import { getQualifierMessage, getSchemaName } from "./schema";
+import { getSchemaName } from "./schema";
import { create, guard } from "./utils";
import { SchemaObject } from "../openapi/types";
@@ -140,7 +140,6 @@ function createProperties(schema: SchemaObject) {
name: "",
required: false,
schemaName: "object",
- qualifierMessage: undefined,
schema: {},
});
}
@@ -169,7 +168,6 @@ function createAdditionalProperties(schema: SchemaObject) {
name: "property name*",
required: false,
schemaName: "any",
- qualifierMessage: getQualifierMessage(schema),
schema: schema,
collapsible: false,
discriminator: false,
@@ -209,7 +207,6 @@ function createAdditionalProperties(schema: SchemaObject) {
name: "property name*",
required: false,
schemaName: schemaName,
- qualifierMessage: getQualifierMessage(schema),
schema: additionalProperties,
collapsible: false,
discriminator: false,
@@ -399,12 +396,6 @@ function createDetailsNode(
children: createDescription(description),
})
),
- guard(getQualifierMessage(schema), (message) =>
- create("div", {
- style: { marginTop: ".5rem", marginBottom: ".5rem" },
- children: createDescription(message),
- })
- ),
createNodes(schema, SCHEMA_TYPE),
],
}),
@@ -545,14 +536,6 @@ function createPropertyDiscriminator(
children: createDescription(description),
})
),
- guard(getQualifierMessage(discriminator), (message) =>
- create("div", {
- style: {
- paddingLeft: "1rem",
- },
- children: createDescription(message),
- })
- ),
create("DiscriminatorTabs", {
className: "openapi-tabs__discriminator",
children: Object.keys(discriminator?.mapping!).map((key, index) => {
@@ -727,7 +710,6 @@ function createEdges({
name,
required: Array.isArray(required) ? required.includes(name) : required,
schemaName: mergedSchemaName,
- qualifierMessage: getQualifierMessage(mergedSchemas),
schema: mergedSchemas,
});
}
@@ -738,7 +720,6 @@ function createEdges({
name,
required: Array.isArray(required) ? required.includes(name) : required,
schemaName: schemaName,
- qualifierMessage: getQualifierMessage(schema),
schema: schema,
});
}
@@ -823,17 +804,7 @@ export function createNodes(
marginTop: ".5rem",
marginBottom: ".5rem",
},
- children: [
- createDescription(schema.type),
- guard(getQualifierMessage(schema), (message) =>
- create("div", {
- style: {
- paddingTop: "1rem",
- },
- children: createDescription(message),
- })
- ),
- ],
+ children: [createDescription(schema.type)],
});
}
@@ -844,17 +815,7 @@ export function createNodes(
marginTop: ".5rem",
marginBottom: ".5rem",
},
- children: [
- createDescription(schema),
- guard(getQualifierMessage(schema), (message) =>
- create("div", {
- style: {
- paddingTop: "1rem",
- },
- children: createDescription(message),
- })
- ),
- ],
+ children: [createDescription(schema)],
});
}
diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts
deleted file mode 100644
index daa3a633d..000000000
--- a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.test.ts
+++ /dev/null
@@ -1,208 +0,0 @@
-/* ============================================================================
- * Copyright (c) Palo Alto Networks
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- * ========================================================================== */
-
-import { getQualifierMessage } from "./schema";
-
-describe("getQualifierMessage", () => {
- it("should render nothing", () => {
- const actual = getQualifierMessage({});
- expect(actual).toBeUndefined();
- });
-
- //
- // minLength + maxLength
- //
- it("should render minLength", () => {
- const expected = "**Possible values:** `non-empty`";
- const actual = getQualifierMessage({ minLength: 1 });
- expect(actual).toBe(expected);
- });
-
- it("should render maxLength", () => {
- const expected = "**Possible values:** `<= 40 characters`";
- const actual = getQualifierMessage({ maxLength: 40 });
- expect(actual).toBe(expected);
- });
-
- it("should render minLength and maxLength", () => {
- const expected = "**Possible values:** `non-empty` and `<= 40 characters`";
- const actual = getQualifierMessage({ minLength: 1, maxLength: 40 });
- expect(actual).toBe(expected);
- });
-
- //
- // pattern
- //
- it("should render pattern", () => {
- const expected =
- "**Possible values:** Value must match regular expression `^[a-zA-Z0-9_-]*$`";
- const actual = getQualifierMessage({ pattern: "^[a-zA-Z0-9_-]*$" });
- expect(actual).toBe(expected);
- });
-
- it("should render multiple string qualifiers", () => {
- const expected =
- "**Possible values:** `non-empty` and `<= 40 characters`, Value must match regular expression `^[a-zA-Z0-9_-]*$`";
- const actual = getQualifierMessage({
- minLength: 1,
- maxLength: 40,
- pattern: "^[a-zA-Z0-9_-]*$",
- });
- expect(actual).toBe(expected);
- });
-
- //
- // enum
- //
- it("should render enum", () => {
- const expected = "**Possible values:** [`cat`, `dog`, `mouse`]";
- const actual = getQualifierMessage({ enum: ["cat", "dog", "mouse"] });
- expect(actual).toBe(expected);
- });
-
- //
- // minimum + maximum + exclusiveMinimum + exclusiveMaximum
- //
- it("should render minimum", () => {
- const expected = "**Possible values:** `>= 1`";
- const actual = getQualifierMessage({ minimum: 1 });
- expect(actual).toBe(expected);
- });
-
- it("should render maximum", () => {
- const expected = "**Possible values:** `<= 40`";
- const actual = getQualifierMessage({ maximum: 40 });
- expect(actual).toBe(expected);
- });
-
- it("should render numeric exclusiveMinimum", () => {
- const expected = "**Possible values:** `> 1`";
- const actual = getQualifierMessage({ exclusiveMinimum: 1 });
- expect(actual).toBe(expected);
- });
-
- it("should render numeric exclusiveMaximum", () => {
- const expected = "**Possible values:** `< 40`";
- const actual = getQualifierMessage({ exclusiveMaximum: 40 });
- expect(actual).toBe(expected);
- });
-
- it("should render boolean exclusiveMinimum", () => {
- const expected = "**Possible values:** `> 1`";
- const actual = getQualifierMessage({ minimum: 1, exclusiveMinimum: true });
- expect(actual).toBe(expected);
- });
-
- it("should render boolean exclusiveMaximum", () => {
- const expected = "**Possible values:** `< 40`";
- const actual = getQualifierMessage({ maximum: 40, exclusiveMaximum: true });
- expect(actual).toBe(expected);
- });
-
- it("should render minimum when exclusiveMinimum is false", () => {
- const expected = "**Possible values:** `>= 1`";
- const actual = getQualifierMessage({ minimum: 1, exclusiveMinimum: false });
- expect(actual).toBe(expected);
- });
-
- it("should render maximum when exclusiveMaximum is false", () => {
- const expected = "**Possible values:** `<= 40`";
- const actual = getQualifierMessage({
- maximum: 40,
- exclusiveMaximum: false,
- });
- expect(actual).toBe(expected);
- });
-
- it("should render minimum and maximum", () => {
- const expected = "**Possible values:** `>= 1` and `<= 40`";
- const actual = getQualifierMessage({ minimum: 1, maximum: 40 });
- expect(actual).toBe(expected);
- });
-
- it("should render 0 minimum and maximum", () => {
- const expected = "**Possible values:** `>= 0` and `<= 40`";
- const actual = getQualifierMessage({ minimum: 0, maximum: 40 });
- expect(actual).toBe(expected);
- });
-
- it("should render minimum and 0 maximum", () => {
- const expected = "**Possible values:** `>= -10` and `<= 0`";
- const actual = getQualifierMessage({ minimum: -10, maximum: 0 });
- expect(actual).toBe(expected);
- });
-
- it("should render boolean exclusiveMinimum and maximum", () => {
- const expected = "**Possible values:** `> 1` and `<= 40`";
- const actual = getQualifierMessage({
- minimum: 1,
- maximum: 40,
- exclusiveMinimum: true,
- });
- expect(actual).toBe(expected);
- });
-
- it("should render minimum and boolean exclusiveMaximum", () => {
- const expected = "**Possible values:** `>= 1` and `< 40`";
- const actual = getQualifierMessage({
- minimum: 1,
- maximum: 40,
- exclusiveMaximum: true,
- });
- expect(actual).toBe(expected);
- });
-
- it("should render numeric exclusiveMinimum and maximum", () => {
- const expected = "**Possible values:** `> 1` and `<= 40`";
- const actual = getQualifierMessage({
- exclusiveMinimum: 1,
- maximum: 40,
- });
- expect(actual).toBe(expected);
- });
-
- it("should render minimum and numeric exclusiveMaximum", () => {
- const expected = "**Possible values:** `>= 1` and `< 40`";
- const actual = getQualifierMessage({
- minimum: 1,
- exclusiveMaximum: 40,
- });
- expect(actual).toBe(expected);
- });
-
- it("should render numeric exclusiveMinimum and boolean exclusiveMaximum", () => {
- const expected = "**Possible values:** `> 1` and `< 40`";
- const actual = getQualifierMessage({
- exclusiveMinimum: 1,
- maximum: 40,
- exclusiveMaximum: true,
- });
- expect(actual).toBe(expected);
- });
-
- it("should render nothing with empty boolean exclusiveMinimum", () => {
- const actual = getQualifierMessage({
- exclusiveMinimum: true,
- });
- expect(actual).toBeUndefined();
- });
-
- it("should render nothing with empty boolean exclusiveMaximum", () => {
- const actual = getQualifierMessage({
- exclusiveMaximum: true,
- });
- expect(actual).toBeUndefined();
- });
-
- it("should render nothing with empty boolean exclusiveMinimum and exclusiveMaximum", () => {
- const actual = getQualifierMessage({
- exclusiveMinimum: true,
- exclusiveMaximum: true,
- });
- expect(actual).toBeUndefined();
- });
-});
diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts
index 185019c17..bd23556a7 100644
--- a/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts
+++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/schema.ts
@@ -60,129 +60,3 @@ export function getSchemaName(
return prettyName(schema, circular) ?? "";
}
-
-export function getQualifierMessage(schema?: SchemaObject): string | undefined {
- // TODO:
- // - uniqueItems
- // - maxProperties
- // - minProperties
- // - multipleOf
- if (!schema) {
- return undefined;
- }
-
- if (
- schema.items &&
- schema.minItems === undefined &&
- schema.maxItems === undefined
- ) {
- return getQualifierMessage(schema.items);
- }
-
- let message = "**Possible values:** ";
-
- let qualifierGroups = [];
-
- if (schema.items && schema.items.enum) {
- if (schema.items.enum) {
- qualifierGroups.push(
- `[${schema.items.enum.map((e) => `\`${e}\``).join(", ")}]`
- );
- }
- }
-
- if (schema.minLength || schema.maxLength) {
- let lengthQualifier = "";
- let minLength;
- let maxLength;
- if (schema.minLength && schema.minLength > 1) {
- minLength = `\`>= ${schema.minLength} characters\``;
- }
- if (schema.minLength && schema.minLength === 1) {
- minLength = `\`non-empty\``;
- }
- if (schema.maxLength) {
- maxLength = `\`<= ${schema.maxLength} characters\``;
- }
-
- if (minLength && !maxLength) {
- lengthQualifier += minLength;
- }
- if (maxLength && !minLength) {
- lengthQualifier += maxLength;
- }
- if (minLength && maxLength) {
- lengthQualifier += `${minLength} and ${maxLength}`;
- }
-
- qualifierGroups.push(lengthQualifier);
- }
-
- if (
- schema.minimum != null ||
- schema.maximum != null ||
- typeof schema.exclusiveMinimum === "number" ||
- typeof schema.exclusiveMaximum === "number"
- ) {
- let minmaxQualifier = "";
- let minimum;
- let maximum;
- if (typeof schema.exclusiveMinimum === "number") {
- minimum = `\`> ${schema.exclusiveMinimum}\``;
- } else if (schema.minimum != null && !schema.exclusiveMinimum) {
- minimum = `\`>= ${schema.minimum}\``;
- } else if (schema.minimum != null && schema.exclusiveMinimum === true) {
- minimum = `\`> ${schema.minimum}\``;
- }
- if (typeof schema.exclusiveMaximum === "number") {
- maximum = `\`< ${schema.exclusiveMaximum}\``;
- } else if (schema.maximum != null && !schema.exclusiveMaximum) {
- maximum = `\`<= ${schema.maximum}\``;
- } else if (schema.maximum != null && schema.exclusiveMaximum === true) {
- maximum = `\`< ${schema.maximum}\``;
- }
-
- if (minimum && !maximum) {
- minmaxQualifier += minimum;
- }
- if (maximum && !minimum) {
- minmaxQualifier += maximum;
- }
- if (minimum && maximum) {
- minmaxQualifier += `${minimum} and ${maximum}`;
- }
-
- qualifierGroups.push(minmaxQualifier);
- }
-
- if (schema.pattern) {
- qualifierGroups.push(
- `Value must match regular expression \`${schema.pattern}\``
- );
- }
-
- // Check if discriminator mapping
- const discriminator = schema as any;
- if (discriminator.mapping) {
- const values = Object.keys(discriminator.mapping);
- qualifierGroups.push(`[${values.map((e) => `\`${e}\``).join(", ")}]`);
- }
-
- if (schema.enum) {
- qualifierGroups.push(`[${schema.enum.map((e) => `\`${e}\``).join(", ")}]`);
- }
-
- if (schema.minItems) {
- qualifierGroups.push(`\`>= ${schema.minItems}\``);
- }
-
- if (schema.maxItems) {
- qualifierGroups.push(`\`<= ${schema.maxItems}\``);
- }
-
- if (qualifierGroups.length === 0) {
- return undefined;
- }
-
- return message + qualifierGroups.join(", ");
-}
diff --git a/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts b/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts
index c4dfe1663..43d912474 100644
--- a/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts
+++ b/packages/docusaurus-plugin-openapi-docs/src/markdown/utils.ts
@@ -24,7 +24,9 @@ export function create(
let propString = "";
for (const [key, value] of Object.entries(rest)) {
- propString += `\n ${key}={${JSON.stringify(value)}}`;
+ if (value !== undefined) {
+ propString += `\n ${key}={${JSON.stringify(value)}}`;
+ }
}
let indentedChildren = render(children).replace(/^/gm, " ");
diff --git a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts
index 5c569169a..f4050dc1a 100644
--- a/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts
+++ b/packages/docusaurus-plugin-openapi-docs/src/openapi/utils/utils/openapi.ts
@@ -450,116 +450,6 @@ export function getDefinitionName(pointer?: string): string | undefined {
return name;
}
-function humanizeMultipleOfConstraint(
- multipleOf: number | undefined
-): string | undefined {
- if (multipleOf === undefined) {
- return;
- }
- const strigifiedMultipleOf = multipleOf.toString(10);
- if (!/^0\.0*1$/.test(strigifiedMultipleOf)) {
- return `multiple of ${strigifiedMultipleOf}`;
- }
- return `decimal places <= ${strigifiedMultipleOf.split(".")[1].length}`;
-}
-
-function humanizeRangeConstraint(
- description: string,
- min: number | undefined,
- max: number | undefined
-): string | undefined {
- let stringRange;
- if (min !== undefined && max !== undefined) {
- if (min === max) {
- stringRange = `= ${min} ${description}`;
- } else {
- stringRange = `[ ${min} .. ${max} ] ${description}`;
- }
- } else if (max !== undefined) {
- stringRange = `<= ${max} ${description}`;
- } else if (min !== undefined) {
- if (min === 1) {
- stringRange = "non-empty";
- } else {
- stringRange = `>= ${min} ${description}`;
- }
- }
-
- return stringRange;
-}
-
-export function humanizeNumberRange(schema: OpenAPISchema): string | undefined {
- const minimum =
- typeof schema.exclusiveMinimum === "number"
- ? Math.min(schema.exclusiveMinimum, schema.minimum ?? Infinity)
- : schema.minimum;
- const maximum =
- typeof schema.exclusiveMaximum === "number"
- ? Math.max(schema.exclusiveMaximum, schema.maximum ?? -Infinity)
- : schema.maximum;
- const exclusiveMinimum =
- typeof schema.exclusiveMinimum === "number" || schema.exclusiveMinimum;
- const exclusiveMaximum =
- typeof schema.exclusiveMaximum === "number" || schema.exclusiveMaximum;
-
- if (minimum !== undefined && maximum !== undefined) {
- return `${exclusiveMinimum ? "( " : "[ "}${minimum} .. ${maximum}${
- exclusiveMaximum ? " )" : " ]"
- }`;
- } else if (maximum !== undefined) {
- return `${exclusiveMaximum ? "< " : "<= "}${maximum}`;
- } else if (minimum !== undefined) {
- return `${exclusiveMinimum ? "> " : ">= "}${minimum}`;
- }
-}
-
-export function humanizeConstraints(schema: OpenAPISchema): string[] {
- const res: string[] = [];
-
- const stringRange = humanizeRangeConstraint(
- "characters",
- schema.minLength,
- schema.maxLength
- );
- if (stringRange !== undefined) {
- res.push(stringRange);
- }
-
- const arrayRange = humanizeRangeConstraint(
- "items",
- schema.minItems,
- schema.maxItems
- );
- if (arrayRange !== undefined) {
- res.push(arrayRange);
- }
-
- const propertiesRange = humanizeRangeConstraint(
- "properties",
- schema.minProperties,
- schema.maxProperties
- );
- if (propertiesRange !== undefined) {
- res.push(propertiesRange);
- }
-
- const multipleOfConstraint = humanizeMultipleOfConstraint(schema.multipleOf);
- if (multipleOfConstraint !== undefined) {
- res.push(multipleOfConstraint);
- }
-
- const numberRange = humanizeNumberRange(schema);
- if (numberRange !== undefined) {
- res.push(numberRange);
- }
-
- if (schema.uniqueItems) {
- res.push("unique");
- }
-
- return res;
-}
-
export function sortByRequired(fields: any[], order: string[] = []) {
const unrequiredFields: any[] = [];
const orderedFields: any[] = [];
diff --git a/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts b/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts
index b14bea631..818115130 100644
--- a/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts
+++ b/packages/docusaurus-theme-openapi-docs/src/markdown/schema.ts
@@ -6,6 +6,7 @@
* ========================================================================== */
import { translate } from "@docusaurus/Translate";
+
import { OPENAPI_SCHEMA_ITEM } from "../theme/translationIds";
import { SchemaObject } from "../types";
@@ -94,13 +95,25 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
let minLength;
let maxLength;
if (schema.minLength && schema.minLength > 1) {
- minLength = `\`>= ${schema.minLength} characters\``;
+ const charactersMessage = translate({
+ id: OPENAPI_SCHEMA_ITEM.CHARACTERS,
+ message: "characters",
+ });
+ minLength = `\`>= ${schema.minLength} ${charactersMessage}\``;
}
if (schema.minLength && schema.minLength === 1) {
- minLength = `\`non-empty\``;
+ const nonEmptyMessage = translate({
+ id: OPENAPI_SCHEMA_ITEM.NON_EMPTY,
+ message: "non-empty",
+ });
+ minLength = `\`${nonEmptyMessage}\``;
}
if (schema.maxLength) {
- maxLength = `\`<= ${schema.maxLength} characters\``;
+ const charactersMessage = translate({
+ id: OPENAPI_SCHEMA_ITEM.CHARACTERS,
+ message: "characters",
+ });
+ maxLength = `\`<= ${schema.maxLength} ${charactersMessage}\``;
}
if (minLength && !maxLength) {
@@ -154,9 +167,11 @@ export function getQualifierMessage(schema?: SchemaObject): string | undefined {
}
if (schema.pattern) {
- qualifierGroups.push(
- `Value must match regular expression \`${schema.pattern}\``
- );
+ const expressionMessage = translate({
+ id: OPENAPI_SCHEMA_ITEM.EXPRESSION,
+ message: "Value must match regular expression",
+ });
+ qualifierGroups.push(`${expressionMessage} \`${schema.pattern}\``);
}
// Check if discriminator mapping
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx
index 6fa457223..0aa0fa95d 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/RequestSchema/index.tsx
@@ -7,18 +7,19 @@
import React from "react";
-import { translate } from "@docusaurus/Translate";
-import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
-
import BrowserOnly from "@docusaurus/BrowserOnly";
+import { translate } from "@docusaurus/Translate";
import Details from "@theme/Details";
import Markdown from "@theme/Markdown";
import MimeTabs from "@theme/MimeTabs"; // Assume these components exist
import SchemaNode from "@theme/Schema";
import SkeletonLoader from "@theme/SkeletonLoader";
import TabItem from "@theme/TabItem";
+import { OPENAPI_REQUEST, OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
import { MediaTypeObject } from "docusaurus-plugin-openapi-docs/lib/openapi/types";
+import { SchemaObject } from "../../types";
+
interface Props {
style?: React.CSSProperties;
title: string;
@@ -55,6 +56,7 @@ const RequestSchemaComponent: React.FC
= ({ title, body, style }) => {
) {
return null;
}
+
return (
// @ts-ignore
@@ -92,7 +94,10 @@ const RequestSchemaComponent: React.FC = ({ title, body, style }) => {
)}
@@ -151,7 +156,10 @@ const RequestSchemaComponent: React.FC = ({ title, body, style }) => {
)}
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/ResponseHeaders/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/ResponseHeaders/index.tsx
index d8f2158dd..882089bdd 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/ResponseHeaders/index.tsx
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/ResponseHeaders/index.tsx
@@ -9,7 +9,7 @@ import React from "react";
import SchemaItem from "@theme/SchemaItem";
-import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
+import { getSchemaName } from "../../markdown/schema";
interface ResponseHeadersProps {
description?: string;
@@ -35,7 +35,6 @@ export const ResponseHeaders: React.FC<{
name={name}
collapsible={false}
schemaName={getSchemaName(schema)}
- qualifierMessage={getQualifierMessage(schema)}
schema={schema}
discriminator={false}
children={null}
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx
index 106aabcd1..31a30d40d 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/Schema/index.tsx
@@ -8,8 +8,6 @@
import React from "react";
import { translate } from "@docusaurus/Translate";
-import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
-
import { ClosingArrayBracket, OpeningArrayBracket } from "@theme/ArrayBrackets";
import Details from "@theme/Details";
import DiscriminatorTabs from "@theme/DiscriminatorTabs";
@@ -17,19 +15,15 @@ import Markdown from "@theme/Markdown";
import SchemaItem from "@theme/SchemaItem";
import SchemaTabs from "@theme/SchemaTabs";
import TabItem from "@theme/TabItem";
+import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
// eslint-disable-next-line import/no-extraneous-dependencies
import { merge } from "allof-merge";
import clsx from "clsx";
-import {
- getQualifierMessage,
- getSchemaName,
-} from "docusaurus-plugin-openapi-docs/lib/markdown/schema";
-import {
- SchemaObject,
- SchemaType,
-} from "docusaurus-plugin-openapi-docs/lib/openapi/types";
import isEmpty from "lodash/isEmpty";
+import { getQualifierMessage, getSchemaName } from "../../markdown/schema";
+import { SchemaObject } from "../../types";
+
// eslint-disable-next-line import/no-extraneous-dependencies
// const jsonSchemaMergeAllOf = require("json-schema-merge-allof");
@@ -153,7 +147,6 @@ const AnyOneOf: React.FC = ({ schema, schemaType }) => {
collapsible={false}
name={undefined}
schemaName={anyOneSchema.type}
- qualifierMessage={getQualifierMessage(anyOneSchema)}
schema={anyOneSchema}
discriminator={false}
children={null}
@@ -170,7 +163,6 @@ const AnyOneOf: React.FC = ({ schema, schemaType }) => {
collapsible={false}
name={undefined}
schemaName={anyOneSchema.type}
- qualifierMessage={getQualifierMessage(anyOneSchema)}
schema={anyOneSchema}
discriminator={false}
children={null}
@@ -437,7 +429,6 @@ const AdditionalProperties: React.FC = ({
name="property name*"
required={false}
schemaName="any"
- qualifierMessage={getQualifierMessage(schema)}
schema={schema}
collapsible={false}
discriminator={false}
@@ -483,7 +474,6 @@ const AdditionalProperties: React.FC = ({
name="property name*"
required={false}
schemaName={schemaName}
- qualifierMessage={getQualifierMessage(schema)}
schema={additionalProperties}
collapsible={false}
discriminator={false}
@@ -576,7 +566,6 @@ const Items: React.FC<{
collapsible={false}
name="" // No name for array items
schemaName={getSchemaName(itemsSchema)}
- qualifierMessage={getQualifierMessage(itemsSchema)}
schema={itemsSchema}
discriminator={false}
children={null}
@@ -798,7 +787,6 @@ const SchemaEdge: React.FC = ({
name={name}
required={Array.isArray(required) ? required.includes(name) : required}
schemaName={mergedSchemaName}
- qualifierMessage={getQualifierMessage(mergedSchemas)}
schema={mergedSchemas}
discriminator={false}
children={null}
@@ -812,7 +800,6 @@ const SchemaEdge: React.FC = ({
name={name}
required={Array.isArray(required) ? required.includes(name) : required}
schemaName={schemaName}
- qualifierMessage={getQualifierMessage(schema)}
schema={schema}
discriminator={false}
children={null}
@@ -904,7 +891,6 @@ const SchemaNode: React.FC = ({ schema, schemaType }) => {
name={schema.type}
required={Boolean(schema.required)}
schemaName={schemaName}
- qualifierMessage={getQualifierMessage(schema)}
schema={schema}
discriminator={false}
children={null}
@@ -917,7 +903,9 @@ const SchemaNode: React.FC = ({ schema, schemaType }) => {
export default SchemaNode;
-type PrimitiveSchemaType = Exclude;
+type PrimitiveSchemaType =
+ | Exclude, "object" | "array">
+ | "null";
const PRIMITIVE_TYPES: Record = {
string: true,
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx b/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx
index 7b311fc86..7d9813b28 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/SchemaItem/index.tsx
@@ -7,11 +7,12 @@
import React, { ReactNode } from "react";
-import Markdown from "@theme/Markdown";
-import clsx from "clsx";
import { translate } from "@docusaurus/Translate";
+import Markdown from "@theme/Markdown";
import { OPENAPI_SCHEMA_ITEM } from "@theme/translationIds";
+import clsx from "clsx";
+import { getQualifierMessage } from "../../markdown/schema";
import { guard } from "../../markdown/utils";
export interface Props {
@@ -127,7 +128,11 @@ export default function SchemaItem(props: Props) {
>
));
- const renderQualifierMessage = guard(qualifierMessage, (message) => (
+ // Generate qualifierMessage from schema if not provided
+ const effectiveQualifierMessage =
+ qualifierMessage ?? (schema ? getQualifierMessage(schema) : undefined);
+
+ const renderQualifierMessage = guard(effectiveQualifierMessage, (message) => (
<>
{message}
>
diff --git a/packages/docusaurus-theme-openapi-docs/src/theme/translationIds.ts b/packages/docusaurus-theme-openapi-docs/src/theme/translationIds.ts
index 46e47bab4..c6e6cbd86 100644
--- a/packages/docusaurus-theme-openapi-docs/src/theme/translationIds.ts
+++ b/packages/docusaurus-theme-openapi-docs/src/theme/translationIds.ts
@@ -71,6 +71,8 @@ export const OPENAPI_STATUS_CODES = {
};
export const OPENAPI_SCHEMA_ITEM = {
+ CHARACTERS: "theme.openapi.schemaItem.characters",
+ NON_EMPTY: "theme.openapi.schemaItem.nonEmpty",
REQUIRED: "theme.openapi.schemaItem.required",
DEPRECATED: "theme.openapi.schemaItem.deprecated",
NULLABLE: "theme.openapi.schemaItem.nullable",
@@ -82,6 +84,7 @@ export const OPENAPI_SCHEMA_ITEM = {
ENUM_VALUE: "theme.openapi.schemaItem.enumValue",
ENUM_DESCRIPTION: "theme.openapi.schemaItem.enumDescription",
POSSIBLE_VALUES: "theme.openapi.schemaItem.possibleValues",
+ EXPRESSION: "theme.openapi.schemaItem.expression",
ONE_OF: "theme.openapi.schemaItem.oneOf",
ANY_OF: "theme.openapi.schemaItem.anyOf",
};
diff --git a/packages/docusaurus-theme-openapi-docs/src/types.ts b/packages/docusaurus-theme-openapi-docs/src/types.ts
index e65019ea5..99fcfe12e 100644
--- a/packages/docusaurus-theme-openapi-docs/src/types.ts
+++ b/packages/docusaurus-theme-openapi-docs/src/types.ts
@@ -28,7 +28,14 @@ export type SchemaObject = Omit<
| "additionalProperties"
> & {
// OpenAPI specific overrides
- type?: "string" | "number" | "integer" | "boolean" | "object" | "array";
+ type?:
+ | "string"
+ | "number"
+ | "integer"
+ | "boolean"
+ | "object"
+ | "array"
+ | "null";
allOf?: SchemaObject[];
oneOf?: SchemaObject[];
anyOf?: SchemaObject[];