File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -479,6 +479,8 @@ function idFinder (schema, searchedId) {
479
479
}
480
480
481
481
function refFinder ( ref , schema , externalSchema ) {
482
+ if ( externalSchema && externalSchema [ ref ] ) return externalSchema [ ref ]
483
+
482
484
// Split file from walk
483
485
ref = ref . split ( '#' )
484
486
Original file line number Diff line number Diff line change @@ -846,3 +846,33 @@ test('ref to nested ref definition', (t) => {
846
846
847
847
t . equal ( output , '{"foo":"foo"}' )
848
848
} )
849
+
850
+ test ( 'ref in definition with exact match' , ( t ) => {
851
+ t . plan ( 2 )
852
+
853
+ const externalSchema = {
854
+ '#/definitions/foo' : {
855
+ type : 'string'
856
+ }
857
+ }
858
+
859
+ const schema = {
860
+ type : 'object' ,
861
+ properties : {
862
+ foo : { $ref : '#/definitions/foo' }
863
+ }
864
+ }
865
+
866
+ const object = { foo : 'foo' }
867
+ const stringify = build ( schema , { schema : externalSchema } )
868
+ const output = stringify ( object )
869
+
870
+ try {
871
+ JSON . parse ( output )
872
+ t . pass ( )
873
+ } catch ( e ) {
874
+ t . fail ( )
875
+ }
876
+
877
+ t . equal ( output , '{"foo":"foo"}' )
878
+ } )
You can’t perform that action at this time.
0 commit comments