add example of using examples in swagger 2.0

add example of using examples in swagger 2.0
This commit is contained in:
Luis Tejeda
2022-06-02 13:10:34 -05:00
parent 21190fa50b
commit d2e2be3c06
7 changed files with 191 additions and 3 deletions

View File

@@ -40,7 +40,8 @@ let expect = require('chai').expect,
'/bringLocalDependenciesFromExternalMultiple'),
multipleRefFromRootComponents = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/multipleRefFromRootComponents'),
sameRefDifferentSource = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/sameRefDifferentSource'),
simpleRef = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/simpleRef');
simpleRef = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/simpleRef'),
refExample20 = path.join(__dirname, SWAGGER_MULTIFILE_FOLDER + '/referenced_example');
describe('bundle files method - 3.0', function () {
it('Should return bundled file as json - schema_from_response', async function () {
@@ -1335,6 +1336,34 @@ describe('bundle files method - 2.0', function() {
expect(res.result).to.be.true;
expect(res.output.data.bundledContent).to.be.equal(expected);
});
it('Should return bundled file with referenced example', async function () {
let contentRootFile = fs.readFileSync(refExample20 + '/root.yaml', 'utf8'),
examples = fs.readFileSync(refExample20 + '/examples.yaml', 'utf8'),
expected = fs.readFileSync(refExample20 + '/expected.json', 'utf8'),
input = {
type: 'folder',
specificationVersion: '2.0',
rootFiles: [
{
path: '/root.yaml',
content: contentRootFile
}
],
data: [
{
path: '/examples.yaml',
content: examples
}
],
options: {},
bundleFormat: 'JSON'
};
const res = await Converter.bundle(input);
expect(res).to.not.be.empty;
expect(res.result).to.be.true;
expect(res.output.data.bundledContent).to.be.equal(expected);
});
});
describe('getReferences method when node does not have any reference', function() {