private IDictionary <string, OpenApiPathItem> CreatePathItemsWithOperations(IEdmNavigationSource navigationSource) { IDictionary <string, OpenApiPathItem> operationPathItems = new Dictionary <string, OpenApiPathItem>(); IEnumerable <IEdmOperation> operations; IEdmEntitySet entitySet = navigationSource as IEdmEntitySet; // collection bound if (entitySet != null) { operations = FindOperations(navigationSource.EntityType(), collection: true); foreach (var operation in operations) { OpenApiPathItem openApiOperation = operation.CreatePathItem(); string operationPathName = operation.CreatePathItemName(); operationPathItems.Add("/" + navigationSource.Name + operationPathName, openApiOperation); } } // non-collection bound operations = FindOperations(navigationSource.EntityType(), collection: false); foreach (var operation in operations) { OpenApiPathItem openApiOperation = operation.CreatePathItem(); string operationPathName = operation.CreatePathItemName(); string temp; if (entitySet != null) { temp = entitySet.CreatePathNameForEntity(); } else { temp = "/" + navigationSource.Name; } operationPathItems.Add(temp + operationPathName, openApiOperation); } return(operationPathItems); }
public IDictionary <string, OpenApiPathItem> CreatePaths(IEdmEntitySet entitySet) { IDictionary <string, OpenApiPathItem> paths = new Dictionary <string, OpenApiPathItem>(); // itself OpenApiPathItem pathItem = new OpenApiPathItem { Get = entitySet.CreateGetOperationForEntitySet(), Post = entitySet.CreatePostOperationForEntitySet() }; paths.Add("/" + entitySet.Name, pathItem); // entity string entityPathName = entitySet.CreatePathNameForEntity(); pathItem = new OpenApiPathItem { Get = entitySet.CreateGetOperationForEntity(), Patch = entitySet.CreatePatchOperationForEntity(), Delete = entitySet.CreateDeleteOperationForEntity() }; paths.Add(entityPathName, pathItem); // bound operations IDictionary <string, OpenApiPathItem> operations = CreatePathItemsWithOperations(entitySet); foreach (var operation in operations) { paths.Add(operation); } return(paths); }