mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-18 06:49:50 +02:00
Fix [object Object] request descriptions after OpenAPI import (#412)
This commit is contained in:
@@ -55,19 +55,11 @@ export function convertPostman(contents: string): ImportPluginResponse | undefin
|
||||
folders: [],
|
||||
};
|
||||
|
||||
const rawDescription = info.description;
|
||||
const description =
|
||||
typeof rawDescription === 'object' && rawDescription != null && 'content' in rawDescription
|
||||
? String(rawDescription.content)
|
||||
: rawDescription == null
|
||||
? undefined
|
||||
: String(rawDescription);
|
||||
|
||||
const workspace: ExportResources['workspaces'][0] = {
|
||||
model: 'workspace',
|
||||
id: generateId('workspace'),
|
||||
name: info.name ? String(info.name) : 'Postman Import',
|
||||
description,
|
||||
description: importDescription(info.description),
|
||||
...globalAuth,
|
||||
};
|
||||
exportResources.workspaces.push(workspace);
|
||||
@@ -139,7 +131,7 @@ export function convertPostman(contents: string): ImportPluginResponse | undefin
|
||||
workspaceId: workspace.id,
|
||||
folderId,
|
||||
name: v.name,
|
||||
description: r.description ? String(r.description) : undefined,
|
||||
description: importDescription(r.description),
|
||||
method: typeof r.method === 'string' ? r.method : 'GET',
|
||||
url,
|
||||
urlParameters,
|
||||
@@ -509,6 +501,26 @@ function toArray<T>(value: unknown): T[] {
|
||||
return [];
|
||||
}
|
||||
|
||||
function importDescription(rawDescription: unknown): string | undefined {
|
||||
if (rawDescription == null) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (typeof rawDescription === 'string') {
|
||||
return rawDescription;
|
||||
}
|
||||
|
||||
if (typeof rawDescription === 'object' && !Array.isArray(rawDescription)) {
|
||||
const description = toRecord(rawDescription);
|
||||
if ('content' in description && description.content != null) {
|
||||
return String(description.content);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return String(rawDescription);
|
||||
}
|
||||
|
||||
/** Recursively render all nested object properties */
|
||||
function convertTemplateSyntax<T>(obj: T): T {
|
||||
if (typeof obj === 'string') {
|
||||
|
||||
Reference in New Issue
Block a user