-
Notifications
You must be signed in to change notification settings - Fork 418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Form-Data and multi-part request feature added #101
Conversation
lib/consts.dart
Outdated
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:google_fonts/google_fonts.dart'; | ||
import 'package:davi/davi.dart'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback in regards to import across all the files.
Please revert all import re-arrangements that have been done as they are introducing non-essential code changes.
Only add new import lines or modify existing lines.
lib/consts.dart
Outdated
@@ -294,6 +298,15 @@ const kSubTypeDefaultViewOptions = 'all'; | |||
const kContentTypeMap = { | |||
ContentType.json: "$kTypeApplication/$kSubTypeJson", | |||
ContentType.text: "$kTypeText/$kSubTypePlain", | |||
ContentType.formdata: "multipart/form-data", | |||
}; | |||
const kFormDataTypeMap = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kFormDataTypeMap & kMapFormDataType can be avoided if FormDataType
is structured as CodegenLanguage
lib/utils/convert_utils.dart
Outdated
import '../models/models.dart'; | ||
import 'dart:typed_data'; | ||
|
||
import 'package:apidash/models/form_data_model.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should already be imported via '../models/models.dart'
lib/services/http_service.dart
Outdated
@@ -63,3 +65,59 @@ Future<(http.Response?, Duration?, String?)> request( | |||
return (null, null, uriRec.$2); | |||
} | |||
} | |||
|
|||
Future<(http.Response?, Duration?, String?)> multiPartRequest( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the existing function be modified to support multipart using a multipart = true argument
Thanks for the PR @vidya-hub There are overflow issues. It should be along the lines of params and headers which have an empty default row in the beginning and the user is able to clear the first row (which gets replaced by an empty row) if it is the only row. Please play around with headers & params to better understand the behaviour. Also, the color scheme of the file picker widget (purple) is not following the color theme of API Dash. |
Thanks for your comments and observations. Thank you. |
lib/consts.dart
Outdated
@@ -48,6 +48,10 @@ const kHintOpacity = 0.6; | |||
const kForegroundOpacity = 0.05; | |||
|
|||
const kTextStyleButton = TextStyle(fontWeight: FontWeight.bold); | |||
const kFormDataButton = TextStyle( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kFormDataButton
-> kFormDataButtonLabelTextStyle
Hi @vidya-hub |
Hey @ashitaprasad Thank you Can you tell me which issues I've missed so that i can give a fix for that |
Sure @vidya-hub |
(http.Response?, Duration?, String?)? responseRec = await request( | ||
requestModel, | ||
defaultUriScheme: defaultUriScheme, | ||
isMultiPartRequest: requestModel.formDataList != null && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requestBodyContentType
is the correct way to determine the value of isMultiPartRequest
.
@@ -108,36 +108,40 @@ class _RequestListState extends ConsumerState<RequestList> { | |||
controller: controller, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this change which has nothing to do with formdata & we already show a full page message in details pane when there is no request.
@@ -3,6 +3,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; | |||
import 'package:apidash/providers/providers.dart'; | |||
import 'package:apidash/widgets/widgets.dart'; | |||
import 'package:apidash/consts.dart'; | |||
import 'package:apidash/widgets/form_data_widget.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add form_data_widget.dart
to widgets.dart
which is already imported.
@@ -12,12 +13,21 @@ class EditRequestBody extends ConsumerStatefulWidget { | |||
} | |||
|
|||
class _EditRequestBodyState extends ConsumerState<EditRequestBody> { | |||
@override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove as you are not doing anything inside initState()
@vidya-hub I have made some changes to the PR. |
Sure @ashitaprasad |
Form data code gen merge
I've gone through the changes and tested it everything is working fine in form-data side. |
Hi @vidya-hub, |
Thank you @ashitaprasad I will check and update. |
chore: fixed code generation test cases
Hi @ashitaprasad Thanks! |
Sure @vidya-hub 👍 |
chore: fixed spacing issues in nodejs axios codegen
@vidya-hub Since you are not adding any new test cases for multipart forms, please make changes only to the codegen codes and revert any changes made to the expected codes (even spacings) given in the test files. |
Sure @ashitaprasad |
test/models/request_model_test.dart can you please check this file in PR once |
@vidya-hub |
rev: reverted changes in js code gen
Thank you, I've pushed the changes, |
Sure @vidya-hub 👍 |
@vidya-hub There was a minor issue with python codegen which I have fixed. |
Thanks a lot @ashitaprasad Sure I am working on it already. Thank you for your comments and suggestions. |
@vidya-hub |
Thank you @ashitaprasad. Sure 😊 |
**Multi-Part Request Feature #92,#91 **