Skip to content

[Feat]: Add Import from cURL in Query Library #1803

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

Merged
merged 6 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Feat] #1799 add simple examples on curl modal
  • Loading branch information
iamfaran committed Jun 23, 2025
commit 12b4b41f15c8dc37351a19f2d0774dc5bc1b1709
19 changes: 13 additions & 6 deletions client/packages/lowcoder/src/components/CurlImport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export function CurlImportModal(props: CurlImportModalProps) {
try {
// Parse the cURL command using the correct import
const parsedData = parseCurl(curlCommand);
console.log("CURL JSON", parsedData)



Expand Down Expand Up @@ -72,15 +71,23 @@ export function CurlImportModal(props: CurlImportModalProps) {
Paste cURL Command Here
</div>
<div style={{ marginBottom: 12, color: "#666", fontSize: "12px" }}>
Hint: Try typing in the following curl command and then click on the 'Import' button:
curl -X GET https://mock-api.appsmith.com/users
<div style={{ marginBottom: 4 }}>
<strong>Examples:</strong>
</div>
<div style={{ marginBottom: 2 }}>
GET: <code>curl -X GET https://jsonplaceholder.typicode.com/posts/1</code>
</div>
<div style={{ marginBottom: 2 }}>
POST: <code>curl -X POST https://jsonplaceholder.typicode.com/posts -H "Content-Type: application/json" -d '&#123;"title":"foo","body":"bar","userId":1&#125;'</code>
</div>
<div>
Users: <code>curl -X GET https://jsonplaceholder.typicode.com/users</code>
</div>
</div>
<TextArea
value={curlCommand}
onChange={(e) => setCurlCommand(e.target.value)}
placeholder="curl -X POST \
-H 'Content-Type: application/json' \
'https://generativelanguage.googleapis.com/v1beta/models/{MODEL_ID}:{GENERATE_CONTENT_API}?key={GEMINI_API_KEY}' -d '@request.json'"
placeholder="curl -X GET https://jsonplaceholder.typicode.com/posts/1"
rows={8}
style={{ fontFamily: "monospace" }}
/>
Expand Down
5 changes: 0 additions & 5 deletions client/packages/lowcoder/src/components/ResCreatePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,6 @@ export function ResCreatePanel(props: ResCreateModalProps) {
}, 100);

const handleCurlImportSuccess = (parsedData: any) => {
// For now just log the result as requested
console.log("cURL import successful:", parsedData);

// Create a new REST API query with the parsed data
// We'll pass the parsed data as extra info to be used when creating the query
onSelect(BottomResTypeEnum.Query, {
compType: "restApi",
dataSourceId: QUICK_REST_API_ID,
Expand Down
2 changes: 0 additions & 2 deletions client/packages/lowcoder/src/util/curlUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ function parseUrlEncodedData(data: string | object): Array<{ key: string; value:
export function processCurlData(curlData: any) {
if (!curlData) return null;

console.log("Raw cURL data:", curlData); // Debug log

// Convert headers object to key-value array format expected by UI
const headers = curlData.header
Expand Down Expand Up @@ -96,7 +95,6 @@ export function processCurlData(curlData: any) {
if (bodyType === "application/x-www-form-urlencoded") {
bodyFormData = parseUrlEncodedData(bodyContent);
processedBody = ""; // Form data goes in bodyFormData, not body
console.log("Parsed form data:", bodyFormData); // Debug log
} else if (typeof bodyContent === "object") {
processedBody = JSON.stringify(bodyContent, null, 2);
} else {
Expand Down
Loading