public IEndpoint?TryGetEndpoint(PathTree tree, IPatternMatcher patternMatcher) { var children = patternMatcher.GetEndpoints(tree); if (children.Count == 0) { return(null); // Plain endpoint with no children serves no purpose } var endpoint = new Endpoint(); endpoint.Children.AddRange(children); return(endpoint); }
public IEndpoint TryGetEndpoint(PathTree tree, IPatternMatcher patternMatcher) { var operations = tree.Item?.Operations.Keys ?? new OperationType[0]; if (!RequiredOperations.All(operations.Contains)) { return(null); } var endpoint = BuildEndpoint(tree.Item); endpoint?.Children.AddRange(patternMatcher.GetEndpoints(tree)); return(endpoint); }
public IEndpoint?TryGetEndpoint(PathTree tree, IPatternMatcher patternMatcher) { var item = tree.Item; if (item == null || !RequiredOperations.All(item.Operations.Keys.Contains)) { return(null); } var endpoint = BuildEndpoint(item); endpoint?.Children.AddRange(patternMatcher.GetEndpoints(tree)); return(endpoint); }
public override IEndpoint?TryGetEndpoint(PathTree tree, IPatternMatcher patternMatcher) { var item = tree.Item; if (item == null || !item.Operations.TryGetValue(OperationType.Get, out var operation)) { return(null); } var children = patternMatcher.GetEndpoints(tree); var element = ExtractElement <ElementEndpoint>(children); if (element == null) { return(null); } var response = operation.Get200Response(); var schema = response?.GetJsonSchema(); // Ensure collection and element schemas match if (schema?.Type != "array" || schema.Items?.Reference?.Id != element.Schema?.Reference?.Id) { return(null); } element.Schema = null; var endpoint = new CollectionEndpoint { Schema = schema.Items, Element = (element.Children.Count == 0) ? null : element, // Trim trivial element endpoint Description = item.Description ?? operation.Description ?? operation.Summary ?? response?.Description ?? schema.Description }; endpoint.Children.AddRange(children); return(endpoint); }
public virtual IEndpoint?TryGetEndpoint(PathTree tree, IPatternMatcher patternMatcher) { var item = tree.Item; OpenApiOperation?operation = null; item?.Operations.TryGetValue(OperationType.Get, out operation); var children = patternMatcher.GetEndpoints(tree); var element = ExtractElement <IEndpoint>(children); if (element == null) { return(null); } var endpoint = new IndexerEndpoint { Element = element, Description = item?.Description ?? operation?.Description ?? operation?.Summary }; endpoint.Children.AddRange(children); return(endpoint); }