mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Using examples before schemas while converting response bodies
This commit is contained in:
22
lib/util.js
22
lib/util.js
@@ -553,23 +553,23 @@ module.exports = {
|
||||
|
||||
// This part is to remove format:binary from any string-type properties
|
||||
// will cause schemaFaker to crash if left untreated
|
||||
if (bodyObj.hasOwnProperty('schema')) {
|
||||
if (bodyObj.schema.hasOwnProperty('$ref')) {
|
||||
bodyObj.schema = this.getRefObject(bodyObj.schema.$ref);
|
||||
}
|
||||
bodyData = this.options.schemaFaker ? safeSchemaFaker(bodyObj.schema || {}, this.components) : '';
|
||||
}
|
||||
else if (bodyObj.hasOwnProperty('examples')) {
|
||||
bodyData = this.getExampleData(bodyObj.examples);
|
||||
// take one of the examples as the body and not all
|
||||
}
|
||||
else if (bodyObj.hasOwnProperty('example')) {
|
||||
if (bodyObj.hasOwnProperty('example')) {
|
||||
bodyData = bodyObj.example;
|
||||
// return example value if present else example is returned
|
||||
if (bodyData.value) {
|
||||
bodyData = bodyData.value;
|
||||
}
|
||||
}
|
||||
else if (bodyObj.hasOwnProperty('examples')) {
|
||||
bodyData = this.getExampleData(bodyObj.examples);
|
||||
// take one of the examples as the body and not all
|
||||
}
|
||||
else if (bodyObj.hasOwnProperty('schema')) {
|
||||
if (bodyObj.schema.hasOwnProperty('$ref')) {
|
||||
bodyObj.schema = this.getRefObject(bodyObj.schema.$ref);
|
||||
}
|
||||
bodyData = this.options.schemaFaker ? safeSchemaFaker(bodyObj.schema || {}, this.components) : '';
|
||||
}
|
||||
return bodyData;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user