(/** @type {SchemaFile} */ schema)
| 1773 | } |
| 1774 | |
| 1775 | async function assertSchemaHasValidIdField(/** @type {SchemaFile} */ schema) { |
| 1776 | let schemaId = '' |
| 1777 | /** |
| 1778 | * Old JSON Schema specification versions use the "id" key for unique |
| 1779 | * identifiers, rather than "$id". See for details: |
| 1780 | * https://json-schema.org/understanding-json-schema/basics.html#declaring-a-unique-identifier |
| 1781 | */ |
| 1782 | const schemasWithDollarlessId = [ |
| 1783 | 'http://json-schema.org/draft-03/schema#', |
| 1784 | 'http://json-schema.org/draft-04/schema#', |
| 1785 | ] |
| 1786 | if (schemasWithDollarlessId.includes(schema.json.$schema)) { |
| 1787 | if (schema.json.id === undefined) { |
| 1788 | printErrorAndExit(new Error(), [ |
| 1789 | `Missing property 'id' for schema "./${path.join(SchemaDir, schema.name)}"`, |
| 1790 | ]) |
| 1791 | } |
| 1792 | schemaId = schema.json.id |
| 1793 | } else { |
| 1794 | if (schema.json.$id === undefined) { |
| 1795 | printErrorAndExit(new Error(), [ |
| 1796 | `Missing property '$id' for schema "./${path.join(SchemaDir, schema.name)}"`, |
| 1797 | ]) |
| 1798 | } |
| 1799 | schemaId = schema.json.$id |
| 1800 | } |
| 1801 | |
| 1802 | if (!schemaId.startsWith('https://') && !schemaId.startsWith('http://')) { |
| 1803 | printErrorAndExit(new Error(), [ |
| 1804 | `Expected schema id/$id to begin with 'https://' or 'http://'`, |
| 1805 | `Found schema with value of "${schemaId}" in "./${path.join(SchemaDir, schema.name)}"`, |
| 1806 | ]) |
| 1807 | } |
| 1808 | } |
| 1809 | |
| 1810 | async function assertSchemaHasCorrectMetadata( |
| 1811 | /** @type {SchemaFile} */ schema, |
no test coverage detected