diff --git a/src/tools/currency-converter/currency-converter.vue b/src/tools/currency-converter/currency-converter.vue
index ac8d0941..1b6ae429 100644
--- a/src/tools/currency-converter/currency-converter.vue
+++ b/src/tools/currency-converter/currency-converter.vue
@@ -1,9 +1,10 @@
@@ -359,7 +370,7 @@ function updateMarker() {
-
+
diff --git a/src/tools/geo-coordinates-converter/index.ts b/src/tools/geo-coordinates-converter/index.ts
index 2f23bc29..7d4b0a0a 100644
--- a/src/tools/geo-coordinates-converter/index.ts
+++ b/src/tools/geo-coordinates-converter/index.ts
@@ -10,5 +10,5 @@ export const tool = defineTool({
icon: defineAsyncComponent(() => import('@tabler/icons-vue/dist/esm/icons/IconWorldPin.mjs')),
createdAt: new Date('2026-01-09'),
category: 'Converters',
- externAccessDescription: 'This tool access OpenStreetMap to display the World map using the Leaflet library.',
+ externAccessDescription: t('tools.geo-coordinates-converter.externalAccess'),
});
diff --git a/src/tools/json-editor/json-editor.vue b/src/tools/json-editor/json-editor.vue
index 513c903d..e55f3685 100644
--- a/src/tools/json-editor/json-editor.vue
+++ b/src/tools/json-editor/json-editor.vue
@@ -54,7 +54,11 @@ const schemaUrl = useQueryParamOrStorage({
storageName: 'json-editor:schema',
defaultValue: '',
});
-const { schemas, errors: validationErrors } = useJsonSchemaValidation({ json: jsonText, schemaUrl, schemaData });
+const {
+ schemas,
+ errors: validationErrors,
+ catalogAvailable,
+} = useJsonSchemaValidation({ json: jsonText, schemaUrl, schemaData });
function tryAutoRepair() {
try {
@@ -128,6 +132,7 @@ const formattedJson = computed(() => {
...schemas.map((s) => ({ label: `${s.name} / ${s.description}`, value: s.url })),
]"
filterable
+ :tag="!catalogAvailable"
mb-4
/>
diff --git a/src/tools/json-linter/json-linter.vue b/src/tools/json-linter/json-linter.vue
index 3ac2b12c..21e08909 100644
--- a/src/tools/json-linter/json-linter.vue
+++ b/src/tools/json-linter/json-linter.vue
@@ -37,7 +37,11 @@ const schemaUrl = useQueryParamOrStorage({
storageName: 'json-linter:schema',
defaultValue: '',
});
-const { schemas, errors: validationErrors } = useJsonSchemaValidation({ json: jsonContent, schemaUrl, schemaData });
+const {
+ schemas,
+ errors: validationErrors,
+ catalogAvailable,
+} = useJsonSchemaValidation({ json: jsonContent, schemaUrl, schemaData });
const indentSize = useITStorage('json-linter:indent-size', 3);
const autoRepair = useITStorage('json-linter:repair', true);
@@ -88,6 +92,7 @@ const cleanJson = computed(() => {
...schemas.map((s) => ({ label: `${s.name} / ${s.description}`, value: s.url })),
]"
filterable
+ :tag="!catalogAvailable"
mb-4
/>
diff --git a/src/tools/json-viewer/json-viewer.vue b/src/tools/json-viewer/json-viewer.vue
index 0b42ae5a..bbd01195 100644
--- a/src/tools/json-viewer/json-viewer.vue
+++ b/src/tools/json-viewer/json-viewer.vue
@@ -50,7 +50,11 @@ const schemaUrl = useQueryParamOrStorage({
storageName: 'json-prettify:schema',
defaultValue: '',
});
-const { schemas, errors: validationErrors } = useJsonSchemaValidation({ json: rawJson, schemaUrl, schemaData });
+const {
+ schemas,
+ errors: validationErrors,
+ catalogAvailable,
+} = useJsonSchemaValidation({ json: rawJson, schemaUrl, schemaData });
@@ -95,6 +99,7 @@ const { schemas, errors: validationErrors } = useJsonSchemaValidation({ json: ra
...schemas.map((s) => ({ label: `${s.name} / ${s.description}`, value: s.url })),
]"
filterable
+ :tag="!catalogAvailable"
mb-4
/>
diff --git a/src/tools/json-viewer/schema-catalog.test.ts b/src/tools/json-viewer/schema-catalog.test.ts
new file mode 100644
index 00000000..b45bf667
--- /dev/null
+++ b/src/tools/json-viewer/schema-catalog.test.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it, vi } from 'vitest';
+import { DEFAULT_SCHEMA_CATALOG_URL, fetchSchemaCatalog, resolveSchemaCatalogUrl } from './schema-catalog';
+
+describe('schema-catalog', () => {
+ const mirror = { 'json-schemas': { 'catalog-url': ' https://intranet.example/schemastore/catalog.json ' } };
+
+ it('uses schemastore.org online and no catalog offline when no mirror is configured', () => {
+ expect(resolveSchemaCatalogUrl({}, false)).to.equal(DEFAULT_SCHEMA_CATALOG_URL);
+ expect(resolveSchemaCatalogUrl({}, true)).to.equal('');
+ });
+
+ it('uses the configured mirror online and offline', () => {
+ expect(resolveSchemaCatalogUrl(mirror, false)).to.equal('https://intranet.example/schemastore/catalog.json');
+ expect(resolveSchemaCatalogUrl(mirror, true)).to.equal('https://intranet.example/schemastore/catalog.json');
+ });
+
+ it('does not fetch without a catalog URL', async () => {
+ const fetchSpy = vi.spyOn(globalThis, 'fetch');
+ expect(await fetchSchemaCatalog('')).to.deep.equal([]);
+ expect(fetchSpy).not.toHaveBeenCalled();
+ fetchSpy.mockRestore();
+ });
+});
diff --git a/src/tools/json-viewer/schema-catalog.ts b/src/tools/json-viewer/schema-catalog.ts
new file mode 100644
index 00000000..2a356dcd
--- /dev/null
+++ b/src/tools/json-viewer/schema-catalog.ts
@@ -0,0 +1,29 @@
+import { type ToolsSettings, getToolsSettingString } from '@/utils/tools-settings';
+
+export interface SchemaStore {
+ name: string;
+ description: string;
+ url: string;
+ fileMatch: string[];
+ versions?: string[];
+}
+
+export const DEFAULT_SCHEMA_CATALOG_URL = 'https://www.schemastore.org/api/json/catalog.json';
+
+/**
+ * The schema catalog to list in the schema picker: `"json-schemas": { "catalog-url": "..." }` from tools-settings.json
+ * (e.g. an intranet mirror of schemastore.org), else schemastore.org itself, except in offline mode where there is
+ * no catalog ('') and only custom or user-entered schemas are available.
+ */
+export function resolveSchemaCatalogUrl(settings: ToolsSettings, offline: boolean): string {
+ return getToolsSettingString(settings, 'json-schemas', 'catalog-url') || (offline ? '' : DEFAULT_SCHEMA_CATALOG_URL);
+}
+
+export async function fetchSchemaCatalog(catalogUrl: string): Promise {
+ if (!catalogUrl) {
+ return [];
+ }
+ const catalog = await fetch(catalogUrl);
+ const catalogJson: { $schemaUrl: string; schemas: SchemaStore[]; version: number } = await catalog.json();
+ return catalogJson.schemas;
+}
diff --git a/src/tools/json-viewer/useJsonSchemaValidation.ts b/src/tools/json-viewer/useJsonSchemaValidation.ts
index 0dc165f2..1d0ba839 100644
--- a/src/tools/json-viewer/useJsonSchemaValidation.ts
+++ b/src/tools/json-viewer/useJsonSchemaValidation.ts
@@ -1,14 +1,8 @@
import { type Schema, Validator } from 'jsonschema';
import { isRef, onBeforeMount, ref, watch } from 'vue';
import { type MaybeRef, get } from '@vueuse/core';
-
-export interface SchemaStore {
- name: string;
- description: string;
- url: string;
- fileMatch: string[];
- versions?: string[];
-}
+import { type SchemaStore, fetchSchemaCatalog, resolveSchemaCatalogUrl } from './schema-catalog';
+import { isOfflineMode, toolsSettings } from '@/tools-settings';
export function useJsonSchemaValidation({
json,
@@ -23,10 +17,12 @@ export function useJsonSchemaValidation({
const schema = ref(null);
const errors = ref([]);
+ // Offline without a configured catalog mirror there is no catalog to pick from: only custom or user-entered schemas
+ const catalogUrl = resolveSchemaCatalogUrl(toolsSettings, isOfflineMode);
+ const catalogAvailable = catalogUrl !== '';
+
onBeforeMount(async () => {
- const catalog = await fetch('https://www.schemastore.org/api/json/catalog.json');
- const catalogJson: { $schemaUrl: string; schemas: SchemaStore[]; version: number } = await catalog.json();
- schemas.value = catalogJson.schemas;
+ schemas.value = await fetchSchemaCatalog(catalogUrl);
});
watch(
@@ -81,5 +77,5 @@ export function useJsonSchemaValidation({
{ immediate: true },
);
- return { schemas, errors };
+ return { schemas, errors, catalogAvailable };
}
diff --git a/src/tools/yaml-viewer/index.ts b/src/tools/yaml-viewer/index.ts
index 4a0787d2..96418d21 100644
--- a/src/tools/yaml-viewer/index.ts
+++ b/src/tools/yaml-viewer/index.ts
@@ -11,4 +11,5 @@ export const tool = defineTool({
createdAt: new Date('2024-01-31'),
npmPackages: ['yaml'],
category: 'YAML',
+ externAccessDescription: t('tools.yaml-prettify.externalAccess'),
});
diff --git a/src/tools/yaml-viewer/useYamlSchemaValidation.ts b/src/tools/yaml-viewer/useYamlSchemaValidation.ts
index e5ab3eb3..7c7963bd 100644
--- a/src/tools/yaml-viewer/useYamlSchemaValidation.ts
+++ b/src/tools/yaml-viewer/useYamlSchemaValidation.ts
@@ -5,14 +5,8 @@ import YAML from 'yaml';
import Ajv from 'ajv';
import AjvErrors from 'ajv-errors';
import { yamlParse } from 'composeverter';
-
-export interface SchemaStore {
- name: string;
- description: string;
- url: string;
- fileMatch: string[];
- versions?: string[];
-}
+import { type SchemaStore, fetchSchemaCatalog, resolveSchemaCatalogUrl } from '../json-viewer/schema-catalog';
+import { isOfflineMode, toolsSettings } from '@/tools-settings';
interface NodeWithRange {
range?: number[];
@@ -31,10 +25,12 @@ export function useYamlSchemaValidation({
const schema = ref(null);
const errors = ref([]);
+ // Offline without a configured catalog mirror there is no catalog to pick from: only custom or user-entered schemas
+ const catalogUrl = resolveSchemaCatalogUrl(toolsSettings, isOfflineMode);
+ const catalogAvailable = catalogUrl !== '';
+
onBeforeMount(async () => {
- const catalog = await fetch('https://www.schemastore.org/api/json/catalog.json');
- const catalogJson: { $schemaUrl: string; schemas: SchemaStore[]; version: number } = await catalog.json();
- schemas.value = catalogJson.schemas;
+ schemas.value = await fetchSchemaCatalog(catalogUrl);
});
watch(
@@ -113,5 +109,5 @@ export function useYamlSchemaValidation({
{ immediate: true },
);
- return { schemas, errors };
+ return { schemas, errors, catalogAvailable };
}
diff --git a/src/tools/yaml-viewer/yaml-viewer.vue b/src/tools/yaml-viewer/yaml-viewer.vue
index 370fc5f1..b7a9a795 100644
--- a/src/tools/yaml-viewer/yaml-viewer.vue
+++ b/src/tools/yaml-viewer/yaml-viewer.vue
@@ -31,7 +31,11 @@ const MONACO_EDITOR_OPTIONS = {
};
const schemaUrl = useQueryParamOrStorage({ name: 'schema', storageName: 'yaml-prettify:schema', defaultValue: '' });
-const { schemas, errors: validationErrors } = useYamlSchemaValidation({ yaml: rawYaml, schemaUrl, schemaData });
+const {
+ schemas,
+ errors: validationErrors,
+ catalogAvailable,
+} = useYamlSchemaValidation({ yaml: rawYaml, schemaUrl, schemaData });
@@ -66,6 +70,7 @@ const { schemas, errors: validationErrors } = useYamlSchemaValidation({ yaml: ra
...schemas.map((s) => ({ label: `${s.name} / ${s.description}`, value: s.url })),
]"
filterable
+ :tag="!catalogAvailable"
mb-4
/>