import { getLanguageService , JSONSchema , SchemaRequestService , TextDocument , MatchingSchema } from '../jsonLanguageService' ; async function main ( ) { const jsonContentUri = 'foo://server/example.data.json' ; const jsonContent = `{
       "name": 12
       "country": "Ireland"
    }` ; const jsonSchemaUri = "foo://server/data.schema.json" ; const jsonSchema = { "type" : "object" , "properties" : { "name" : { "type" : "string" } , "country" : { "type" : "string" , "enum" : [ "Ireland" , "Iceland" ] } } } ; const textDocument = TextDocument . create ( jsonContentUri , 'json' , 1 , jsonContent ) ; const jsonLanguageService = getLanguageService ( { schemaRequestService : ( uri ) => { if ( uri === jsonSchemaUri ) { return Promise . resolve ( JSON . stringify ( jsonSchema ) ) ; } return Promise . reject ( `Unabled to load schema at ${ uri }` ) ; } } ) ; jsonLanguageService . configure ( { allowComments : false , schemas : [ { fileMatch : [ "*.data.json" ] , uri : jsonSchemaUri } ] } ) ; const jsonDocument = jsonLanguageService . parseJSONDocument ( textDocument ) ; const diagnostics = await jsonLanguageService . doValidation ( textDocument , jsonDocument ) ; console . log ( 'Validation results:' , diagnostics . map ( d => `[line ${ d . range . start . line }] ${ d . message }` ) ) ; const competionResult = await jsonLanguageService . doComplete ( textDocument , { line : 2 , character : 18 } , jsonDocument ) ; console . log ( 'Completion proposals:' , competionResult ?. items . map ( i => `${ i . label }` ) ) ; } main ( ) ;