Skip to content

Commit e8f9c14

Browse files
committed
scenario
1 parent 9f78464 commit e8f9c14

File tree

5 files changed

+91
-1
lines changed

5 files changed

+91
-1
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
openapi: "3.0.0"
2+
info:
3+
version: 1.0.10
4+
title: Some Platform API
5+
description: API definition between UI and backend
6+
termsOfService: http://swagger.io/terms/
7+
8+
servers:
9+
- url: http://petstore.swagger.io/
10+
11+
components:
12+
securitySchemes:
13+
AuthorizationToken:
14+
type: apiKey
15+
in: header
16+
name: X-API-Key
17+
18+
parameters:
19+
path.Id:
20+
$ref: './parameters/path/Id.yaml'
21+
query.ConversionFlows:
22+
$ref: './parameters/query/qparam.yaml'
23+
24+
25+
schemas:
26+
ConversionFlow:
27+
$ref: './schemas/properties/def.yaml'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: id
2+
in: path
3+
description: object identifier
4+
required: true
5+
schema:
6+
type: integer
7+
format: int64
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name: conversion_flows
2+
in: query
3+
description: Enum for Offers's conversion flow
4+
schema:
5+
type: array
6+
items:
7+
$ref: '../../api.yaml#/components/schemas/def'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: string
2+
enum: [ sale, free_trial, cc_submit, cash_on_delivery, 1_click, 2_click, pin_submit, click_2_sms, mo_flow, click_2_call, ussd, otp, single_opt_in, double_opt_in, install, engagement, other ]
3+
x-validate:
4+
go: 'required'
5+
x-enum:
6+
go: enum

test/unit/bundle.test.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ let expect = require('chai').expect,
4949
exampleValue = path.join(__dirname, BUNDLES_FOLDER + '/example_value'),
5050
example2 = path.join(__dirname, BUNDLES_FOLDER + '/example2'),
5151
schemaCircularRef = path.join(__dirname, BUNDLES_FOLDER + '/circular_reference'),
52-
schemaCircularRefInline = path.join(__dirname, BUNDLES_FOLDER + '/circular_reference_inline');
52+
schemaCircularRefInline = path.join(__dirname, BUNDLES_FOLDER + '/circular_reference_inline'),
53+
issue = path.join(__dirname, BUNDLES_FOLDER + '/issue');
5354

5455
describe('bundle files method - 3.0', function () {
5556
it('Should return bundled file as json - schema_from_response', async function () {
@@ -2679,6 +2680,48 @@ describe('bundle files method - 3.0', function () {
26792680
expect(res.output.specification.version).to.equal('3.0');
26802681
expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected);
26812682
});
2683+
2684+
it('Should resolve ', async function () {
2685+
let contentRootFile = fs.readFileSync(issue + '/api.yaml', 'utf8'),
2686+
parameterIdContent = fs.readFileSync(issue + '/parameters/path/Id.yaml', 'utf8'),
2687+
parameterCFContent = fs.readFileSync(issue + '/parameters/query/qparam.yaml', 'utf8'),
2688+
schemaCFContent = fs.readFileSync(issue + '/schemas/properties/def.yaml', 'utf8'),
2689+
// expected = fs.readFileSync(schemaCircularRefInline + '/expected.json', 'utf8'),
2690+
input = {
2691+
type: 'multiFile',
2692+
specificationVersion: '3.0',
2693+
rootFiles: [
2694+
{
2695+
path: '/api.yaml'
2696+
}
2697+
],
2698+
data: [
2699+
{
2700+
path: '/api.yaml',
2701+
content: contentRootFile
2702+
},
2703+
{
2704+
path: '/parameters/path/Id.yaml',
2705+
content: parameterIdContent
2706+
},
2707+
{
2708+
path: '/parameters/query/qparam.yaml',
2709+
content: parameterCFContent
2710+
},
2711+
{
2712+
path: '/schemas/properties/def.yaml',
2713+
content: schemaCFContent
2714+
}
2715+
],
2716+
options: {},
2717+
bundleFormat: 'JSON'
2718+
};
2719+
const res = await Converter.bundle(input);
2720+
expect(res).to.not.be.empty;
2721+
expect(res.result).to.be.true;
2722+
expect(res.output.specification.version).to.equal('3.0');
2723+
// expect(JSON.stringify(JSON.parse(res.output.data[0].bundledContent), null, 2)).to.be.equal(expected);
2724+
});
26822725
});
26832726

26842727
describe('getReferences method when node does not have any reference', function() {

0 commit comments

Comments
 (0)