Merge pull request #547 from postmanlabs/feature/allOfAndAdditionalProperties30

Adding tests
This commit is contained in:
Luis Tejeda
2022-06-14 09:45:10 -05:00
committed by GitHub
5 changed files with 153 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
type:
object
properties:
color:
type: string
weight:
type: integer
height:
type: integer

View File

@@ -0,0 +1,71 @@
{
"openapi": "3.0",
"info": {
"title": "Sample API",
"description": "API description in Markdown.",
"version": "1.0.0"
},
"host": "api.example.com",
"basePath": "/v1",
"schemes": [
"https"
],
"paths": {
"/pets": {
"get": {
"description": "Returns all pets from the system that the user has access to,",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "A list of pets.,",
"schema": {
"$ref": "#/components/schemas/_pet.yaml"
}
}
}
}
}
},
"components": {
"schemas": {
"_pet.yaml": {
"type": "object",
"required": [
"id",
"name"
],
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"tag": {
"type": "string"
},
"additionalProperties": {
"$ref": "#/components/schemas/_additionalProperties.yaml"
}
}
},
"_additionalProperties.yaml": {
"type": "object",
"properties": {
"color": {
"type": "string"
},
"weight": {
"type": "integer"
},
"height": {
"type": "integer"
}
}
}
}
}
}

View File

@@ -0,0 +1,14 @@
type: object
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
additionalProperties:
$ref: "./additionalProperties.yaml"

View File

@@ -0,0 +1,20 @@
openapi: "3.0"
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
host: api.example.com
basePath: /v1
schemes:
- https
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to,
produces:
- application/json
responses:
200:
description: A list of pets.,
schema:
$ref: "./pet.yaml"

View File

@@ -33,7 +33,8 @@ let expect = require('chai').expect,
referencedHeader = path.join(__dirname, BUNDLES_FOLDER + '/referenced_header'),
referencedLink = path.join(__dirname, BUNDLES_FOLDER + '/referenced_link'),
referencedCallback = path.join(__dirname, BUNDLES_FOLDER + '/referenced_callback'),
referencedSecuritySchemes = path.join(__dirname, BUNDLES_FOLDER + '/referenced_security_schemes');
referencedSecuritySchemes = path.join(__dirname, BUNDLES_FOLDER + '/referenced_security_schemes'),
additionalProperties = path.join(__dirname, BUNDLES_FOLDER + '/additionalProperties');
describe('bundle files method - 3.0', function () {
@@ -1751,6 +1752,43 @@ describe('bundle files method - 3.0', function () {
expect(res.result).to.be.true;
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
});
it('Should bundle file from - additionalProperties', async function() {
let contentRoot = fs.readFileSync(additionalProperties + '/root.yaml', 'utf8'),
pet = fs.readFileSync(additionalProperties + '/pet.yaml', 'utf8'),
additionalProps = fs.readFileSync(additionalProperties + '/additionalProperties.yaml', 'utf8'),
expected = fs.readFileSync(additionalProperties + '/expected.json', 'utf8'),
input = {
type: 'multiFile',
specificationVersion: '3.0',
rootFiles: [
{
path: '/root.yaml'
}
],
data: [
{
path: '/root.yaml',
content: contentRoot
},
{
path: '/pet.yaml',
content: pet
},
{
path: '/additionalProperties.yaml',
content: additionalProps
}
],
options: {},
bundleFormat: 'JSON'
};
const res = await Converter.bundle(input);
expect(res).to.not.be.empty;
expect(res.result).to.be.true;
expect(JSON.stringify(res.output.data[0].bundledContent, null, 2)).to.be.equal(expected);
});
});