File tree Expand file tree Collapse file tree 5 files changed +70
-0
lines changed
Expand file tree Collapse file tree 5 files changed +70
-0
lines changed Original file line number Diff line number Diff line change 1+ $schema : https://json-schema.org/draft/2020-12
2+ $id : test/resources/refOptions/common.yml
3+ type : object
4+ properties :
5+ id :
6+ type : integer
7+ description : The unique identifier of the object
8+ name :
9+ type : string
10+ description : The name of the object
11+ required :
12+ - id
Original file line number Diff line number Diff line change 1+ $schema : https://json-schema.org/draft/2020-12
2+ $id : test/resources/refOptions/specific/caseA.yml
3+ type : object
4+ allOf :
5+ - $ref : test/resources/refOptions/common.yml
6+ - properties :
7+ module :
8+ type : string
9+ const : caseA
10+ is_old :
11+ type : boolean
12+ description : The age of the object
13+ required :
14+ - module
Original file line number Diff line number Diff line change 1+ $schema : https://json-schema.org/draft/2020-12
2+ $id : test/resources/refOptions/specific/caseB.yml
3+ type : object
4+ allOf :
5+ - $ref : test/resources/refOptions/common.yml
6+ - properties :
7+ module :
8+ type : string
9+ const : caseB
10+ age :
11+ type :
12+ description : The age of the object
13+ required :
14+ - module
Original file line number Diff line number Diff line change 1+ $schema : https://json-schema.org/draft/2020-12
2+ $id : test/resources/refOptions/specific/specific.yml
3+ type : object
4+ anyOf :
5+ - $ref : test/resources/refOptions/specific/caseA.yml
6+ - $ref : test/resources/refOptions/specific/caseB.yml
Original file line number Diff line number Diff line change @@ -137,6 +137,30 @@ export function run() {
137137 } )
138138 rimraf . sync ( './test/resources/MultiSchema2/out' )
139139 } )
140+
141+ test ( '--refOptions - JSON string error' , t => {
142+ t . throws ( ( ) => execSync ( 'node dist/src/cli.js --refOptions "{invalid}" --input ./test/resources/refOptions' ) )
143+ } )
144+
145+ test ( '--refOptions - referenced base URI, default externalReferenceResolution' , t => {
146+ t . throws ( ( ) => execSync ( 'node dist/src/cli.js --input ./test/resources/refOptions' ) )
147+ } )
148+
149+ test ( '--refOptions - referenced base URI, unknown externalReferenceResolution' , t => {
150+ t . throws ( ( ) =>
151+ execSync (
152+ 'node dist/src/cli.js --refOptions "{\\"dereference\\": {\\"externalReferenceResolution\\": \\"...\\"}}" --input ./test/resources/refOptions' ,
153+ ) ,
154+ )
155+ } )
156+
157+ test ( '--refOptions - referenced base URI, root externalReferenceResolution' , t => {
158+ t . notThrows ( ( ) =>
159+ execSync (
160+ 'node dist/src/cli.js --refOptions "{\\"dereference\\": {\\"externalReferenceResolution\\": \\"root\\"}}" --input ./test/resources/refOptions' ,
161+ ) ,
162+ )
163+ } )
140164}
141165
142166function getPaths ( path : string , paths : string [ ] = [ ] ) {
You can’t perform that action at this time.
0 commit comments