mirror of
https://github.com/foss42/apidash.git
synced 2025-12-01 10:17:47 +08:00
fix: open api spec bottom modal sheet
This commit is contained in:
@@ -233,6 +233,9 @@ class DashbotImportNowButton extends ConsumerWidget with DashbotActionMixin {
|
|||||||
try {
|
try {
|
||||||
OpenApi? spec;
|
OpenApi? spec;
|
||||||
String? sourceName;
|
String? sourceName;
|
||||||
|
final overlayNotifier =
|
||||||
|
ref.read(dashbotWindowNotifierProvider.notifier);
|
||||||
|
final chatNotifier = ref.read(chatViewmodelProvider.notifier);
|
||||||
if (action.value is Map<String, dynamic>) {
|
if (action.value is Map<String, dynamic>) {
|
||||||
final map = action.value as Map<String, dynamic>;
|
final map = action.value as Map<String, dynamic>;
|
||||||
sourceName = map['sourceName'] as String?;
|
sourceName = map['sourceName'] as String?;
|
||||||
@@ -247,9 +250,6 @@ class DashbotImportNowButton extends ConsumerWidget with DashbotActionMixin {
|
|||||||
|
|
||||||
final servers = spec.servers ?? const [];
|
final servers = spec.servers ?? const [];
|
||||||
final baseUrl = servers.isNotEmpty ? (servers.first.url ?? '/') : '/';
|
final baseUrl = servers.isNotEmpty ? (servers.first.url ?? '/') : '/';
|
||||||
|
|
||||||
final overlayNotifier =
|
|
||||||
ref.read(dashbotWindowNotifierProvider.notifier);
|
|
||||||
overlayNotifier.hide();
|
overlayNotifier.hide();
|
||||||
final selected = await showOpenApiOperationPickerDialog(
|
final selected = await showOpenApiOperationPickerDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -258,8 +258,6 @@ class DashbotImportNowButton extends ConsumerWidget with DashbotActionMixin {
|
|||||||
);
|
);
|
||||||
overlayNotifier.show();
|
overlayNotifier.show();
|
||||||
if (selected == null || selected.isEmpty) return;
|
if (selected == null || selected.isEmpty) return;
|
||||||
|
|
||||||
final notifier = ref.read(chatViewmodelProvider.notifier);
|
|
||||||
for (final s in selected) {
|
for (final s in selected) {
|
||||||
final payload = OpenApiImportService.payloadForOperation(
|
final payload = OpenApiImportService.payloadForOperation(
|
||||||
baseUrl: baseUrl,
|
baseUrl: baseUrl,
|
||||||
@@ -267,7 +265,7 @@ class DashbotImportNowButton extends ConsumerWidget with DashbotActionMixin {
|
|||||||
method: s.method,
|
method: s.method,
|
||||||
op: s.op,
|
op: s.op,
|
||||||
);
|
);
|
||||||
await notifier.applyAutoFix(ChatAction.fromJson({
|
await chatNotifier.applyAutoFix(ChatAction.fromJson({
|
||||||
'action': 'apply_openapi',
|
'action': 'apply_openapi',
|
||||||
'actionType': 'apply_openapi',
|
'actionType': 'apply_openapi',
|
||||||
'target': 'httpRequestModel',
|
'target': 'httpRequestModel',
|
||||||
@@ -372,7 +370,6 @@ class DashbotActionWidgetFactory {
|
|||||||
case ChatActionType.downloadDoc:
|
case ChatActionType.downloadDoc:
|
||||||
return DashbotDownloadDocButton(action: action);
|
return DashbotDownloadDocButton(action: action);
|
||||||
case ChatActionType.noAction:
|
case ChatActionType.noAction:
|
||||||
// If downstream requests, render an Import Now for OpenAPI contexts
|
|
||||||
if (action.action == 'import_now_openapi') {
|
if (action.action == 'import_now_openapi') {
|
||||||
return DashbotImportNowButton(action: action);
|
return DashbotImportNowButton(action: action);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user