-
Notifications
You must be signed in to change notification settings - Fork 4
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
Example #22
Comments
@sumachaa We will be updating README.md with better description in future release. For now you can follow this steps. Using the converter as a NodeJS moduleIn order to use the convert in your node application, you need to import the package using var Converter = require('raml1-to-postman') The converter provides the following functions: ConvertThe convert function takes in your RAML 1.0 specification and converts it to a Postman collection. Signature: data: { type: 'file', data: 'filepath' }
OR
{ type: 'string', data: '<entire RAML 1.0 Specification string>' }
OR
{ type: 'folder', data: [Array of Objects with fileName property and file-path as it's value] } options: {
collapseFolders: true,
requestParametersResolution: 'schema',
exampleParametersResolution: 'example'
}
/*
All three properties are optional. Defaults will be used for no options provided. For now you can pass this as empty object.
*/ callback: function (err, result) {
/*
result = {
result: true,
output: [
{
type: 'collection',
data: {..collection object..}
}
]
}
*/
} ConversionResult
Sample Usage:var fs = require('fs'),
Converter = require('raml1-to-postman'),
ramlSpec = fs.readFileSync('sample-spec.raml', {encoding: 'UTF8'});
Converter.convert({ type: 'string', data: ramlSpec },
{}, (err, conversionResult) => {
if (!conversionResult.result) {
console.log('Could not convert', conversionResult.reason);
}
else {
console.log('The collection object is: ', conversionResult.output[0].data);
}
}
); Validate FunctionThe validate function is meant to ensure that the data that is being passed to the convert function is a valid RAML 1.0 Spec. The validate function is synchronous and returns a status object which conforms to the following schema Validation object schema{
type: 'object',
properties: {
result: { type: 'boolean'},
reason: { type: 'string' }
},
required: ['result']
} Validation object explanation
|
PR to update Readme here includes example and detailed usage. So closing this fo now. |
Is there an example of how we can use this. We have a raml folder (with #%RAML 1.0).
How can we this code to convert those to postman collection?
The text was updated successfully, but these errors were encountered: