@@ -49,7 +49,7 @@ public PropertyNode this[string key]
4949 }
5050 }
5151
52- public override Dictionary < string , T > CreateMap < T > ( Func < MapNode , OpenApiDocument , T > map )
52+ public override Dictionary < string , T > CreateMap < T > ( Func < MapNode , OpenApiDocument , T > map , OpenApiDocument hostDocument = null )
5353 {
5454 var jsonMap = _node ?? throw new OpenApiReaderException ( $ "Expected map while parsing { typeof ( T ) . Name } ", Context ) ;
5555 var nodes = jsonMap . Select (
@@ -62,7 +62,7 @@ public override Dictionary<string, T> CreateMap<T>(Func<MapNode, OpenApiDocument
6262 {
6363 Context . StartObject ( key ) ;
6464 value = n . Value is JsonObject jsonObject
65- ? map ( new MapNode ( Context , jsonObject ) , null )
65+ ? map ( new MapNode ( Context , jsonObject ) , hostDocument )
6666 : default ;
6767 }
6868 finally
@@ -79,10 +79,11 @@ public override Dictionary<string, T> CreateMap<T>(Func<MapNode, OpenApiDocument
7979 return nodes . ToDictionary ( k => k . key , v => v . value ) ;
8080 }
8181
82- public override Dictionary < string , JsonSchema > CreateJsonSchemaMapWithReference (
82+ public override Dictionary < string , JsonSchema > CreateJsonSchemaMap (
8383 ReferenceType referenceType ,
8484 Func < MapNode , OpenApiDocument , JsonSchema > map ,
85- OpenApiSpecVersion version )
85+ OpenApiSpecVersion version ,
86+ OpenApiDocument hostDocument = null )
8687 {
8788 var jsonMap = _node ?? throw new OpenApiReaderException ( $ "Expected map while parsing { typeof ( JsonSchema ) . Name } ", Context ) ;
8889
@@ -95,30 +96,12 @@ public override Dictionary<string, JsonSchema> CreateJsonSchemaMapWithReference(
9596 {
9697 Context . StartObject ( key ) ;
9798 entry = ( key ,
98- value : map ( new MapNode ( Context , ( JsonObject ) n . Value ) , null )
99+ value : map ( new MapNode ( Context , ( JsonObject ) n . Value ) , hostDocument )
99100 ) ;
100101 if ( entry . value == null )
101102 {
102103 return default ; // Body Parameters shouldn't be converted to Parameters
103104 }
104- // If the component isn't a reference to another component, then point it to itself.
105- if ( entry . value . GetRef ( ) == null )
106- {
107- var builder = new JsonSchemaBuilder ( ) ;
108-
109- // construct the Ref and append it to the builder
110- var reference = version == OpenApiSpecVersion . OpenApi2_0 ? string . Concat ( "#/definitions/" , entry . key ) :
111- string . Concat ( "#/components/schemas/" , entry . key ) ;
112-
113- builder . Ref ( reference ) ;
114-
115- // Append all the keywords in original schema to our new schema using a builder instance
116- foreach ( var keyword in entry . value . Keywords )
117- {
118- builder . Add ( keyword ) ;
119- }
120- entry . value = builder . Build ( ) ;
121- }
122105 }
123106 finally
124107 {
0 commit comments