mirror of
https://github.com/BlossomiShymae/Needlework.Net.git
synced 2025-12-06 10:10:48 +01:00
Add copy Swagger URL context flyout
This commit is contained in:
@@ -36,10 +36,10 @@ public class OpenApiDocumentWrapper
|
|||||||
{
|
{
|
||||||
pluginsKey = "default";
|
pluginsKey = "default";
|
||||||
if (plugins.TryGetValue(pluginsKey, out var p))
|
if (plugins.TryGetValue(pluginsKey, out var p))
|
||||||
p.Add(new(method.ToString(), path, operation));
|
p.Add(new(method.ToString(), path, pluginsKey, operation));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operations.Add(new(method.ToString(), path, operation));
|
operations.Add(new(method.ToString(), path, pluginsKey, operation));
|
||||||
plugins[pluginsKey] = operations;
|
plugins[pluginsKey] = operations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,10 +53,10 @@ public class OpenApiDocumentWrapper
|
|||||||
pluginsKey = tag.Name;
|
pluginsKey = tag.Name;
|
||||||
|
|
||||||
if (plugins.TryGetValue(pluginsKey, out var p))
|
if (plugins.TryGetValue(pluginsKey, out var p))
|
||||||
p.Add(new(method.ToString(), path, operation));
|
p.Add(new(method.ToString(), path, tag.Name, operation));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
operations.Add(new(method.ToString(), path, operation));
|
operations.Add(new(method.ToString(), path, tag.Name, operation));
|
||||||
plugins[pluginsKey] = operations;
|
plugins[pluginsKey] = operations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ using Microsoft.OpenApi.Models;
|
|||||||
|
|
||||||
namespace Needlework.Net.Models;
|
namespace Needlework.Net.Models;
|
||||||
|
|
||||||
public record PathOperation(string Method, string Path, OpenApiOperation Operation);
|
public record PathOperation(string Method, string Path, string Tag, OpenApiOperation Operation);
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using Avalonia.Controls;
|
||||||
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Needlework.Net.Models;
|
using Needlework.Net.Models;
|
||||||
@@ -14,6 +15,8 @@ public partial class PathOperationViewModel : ObservableObject
|
|||||||
public string Path { get; }
|
public string Path { get; }
|
||||||
public OperationViewModel Operation { get; }
|
public OperationViewModel Operation { get; }
|
||||||
|
|
||||||
|
public string Url { get; }
|
||||||
|
|
||||||
[ObservableProperty] private bool _isBusy;
|
[ObservableProperty] private bool _isBusy;
|
||||||
[ObservableProperty] private Lazy<LcuRequestViewModel> _lcuRequest;
|
[ObservableProperty] private Lazy<LcuRequestViewModel> _lcuRequest;
|
||||||
|
|
||||||
@@ -25,6 +28,7 @@ public partial class PathOperationViewModel : ObservableObject
|
|||||||
{
|
{
|
||||||
Method = pathOperation.Method.ToUpper()
|
Method = pathOperation.Method.ToUpper()
|
||||||
});
|
});
|
||||||
|
Url = $"https://swagger.dysolix.dev/lcu/#/{pathOperation.Tag}/{pathOperation.Operation.OperationId}";
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -50,4 +54,10 @@ public partial class PathOperationViewModel : ObservableObject
|
|||||||
LcuRequest.Value.RequestPath = sb.ToString();
|
LcuRequest.Value.RequestPath = sb.ToString();
|
||||||
await LcuRequest.Value.ExecuteAsync();
|
await LcuRequest.Value.ExecuteAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
private void CopyUrl()
|
||||||
|
{
|
||||||
|
App.MainWindow?.Clipboard?.SetTextAsync(Url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,11 @@
|
|||||||
<Grid
|
<Grid
|
||||||
RowDefinitions="*"
|
RowDefinitions="*"
|
||||||
ColumnDefinitions="auto,*">
|
ColumnDefinitions="auto,*">
|
||||||
|
<Grid.ContextFlyout>
|
||||||
|
<MenuFlyout>
|
||||||
|
<MenuItem Header="Copy Swagger URL" Command="{Binding CopyUrlCommand}"/>
|
||||||
|
</MenuFlyout>
|
||||||
|
</Grid.ContextFlyout>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
TextAlignment="Center"
|
TextAlignment="Center"
|
||||||
|
|||||||
Reference in New Issue
Block a user