How to use the json.schemas function in json

To help you get started, we’ve selected a few json examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / json / src / browser / json-client-contribution.ts View on Github external
protected async updateSchemas(): Promise {
        const allConfigs = [...this.jsonSchemaStore.getJsonSchemaConfigurations()];
        const config = this.preferences['json.schemas'];
        if (config instanceof Array) {
            allConfigs.push(...config);
        }
        const registry: { [pattern: string]: string[] } = {};
        for (const s of allConfigs) {
            if (s.fileMatch) {
                for (let fileMatch of s.fileMatch) {
                    if (fileMatch.charAt(0) !== '/' && !fileMatch.match(/\w+:/)) {
                        fileMatch = '/' + fileMatch;
                    }
                    registry[fileMatch] = [s.url];
                }
            }
        }
        const client = await this.languageClient;
        await client.onReady();
github microsoft / PowerBI-visuals-tools / lib / VisualGenerator.js View on Github external
vsCodeSettings['json.schemas'].forEach((item, idx) => {
            if (item.url.match(/.api\/.+\/schema.pbiviz.json$/)) {
                vsCodeSettings['json.schemas'][idx].url = `./.api/v${apiVersion}/schema.pbiviz.json`;
            } else if (item.url.match(/.api\/.+\/schema.capabilities.json$/)) {
                vsCodeSettings['json.schemas'][idx].url = `./.api/v${apiVersion}/schema.capabilities.json`;
            } else if (item.url.match(/.api\/.+\/schema.dependencies.json$/)) {
                vsCodeSettings['json.schemas'][idx].url = `./.api/v${apiVersion}/schema.dependencies.json`;
            }
        });
        fs.writeJsonSync(vsCodeSettingsPath, vsCodeSettings);
github microsoft / PowerBI-visuals-tools / spec / e2e / pbivizNewSpec.js View on Github external
let stat = fs.statSync(path.join(visualPath, '.api', 'v1.0.0'));
            expect(stat.isDirectory()).toBe(true);

            //pbiviz version number should've been updated
            let pbivizJson = fs.readJsonSync(path.join(visualPath, 'pbiviz.json'));
            expect(pbivizJson.apiVersion).toBe('1.0.0');

            //tsconfig should've been updated
            let tsConfig = fs.readJsonSync(path.join(visualPath, 'tsconfig.json'));
            let typeDefIndex = lodashFindIndex(tsConfig.files, i => i.match(/.api\/.+\/PowerBI-visuals.d.ts$/));
            expect(tsConfig.files[typeDefIndex]).toBe('.api/v1.0.0/PowerBI-visuals.d.ts');

            //.vscode/settings.json should've been set to the correct schemas
            let vsCodeSettings = fs.readJsonSync(path.join(visualPath, '.vscode', 'settings.json'));
            let vsCodeMatches = 0;
            vsCodeSettings['json.schemas'].forEach((item, idx) => {
                if (item.url.indexOf("schema.pbiviz.json") > -1) {
                    expect(vsCodeSettings['json.schemas'][idx].url).toBe('./node_modules/powerbi-visuals-api/schema.pbiviz.json');
                    vsCodeMatches++;
                } else if (item.url.indexOf("schema.capabilities.json")  > -1) {
                    expect(vsCodeSettings['json.schemas'][idx].url).toBe('./node_modules/powerbi-visuals-api/schema.capabilities.json');
                    vsCodeMatches++;
                }
            });
            expect(vsCodeMatches).toBe(2);
        });
github microsoft / PowerBI-visuals-tools / lib / VisualGenerator.js View on Github external
let vsCodeSettingsPath = path.join(targetPath, '.vscode', 'settings.json');

        //set version in pbiviz.json
        let pbiviz = fs.readJsonSync(pbivizPath);
        pbiviz.apiVersion = apiVersion;
        fs.writeJsonSync(pbivizPath, pbiviz);

        //set correct version d.ts file in tsconfig.json
        let tsConfig = fs.readJsonSync(tsConfigPath);
        let typeDefIndex = lodashFindIndex(tsConfig.files, i => i.match(/.api\/.+\/PowerBI-visuals.d.ts$/));
        tsConfig.files[typeDefIndex] = `.api/v${apiVersion}/PowerBI-visuals.d.ts`;
        fs.writeJsonSync(tsConfigPath, tsConfig);

        //set correct version schemas in .vscode/settings.json
        let vsCodeSettings = fs.readJsonSync(vsCodeSettingsPath);
        vsCodeSettings['json.schemas'].forEach((item, idx) => {
            if (item.url.match(/.api\/.+\/schema.pbiviz.json$/)) {
                vsCodeSettings['json.schemas'][idx].url = `./.api/v${apiVersion}/schema.pbiviz.json`;
            } else if (item.url.match(/.api\/.+\/schema.capabilities.json$/)) {
                vsCodeSettings['json.schemas'][idx].url = `./.api/v${apiVersion}/schema.capabilities.json`;
            } else if (item.url.match(/.api\/.+\/schema.dependencies.json$/)) {
                vsCodeSettings['json.schemas'][idx].url = `./.api/v${apiVersion}/schema.dependencies.json`;
            }
        });
        fs.writeJsonSync(vsCodeSettingsPath, vsCodeSettings);
    }
github microsoft / PowerBI-visuals-tools / spec / e2e / pbivizNewSpec.js View on Github external
vsCodeSettings['json.schemas'].forEach((item, idx) => {
                if (item.url.indexOf("schema.pbiviz.json") > -1) {
                    expect(vsCodeSettings['json.schemas'][idx].url).toBe('./node_modules/powerbi-visuals-api/schema.pbiviz.json');
                    vsCodeMatches++;
                } else if (item.url.indexOf("schema.capabilities.json")  > -1) {
                    expect(vsCodeSettings['json.schemas'][idx].url).toBe('./node_modules/powerbi-visuals-api/schema.capabilities.json');
                    vsCodeMatches++;
                }
            });
            expect(vsCodeMatches).toBe(2);