diff --git a/src/components/Tables/ActionOptionsTable.tsx b/src/components/Tables/ActionOptionsTable.tsx index e0b47d9b27..bfc204b6fb 100644 --- a/src/components/Tables/ActionOptionsTable.tsx +++ b/src/components/Tables/ActionOptionsTable.tsx @@ -1,4 +1,4 @@ -import configSchema from '../../util/sanitizedConfigSchema'; +import configSchema from '../../../public/mergify-configuration-schema.json'; import { ConfigSchema, Def } from './ConfigOptions'; import { OptionsTableBase } from './OptionsTable'; diff --git a/src/components/Tables/ConfigOptions.tsx b/src/components/Tables/ConfigOptions.tsx index 2378e16612..7f0bb61094 100644 --- a/src/components/Tables/ConfigOptions.tsx +++ b/src/components/Tables/ConfigOptions.tsx @@ -1,7 +1,7 @@ import jsonpointer from 'jsonpointer'; import React, { ReactElement } from 'react'; import { getDataTypeHref, isDataType } from '~/util/dataType'; -import configSchema from '~/util/sanitizedConfigSchema'; +import configSchema from '../../../public/mergify-configuration-schema.json'; import { renderMarkdown } from './utils'; const valueTypeLinks: { [key: string]: string } = { diff --git a/src/components/Tables/OptionsTable.tsx b/src/components/Tables/OptionsTable.tsx index 6f88b2d98b..07b48a1a9a 100644 --- a/src/components/Tables/OptionsTable.tsx +++ b/src/components/Tables/OptionsTable.tsx @@ -1,6 +1,6 @@ import * as yaml from 'js-yaml'; -import configSchema from '../../util/sanitizedConfigSchema'; +import configSchema from '../../../public/mergify-configuration-schema.json'; import { extractTemplateVariables } from '../../util/templateVariables'; import Badge from '../Badge/Badge'; import { diff --git a/src/components/Tables/PullRequestAttributes.tsx b/src/components/Tables/PullRequestAttributes.tsx index 0ba9c36cfe..eed348bfc2 100644 --- a/src/components/Tables/PullRequestAttributes.tsx +++ b/src/components/Tables/PullRequestAttributes.tsx @@ -1,5 +1,5 @@ +import configSchema from '../../../public/mergify-configuration-schema.json'; import { getAttributeDocumentationUrl, getAttributeSource } from '../../util/attributeMetadata'; -import configSchema from '../../util/sanitizedConfigSchema'; import { getValueType } from './ConfigOptions'; import { defToIdPrefix } from './OptionsTable'; // Attributes render with the OptionsTable layout (stacked entries, full-width diff --git a/src/components/Tables/QueueDequeueReasons.tsx b/src/components/Tables/QueueDequeueReasons.tsx index ca663b475b..2bf887b346 100644 --- a/src/components/Tables/QueueDequeueReasons.tsx +++ b/src/components/Tables/QueueDequeueReasons.tsx @@ -1,5 +1,5 @@ +import configSchema from '../../../public/mergify-configuration-schema.json'; import { readEnumChoices } from '../../util/enumChoices'; -import configSchema from '../../util/sanitizedConfigSchema'; import { renderMarkdown } from './utils'; diff --git a/src/components/Tables/TemplateVariablesTable.tsx b/src/components/Tables/TemplateVariablesTable.tsx index 3db0f174e5..811f56babb 100644 --- a/src/components/Tables/TemplateVariablesTable.tsx +++ b/src/components/Tables/TemplateVariablesTable.tsx @@ -1,4 +1,4 @@ -import configSchema from '../../util/sanitizedConfigSchema'; +import configSchema from '../../../public/mergify-configuration-schema.json'; import { extractTemplateVariables } from '../../util/templateVariables'; import { ConfigSchema, Def } from './ConfigOptions'; diff --git a/src/util/mdxast.tsx b/src/util/mdxast.tsx index 92051cba6f..d287ad344a 100644 --- a/src/util/mdxast.tsx +++ b/src/util/mdxast.tsx @@ -6,8 +6,8 @@ import { } from '~/components/Tables/ConfigOptions'; import { OptionsTableBase } from '~/components/Tables/OptionsTable'; import PullRequestAttributesTable from '~/components/Tables/PullRequestAttributes'; +import configSchema from '../../public/mergify-configuration-schema.json'; import { MdxNodeJsxElement } from '../@types/mdxast'; -import configSchema from './sanitizedConfigSchema'; interface TableType { node: string; diff --git a/src/util/sanitizedConfigSchema.ts b/src/util/sanitizedConfigSchema.ts deleted file mode 100644 index fd899d0a05..0000000000 --- a/src/util/sanitizedConfigSchema.ts +++ /dev/null @@ -1,28 +0,0 @@ -import rawConfigSchema from '../../public/mergify-configuration-schema.json'; - -// Fields to hide from configuration documentation -const hiddenFields = ['autosquash']; - -function deepRemoveKey(value: any, keyToRemove: string) { - if (Array.isArray(value)) { - for (const item of value) deepRemoveKey(item, keyToRemove); - return value; - } - if (value && typeof value === 'object') { - if (Object.prototype.hasOwnProperty.call(value, keyToRemove)) { - delete (value as any)[keyToRemove]; - } - for (const k of Object.keys(value)) deepRemoveKey((value as any)[k], keyToRemove); - } - return value; -} - -function sanitizeConfigSchema() { - const cloned = JSON.parse(JSON.stringify(rawConfigSchema)); - for (const field of hiddenFields) deepRemoveKey(cloned, field); - return cloned as typeof rawConfigSchema; -} - -const configSchema = sanitizeConfigSchema(); - -export default configSchema; diff --git a/src/util/schemaToMarkdown.ts b/src/util/schemaToMarkdown.ts index 7bbbb5c907..4b438ab208 100644 --- a/src/util/schemaToMarkdown.ts +++ b/src/util/schemaToMarkdown.ts @@ -1,8 +1,7 @@ import jsonpointer from 'jsonpointer'; - +import configSchema from '../../public/mergify-configuration-schema.json'; import { getAttributeDocumentationUrl, getAttributeSource } from './attributeMetadata'; import { getDataTypeHref, isDataType } from './dataType'; -import configSchema from './sanitizedConfigSchema'; type Schema = typeof configSchema;