From 68e5abd1d181e7e8217049f6721d3d9411940c67 Mon Sep 17 00:00:00 2001 From: estrogen elf <87099578+BlossomiShymae@users.noreply.github.com> Date: Mon, 5 May 2025 02:55:36 -0500 Subject: [PATCH] Add copy Swagger URL context flyout --- .../Models/OpenApiDocumentWrapper.cs | 8 ++-- Needlework.Net/Models/PathOperation.cs | 2 +- .../Pages/Endpoints/PathOperationViewModel.cs | 12 +++++- .../Views/Pages/Endpoints/EndpointView.axaml | 39 +++++++++++-------- 4 files changed, 38 insertions(+), 23 deletions(-) diff --git a/Needlework.Net/Models/OpenApiDocumentWrapper.cs b/Needlework.Net/Models/OpenApiDocumentWrapper.cs index b949395..481862b 100644 --- a/Needlework.Net/Models/OpenApiDocumentWrapper.cs +++ b/Needlework.Net/Models/OpenApiDocumentWrapper.cs @@ -36,10 +36,10 @@ public class OpenApiDocumentWrapper { pluginsKey = "default"; if (plugins.TryGetValue(pluginsKey, out var p)) - p.Add(new(method.ToString(), path, operation)); + p.Add(new(method.ToString(), path, pluginsKey, operation)); else { - operations.Add(new(method.ToString(), path, operation)); + operations.Add(new(method.ToString(), path, pluginsKey, operation)); plugins[pluginsKey] = operations; } } @@ -53,10 +53,10 @@ public class OpenApiDocumentWrapper pluginsKey = tag.Name; if (plugins.TryGetValue(pluginsKey, out var p)) - p.Add(new(method.ToString(), path, operation)); + p.Add(new(method.ToString(), path, tag.Name, operation)); else { - operations.Add(new(method.ToString(), path, operation)); + operations.Add(new(method.ToString(), path, tag.Name, operation)); plugins[pluginsKey] = operations; } } diff --git a/Needlework.Net/Models/PathOperation.cs b/Needlework.Net/Models/PathOperation.cs index 7e5b914..90f3956 100644 --- a/Needlework.Net/Models/PathOperation.cs +++ b/Needlework.Net/Models/PathOperation.cs @@ -2,4 +2,4 @@ using Microsoft.OpenApi.Models; namespace Needlework.Net.Models; -public record PathOperation(string Method, string Path, OpenApiOperation Operation); \ No newline at end of file +public record PathOperation(string Method, string Path, string Tag, OpenApiOperation Operation); \ No newline at end of file diff --git a/Needlework.Net/ViewModels/Pages/Endpoints/PathOperationViewModel.cs b/Needlework.Net/ViewModels/Pages/Endpoints/PathOperationViewModel.cs index 977cec6..3cb38cb 100644 --- a/Needlework.Net/ViewModels/Pages/Endpoints/PathOperationViewModel.cs +++ b/Needlework.Net/ViewModels/Pages/Endpoints/PathOperationViewModel.cs @@ -1,4 +1,5 @@ -using CommunityToolkit.Mvvm.ComponentModel; +using Avalonia.Controls; +using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; using Microsoft.Extensions.Logging; using Needlework.Net.Models; @@ -14,6 +15,8 @@ public partial class PathOperationViewModel : ObservableObject public string Path { get; } public OperationViewModel Operation { get; } + public string Url { get; } + [ObservableProperty] private bool _isBusy; [ObservableProperty] private Lazy _lcuRequest; @@ -25,6 +28,7 @@ public partial class PathOperationViewModel : ObservableObject { Method = pathOperation.Method.ToUpper() }); + Url = $"https://swagger.dysolix.dev/lcu/#/{pathOperation.Tag}/{pathOperation.Operation.OperationId}"; } [RelayCommand] @@ -50,4 +54,10 @@ public partial class PathOperationViewModel : ObservableObject LcuRequest.Value.RequestPath = sb.ToString(); await LcuRequest.Value.ExecuteAsync(); } + + [RelayCommand] + private void CopyUrl() + { + App.MainWindow?.Clipboard?.SetTextAsync(Url); + } } diff --git a/Needlework.Net/Views/Pages/Endpoints/EndpointView.axaml b/Needlework.Net/Views/Pages/Endpoints/EndpointView.axaml index f053941..96fd17e 100644 --- a/Needlework.Net/Views/Pages/Endpoints/EndpointView.axaml +++ b/Needlework.Net/Views/Pages/Endpoints/EndpointView.axaml @@ -55,23 +55,28 @@ - - + + + + + + +