Skip to content

Commit

Permalink
Allow JSON Schemas to be set dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
JPinkney committed May 31, 2019
1 parent 4b2f792 commit 39e800c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ export class YAMLCompletion {

const propertyText = this.getInsertTextForValue(key, '');
// if (!addValue) {
// return propertyText;
// return propertyText;
// }
const resultText = propertyText + ':';

Expand Down
20 changes: 11 additions & 9 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,24 @@ connection.onDidChangeConfiguration(change => {
}
schemaConfigurationSettings = [];

const jsonSchemas = [];
for (const url in yamlConfigurationSettings){
const globPattern = yamlConfigurationSettings[url];
const checkedURL = url.toLowerCase() === 'kubernetes' ? KUBERNETES_SCHEMA_URL : url;
const schemaObj = {
'fileMatch': Array.isArray(globPattern) ? globPattern : [globPattern],
'url': url
'uri': checkedURL
};
jsonSchemas.push(schemaObj);
schemaConfigurationSettings.push(schemaObj);
}

jsonLanguageService.configure({
schemas: jsonSchemas,
validate: settings.yaml.validate,
allowComments: true
});

setSchemaStoreSettingsIfNotSet();

updateConfiguration();
Expand Down Expand Up @@ -370,7 +379,7 @@ function updateConfiguration() {
}
if (schemaConfigurationSettings) {
schemaConfigurationSettings.forEach(schema => {
let uri = schema.url;
let uri = schema.uri;
if (!uri && schema.schema) {
uri = schema.schema.id;
}
Expand All @@ -384,13 +393,6 @@ function updateConfiguration() {
}
languageSettings = configureSchemas(uri, schema.fileMatch, schema.schema, languageSettings);
}
jsonLanguageService.configure({
schemas: [{
fileMatch: ['*.yaml', '*.yml'],
uri: 'https://raw.githubusercontent.com/garethr/kubernetes-json-schema/master/v1.14.0-standalone-strict/all.json'
}],
validate: true
});
});
}
if (schemaStoreSettings){
Expand Down

0 comments on commit 39e800c

Please sign in to comment.