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";
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,4 @@ using Microsoft.OpenApi.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 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<LcuRequestViewModel> _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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,23 +55,28 @@
|
||||
<Grid
|
||||
RowDefinitions="*"
|
||||
ColumnDefinitions="auto,*">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
Margin="0 0 8 0"
|
||||
Text="{Binding LcuRequest.Value.Method}"
|
||||
Background="{Binding LcuRequest.Value.Color}"
|
||||
FontSize="8"
|
||||
Width="50"
|
||||
Padding="10 2 10 2"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"/>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Path}"
|
||||
FontSize="11"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"/>
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout>
|
||||
<MenuItem Header="Copy Swagger URL" Command="{Binding CopyUrlCommand}"/>
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
TextAlignment="Center"
|
||||
Margin="0 0 8 0"
|
||||
Text="{Binding LcuRequest.Value.Method}"
|
||||
Background="{Binding LcuRequest.Value.Color}"
|
||||
FontSize="8"
|
||||
Width="50"
|
||||
Padding="10 2 10 2"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"/>
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding Path}"
|
||||
FontSize="11"
|
||||
Grid.Row="0"
|
||||
Grid.Column="1"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
Reference in New Issue
Block a user