mirror of
https://github.com/postmanlabs/openapi-to-postman.git
synced 2022-11-29 22:05:00 +03:00
Add getMetaData function
This commit is contained in:
5
index.js
5
index.js
@@ -18,6 +18,11 @@ module.exports = {
|
||||
return schema.validationResult;
|
||||
},
|
||||
|
||||
getMetaData: function (input) {
|
||||
var schema = new SchemaPack(input);
|
||||
return schema.metaData;
|
||||
},
|
||||
|
||||
mergeAndValidate: function (input, cb) {
|
||||
var schema = new SchemaPack(input);
|
||||
schema.mergeAndValidate(cb);
|
||||
|
||||
@@ -81,6 +81,7 @@ class SchemaPack {
|
||||
);
|
||||
// hardcoding this option - not exposed to users yet
|
||||
this.computedOptions.schemaFaker = true;
|
||||
this.metaData = null;
|
||||
|
||||
this.validate();
|
||||
}
|
||||
@@ -150,13 +151,32 @@ class SchemaPack {
|
||||
}
|
||||
|
||||
this.openapi = specParseResult.openapi;
|
||||
this.metaData = this.getMetaData(this.openapi);
|
||||
this.validated = true;
|
||||
this.validationResult = {
|
||||
result: true
|
||||
result: true,
|
||||
meta: this.metaData
|
||||
};
|
||||
return this.validationResult;
|
||||
}
|
||||
|
||||
getMetaData (openapi) {
|
||||
if (!openapi) {
|
||||
return {
|
||||
result: false,
|
||||
reason: 'Empty collection'
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
result: true,
|
||||
output: [{
|
||||
type: 'collection',
|
||||
data: _.get(openapi, 'info.title', COLLECTION_NAME)
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
mergeAndValidate (cb) {
|
||||
let input = this.input,
|
||||
validationResult,
|
||||
|
||||
Reference in New Issue
Block a user