/// <inheritdoc/> public virtual OpenApiOperation CreateOperation(ODataContext context, ODataPath path) { Context = context ?? throw Error.ArgumentNull(nameof(context)); Path = path ?? throw Error.ArgumentNull(nameof(path)); ParameterMappings = path.CalculateParameterMapping(context.Settings); // Initialize the object ahead. Initialize(context, path); OpenApiOperation operation = new OpenApiOperation(); // Description / Summary / OperationId SetBasicInfo(operation); // Security SetSecurity(operation); // Responses SetResponses(operation); // RequestBody SetRequestBody(operation); // Parameters SetParameters(operation); // Tags SetTags(operation); // Extensions SetExtensions(operation); return(operation); }
/// <summary> /// Creates the path parameters for the <see cref="ODataPath"/> /// </summary> /// <param name="path">The ODataPath</param> /// <param name="context">The OData context.</param> /// <returns>The created list of <see cref="OpenApiParameter"/></returns> public static List <OpenApiParameter> CreatePathParameters(this ODataPath path, ODataContext context) { List <OpenApiParameter> pathParameters = new(); var parameterMappings = path.CalculateParameterMapping(context.Settings); foreach (ODataKeySegment keySegment in path.OfType <ODataKeySegment>()) { IDictionary <string, string> mapping = parameterMappings[keySegment]; pathParameters.AddRange(context.CreateKeyParameters(keySegment, mapping)); } // Add the route prefix parameter v1{data} if (context.Settings.RoutePathPrefixProvider?.Parameters != null) { pathParameters.AddRange(context.Settings.RoutePathPrefixProvider.Parameters); } return(pathParameters); }