-
+
@foreach ( var media in Value.Content)
{
diff --git a/BlazorOpenApi/ExpandoTree.cs b/BlazorOpenApi/ExpandoTree.cs
new file mode 100644
index 0000000..2c81807
--- /dev/null
+++ b/BlazorOpenApi/ExpandoTree.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace BlazorOpenApi;
+
+internal class ExpandoTree : IExpandoTree
+{
+ private readonly Dictionary
_nodes = new();
+ private readonly List _order = new();
+
+ public void Add(string name, string anchor, string parentAnchor, bool collapsed)
+ {
+ if (_nodes.ContainsKey(anchor))
+ {
+ throw new InvalidOperationException($"A node with anchor '{anchor}' already exists.");
+ }
+
+ var node = new ExpandoTreeNode
+ {
+ Name = name,
+ Anchor = anchor,
+ ParentAnchor = parentAnchor,
+ Collapsed = collapsed
+ };
+
+ _nodes[anchor] = node;
+ _order.Add(anchor);
+ }
+
+ public void Collapse(string anchor, bool collapsed)
+ {
+ if (_nodes.TryGetValue(anchor, out var node))
+ {
+ node.Collapsed = collapsed;
+ }
+ else
+ {
+ throw new KeyNotFoundException($"No node found with anchor '{anchor}'.");
+ }
+ }
+
+ public bool IsCollapsed(string anchor)
+ {
+ return _nodes.TryGetValue(anchor, out var node) && node.Collapsed;
+ }
+
+ public bool Exists(string anchor) => _nodes.ContainsKey(anchor);
+
+ public ExpandoTreeNode[] GetChildren(string anchor) => _order
+ .Where(x => _nodes[x].ParentAnchor == anchor)
+ .Select(x => _nodes[x])
+ .ToArray();
+}
diff --git a/BlazorOpenApi/IExpandoTree.cs b/BlazorOpenApi/IExpandoTree.cs
new file mode 100644
index 0000000..54d45e8
--- /dev/null
+++ b/BlazorOpenApi/IExpandoTree.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BlazorOpenApi;
+
+public class ExpandoTreeNode
+{
+ public string Name { get; set; } = string.Empty;
+ public string Anchor { get; set; } = string.Empty;
+ public string ParentAnchor { get; set; } = string.Empty;
+ public bool Collapsed { get; set; }
+}
+
+public interface IExpandoTree
+{
+ void Add(string name, string anchor, string parentAnchor, bool collapsed);
+ void Collapse(string anchor, bool collapsed);
+ bool IsCollapsed(string anchor);
+ bool Exists(string anchor);
+ ExpandoTreeNode[] GetChildren(string anchor);
+}
+
+//implement IExpandoTree
\ No newline at end of file
diff --git a/BlazorOpenApi/OpenAPIUIControl.razor b/BlazorOpenApi/OpenAPIUIControl.razor
index 5d54315..34f9567 100644
--- a/BlazorOpenApi/OpenAPIUIControl.razor
+++ b/BlazorOpenApi/OpenAPIUIControl.razor
@@ -2,31 +2,36 @@
@using Microsoft.OpenApi.Models
@using Microsoft.OpenApi.Readers
+
@if (Palette != null )
{
@PaletteStr
}
-
-
-
- @if (_api.Paths?.Count > 0)
- {
- Endpoints
- foreach (var path in _api.Paths)
+
+
+
+
+
+ @if (_api.Paths?.Count > 0)
{
- if (!string.IsNullOrWhiteSpace(path.Key) || path.Value != null)
+ Endpoints
+ foreach (var path in _api.Paths)
{
-
+ if (!string.IsNullOrWhiteSpace(path.Key) || path.Value != null)
+ {
+
+ }
}
}
- }
- @if (_api.Components != null)
- {
- Components
-
- }
+ @if (_api.Components != null)
+ {
+ Components
+
+ }
+
+
@@ -35,8 +40,11 @@
[Parameter] public string Json { get; set; } = "";
[Parameter] public OpenApiUiPalette? Palette { get; set; }
+
private string _loadedFor = "";
+
private OpenApiDocument _api = new();
+ private IExpandoTree _tree = new ExpandoTree();
private MarkupString PaletteStr => Palette?.AsMarkupString ?? new();
@@ -98,4 +106,6 @@
_api = new();
}
}
+
+
}