mirror of
https://github.com/usebruno/bruno.git
synced 2025-02-16 17:51:48 +01:00
Bugfix/openapi import array body (#3009)
* added validations for spec and ref * Fix | openapispec import-show proper body for arrays of objects * removed unwanted changes * handles body schema of array of objects * removed logs --------- Co-authored-by: Anusree Subash <anusree@usebruno.com>
This commit is contained in:
parent
450b1d3ae3
commit
ab8afed8f9
@ -40,9 +40,12 @@ const buildEmptyJsonBody = (bodySchema) => {
|
|||||||
each(bodySchema.properties || {}, (prop, name) => {
|
each(bodySchema.properties || {}, (prop, name) => {
|
||||||
if (prop.type === 'object') {
|
if (prop.type === 'object') {
|
||||||
_jsonBody[name] = buildEmptyJsonBody(prop);
|
_jsonBody[name] = buildEmptyJsonBody(prop);
|
||||||
// handle arrays
|
|
||||||
} else if (prop.type === 'array') {
|
} else if (prop.type === 'array') {
|
||||||
_jsonBody[name] = [];
|
if (prop.items && prop.items.type === 'object') {
|
||||||
|
_jsonBody[name] = [buildEmptyJsonBody(prop.items)];
|
||||||
|
} else {
|
||||||
|
_jsonBody[name] = [];
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_jsonBody[name] = '';
|
_jsonBody[name] = '';
|
||||||
}
|
}
|
||||||
@ -164,6 +167,9 @@ const transformOpenapiRequestItem = (request) => {
|
|||||||
let _jsonBody = buildEmptyJsonBody(bodySchema);
|
let _jsonBody = buildEmptyJsonBody(bodySchema);
|
||||||
brunoRequestItem.request.body.json = JSON.stringify(_jsonBody, null, 2);
|
brunoRequestItem.request.body.json = JSON.stringify(_jsonBody, null, 2);
|
||||||
}
|
}
|
||||||
|
if (bodySchema && bodySchema.type === 'array') {
|
||||||
|
brunoRequestItem.request.body.json = JSON.stringify([buildEmptyJsonBody(bodySchema.items)], null, 2);
|
||||||
|
}
|
||||||
} else if (mimeType === 'application/x-www-form-urlencoded') {
|
} else if (mimeType === 'application/x-www-form-urlencoded') {
|
||||||
brunoRequestItem.request.body.mode = 'formUrlEncoded';
|
brunoRequestItem.request.body.mode = 'formUrlEncoded';
|
||||||
if (bodySchema && bodySchema.type === 'object') {
|
if (bodySchema && bodySchema.type === 'object') {
|
||||||
|
Loading…
Reference in New Issue
Block a user