@@ -51,27 +51,32 @@ public static IDictionary<string, OpenApiParameter> CreateParameters(this ODataC
5151 /// </summary>
5252 /// <param name="context">The OData context.</param>
5353 /// <param name="functionImport">The Edm function import.</param>
54+ /// <param name="document">The Open API document to lookup references.</param>
5455 /// <returns>The created list of <see cref="OpenApiParameter"/>.</returns>
55- public static IList < OpenApiParameter > CreateParameters ( this ODataContext context , IEdmFunctionImport functionImport )
56+ public static IList < OpenApiParameter > CreateParameters ( this ODataContext context , IEdmFunctionImport functionImport , OpenApiDocument document )
5657 {
5758 Utils . CheckArgumentNull ( context , nameof ( context ) ) ;
5859 Utils . CheckArgumentNull ( functionImport , nameof ( functionImport ) ) ;
60+ Utils . CheckArgumentNull ( document , nameof ( document ) ) ;
5961
60- return context . CreateParameters ( functionImport . Function ) ;
62+ return context . CreateParameters ( functionImport . Function , document ) ;
6163 }
6264
6365 /// <summary>
6466 /// Create the list of <see cref="OpenApiParameter"/> for a <see cref="IEdmFunction"/>.
6567 /// </summary>
6668 /// <param name="context">The OData context.</param>
6769 /// <param name="function">The Edm function.</param>
70+ /// <param name="document">The Open API document to lookup references.</param>
6871 /// <param name="parameterNameMapping">The parameter name mapping.</param>
6972 /// <returns>The created list of <see cref="OpenApiParameter"/>.</returns>
7073 public static IList < OpenApiParameter > CreateParameters ( this ODataContext context , IEdmFunction function ,
74+ OpenApiDocument document ,
7175 IDictionary < string , string > parameterNameMapping = null )
7276 {
7377 Utils . CheckArgumentNull ( context , nameof ( context ) ) ;
7478 Utils . CheckArgumentNull ( function , nameof ( function ) ) ;
79+ Utils . CheckArgumentNull ( document , nameof ( document ) ) ;
7580
7681 IList < OpenApiParameter > parameters = new List < OpenApiParameter > ( ) ;
7782 int skip = function . IsBound ? 1 : 0 ;
@@ -131,7 +136,7 @@ public static IList<OpenApiParameter> CreateParameters(this ODataContext context
131136 Name = parameterNameMapping == null ? edmParameter . Name : parameterNameMapping [ edmParameter . Name ] ,
132137 In = isOptionalParameter ? ParameterLocation . Query : ParameterLocation . Path ,
133138 Required = ! isOptionalParameter ,
134- Schema = context . CreateEdmTypeSchema ( edmParameter . Type )
139+ Schema = context . CreateEdmTypeSchema ( edmParameter . Type , document )
135140 } ;
136141 }
137142
@@ -154,16 +159,19 @@ public static IList<OpenApiParameter> CreateParameters(this ODataContext context
154159 /// </summary>
155160 /// <param name="context">The OData context.</param>
156161 /// <param name="keySegment">The key segment.</param>
162+ /// <param name="document">The Open API document to lookup references.</param>
157163 /// <param name="parameterNameMapping">The parameter name mapping.</param>
158164 /// <returns>The created list of <see cref="OpenApiParameter"/>.</returns>
159165 public static IList < OpenApiParameter > CreateKeyParameters ( this ODataContext context , ODataKeySegment keySegment ,
166+ OpenApiDocument document ,
160167 IDictionary < string , string > parameterNameMapping = null )
161168 {
162169 Utils . CheckArgumentNull ( context , nameof ( context ) ) ;
163170 Utils . CheckArgumentNull ( keySegment , nameof ( keySegment ) ) ;
171+ Utils . CheckArgumentNull ( document , nameof ( document ) ) ;
164172
165173 if ( keySegment . IsAlternateKey )
166- return CreateAlternateKeyParameters ( context , keySegment ) ;
174+ return CreateAlternateKeyParameters ( context , keySegment , document ) ;
167175
168176 IEdmEntityType entityType = keySegment . EntityType ;
169177 IList < IEdmStructuralProperty > keys = entityType . Key ( ) . ToList ( ) ;
@@ -186,7 +194,7 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
186194 In = ParameterLocation . Path ,
187195 Required = true ,
188196 Description = $ "The unique identifier of { entityType . Name } ",
189- Schema = context . CreateEdmTypeSchema ( keys . First ( ) . Type )
197+ Schema = context . CreateEdmTypeSchema ( keys [ 0 ] . Type , document )
190198 } ;
191199
192200 parameter . Extensions . Add ( Constants . xMsKeyType , new OpenApiAny ( entityType . Name ) ) ;
@@ -205,7 +213,7 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
205213 In = ParameterLocation . Path ,
206214 Required = true ,
207215 Description = $ "Property in multi-part unique identifier of { entityType . Name } ",
208- Schema = context . CreateEdmTypeSchema ( keyProperty . Type )
216+ Schema = context . CreateEdmTypeSchema ( keyProperty . Type , document )
209217 } ;
210218
211219 if ( keySegment . KeyMappings != null )
@@ -227,8 +235,9 @@ public static IList<OpenApiParameter> CreateKeyParameters(this ODataContext cont
227235 /// </summary>
228236 /// <param name="context">The OData context.</param>
229237 /// <param name="keySegment">The key segment.</param>
238+ /// <param name="document">The Open API document to lookup references.</param>
230239 /// <returns>A list of <see cref="OpenApiParameter"/> of alternate key parameters.</returns>
231- private static IList < OpenApiParameter > CreateAlternateKeyParameters ( ODataContext context , ODataSegment keySegment )
240+ private static IList < OpenApiParameter > CreateAlternateKeyParameters ( ODataContext context , ODataSegment keySegment , OpenApiDocument document )
232241 {
233242 Debug . Assert ( keySegment . Kind == ODataSegmentKind . Key ) ;
234243
@@ -248,7 +257,7 @@ private static IList<OpenApiParameter> CreateAlternateKeyParameters(ODataContext
248257 Name = alternateKey . First ( ) . Key ,
249258 In = ParameterLocation . Path ,
250259 Description = $ "Alternate key of { entityType . Name } ",
251- Schema = context . CreateEdmTypeSchema ( alternateKey . First ( ) . Value . Type ) ,
260+ Schema = context . CreateEdmTypeSchema ( alternateKey . First ( ) . Value . Type , document ) ,
252261 Required = true
253262 }
254263 ) ;
@@ -266,7 +275,7 @@ private static IList<OpenApiParameter> CreateAlternateKeyParameters(ODataContext
266275 Name = compositekey . Key ,
267276 In = ParameterLocation . Path ,
268277 Description = $ "Property in multi-part alternate key of { entityType . Name } ",
269- Schema = context . CreateEdmTypeSchema ( compositekey . Value . Type ) ,
278+ Schema = context . CreateEdmTypeSchema ( compositekey . Value . Type , document ) ,
270279 Required = true
271280 }
272281 ) ;
@@ -282,16 +291,17 @@ private static IList<OpenApiParameter> CreateAlternateKeyParameters(ODataContext
282291 /// </summary>
283292 /// <param name="path">The ODataPath</param>
284293 /// <param name="context">The OData context.</param>
294+ /// <param name="document">The Open API document to lookup references.</param>
285295 /// <returns>The created list of <see cref="OpenApiParameter"/></returns>
286- public static List < OpenApiParameter > CreatePathParameters ( this ODataPath path , ODataContext context )
296+ public static List < OpenApiParameter > CreatePathParameters ( this ODataPath path , ODataContext context , OpenApiDocument document )
287297 {
288298 List < OpenApiParameter > pathParameters = [ ] ;
289299 var parameterMappings = path . CalculateParameterMapping ( context . Settings ) ;
290300
291301 foreach ( ODataKeySegment keySegment in path . OfType < ODataKeySegment > ( ) )
292302 {
293303 IDictionary < string , string > mapping = parameterMappings [ keySegment ] ;
294- pathParameters . AddRange ( context . CreateKeyParameters ( keySegment , mapping ) ) ;
304+ pathParameters . AddRange ( context . CreateKeyParameters ( keySegment , document , mapping ) ) ;
295305 }
296306
297307 foreach ( ODataOperationSegment operationSegment in path . OfType < ODataOperationSegment > ( ) )
@@ -303,7 +313,7 @@ public static List<OpenApiParameter> CreatePathParameters(this ODataPath path, O
303313
304314 if ( operationSegment . ParameterMappings != null )
305315 {
306- IList < OpenApiParameter > parameters = context . CreateParameters ( function , operationSegment . ParameterMappings ) ;
316+ IList < OpenApiParameter > parameters = context . CreateParameters ( function , document , operationSegment . ParameterMappings ) ;
307317 foreach ( var parameter in parameters )
308318 {
309319 pathParameters . AppendParameter ( parameter ) ;
@@ -312,7 +322,7 @@ public static List<OpenApiParameter> CreatePathParameters(this ODataPath path, O
312322 else
313323 {
314324 IDictionary < string , string > mappings = parameterMappings [ operationSegment ] ;
315- IList < OpenApiParameter > parameters = context . CreateParameters ( function , mappings ) ;
325+ IList < OpenApiParameter > parameters = context . CreateParameters ( function , document , mappings ) ;
316326 pathParameters . AddRange ( parameters ) ;
317327 }
318328 }
0 commit comments