@@ -1998,7 +1998,60 @@ suite('JSON Schema', () => {
1998
1998
const testDoc = toDocument ( JSON . stringify ( { $schema : httpUrl , bar : 2 } ) ) ;
1999
1999
let validation = await ls . doValidation ( testDoc . textDoc , testDoc . jsonDoc ) ;
2000
2000
assert . deepStrictEqual ( validation . map ( v => v . message ) , [ 'Value must be 3.' ] ) ;
2001
- assert . deepStrictEqual ( [ httpsUrl ] , accesses ) ;
2001
+ assert . deepStrictEqual ( [ httpsUrl ] , accesses ) ;
2002
2002
} ) ;
2003
2003
2004
+ test ( 'combined schemas and URIs without host' , async function ( ) {
2005
+ const schemas : SchemaConfiguration [ ] = [ {
2006
+ uri : 'myproto:///schema.json' ,
2007
+ fileMatch : [ 'foo.json' ] ,
2008
+ } ,
2009
+ {
2010
+ uri : 'https://myschemastore/schema2.json' ,
2011
+ fileMatch : [ 'foo.json' ] ,
2012
+ }
2013
+ ] ;
2014
+ const schemaContents : { [ uri : string ] : JSONSchema } = {
2015
+ [ 'myproto:/schema.json' ] : {
2016
+ type : 'object' ,
2017
+ properties : {
2018
+ bar : {
2019
+ type : 'string'
2020
+ }
2021
+ }
2022
+ } ,
2023
+ [ 'https://myschemastore/schema2.json' ] : {
2024
+ type : 'object' ,
2025
+ properties : {
2026
+ foo : {
2027
+ type : 'string'
2028
+ }
2029
+ }
2030
+ }
2031
+ } ;
2032
+
2033
+ const accesses : string [ ] = [ ] ;
2034
+
2035
+
2036
+ const schemaRequestService : SchemaRequestService = async ( uri : string ) => {
2037
+ if ( uri === `https://myschemastore/schema2.json` || uri === `myproto:/schema.json` ) {
2038
+ return '{}' ;
2039
+ }
2040
+ throw new Error ( 'Unknown schema ' + uri ) ;
2041
+ } ;
2042
+
2043
+
2044
+ const ls = getLanguageService ( { workspaceContext, schemaRequestService } ) ;
2045
+ ls . configure ( { schemas } ) ;
2046
+
2047
+ {
2048
+ const { textDoc, jsonDoc } = toDocument ( '{ }' , undefined , 'foo://bar/folder/foo.json' ) ;
2049
+ const res = await ls . doValidation ( textDoc , jsonDoc ) ;
2050
+ console . log ( res ) ;
2051
+ }
2052
+
2053
+ } ) ;
2054
+
2055
+
2056
+
2004
2057
} ) ;
0 commit comments