Skip to content

Commit

Permalink
Removed %20's, fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
onionhammer committed Aug 26, 2019
1 parent 148d0da commit 0f2b462
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions lib/definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ internals.append = function(definitionName, definition, currentCollection, force
// else create a new item using definitionName or next model number
if (forceDynamicName) {
if (settings.definitionPrefix === 'useLabel') {
out = internals.nextModelName(definitionName + ' ', currentCollection);
out = internals.nextModelName(definitionName, currentCollection);
} else {
out = internals.nextModelName('Model ', currentCollection);
out = internals.nextModelName('Model', currentCollection);
}
} else {
out = definitionName || internals.nextModelName('Model ', currentCollection);
out = definitionName || internals.nextModelName('Model', currentCollection);
}
currentCollection[out] = definition;
}
Expand Down
6 changes: 3 additions & 3 deletions test/Integration/alternatives-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ lab.experiment('alternatives', () => {
required: ['name']
});

expect(response.result.definitions['Model 1']).to.equal({
expect(response.result.definitions['Model1']).to.equal({
type: 'object',
properties: {
type: {
Expand Down Expand Up @@ -288,7 +288,7 @@ lab.experiment('alternatives', () => {
in: 'body',
name: 'body',
schema: {
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
}
}
]);
Expand All @@ -314,7 +314,7 @@ lab.experiment('alternatives', () => {
},
type: 'object'
},
'Model 1': {
'Model1': {
properties: {
type: {
type: 'string',
Expand Down
8 changes: 4 additions & 4 deletions test/Integration/builder-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ lab.experiment('builder', () => {
type: 'string'
}
},
'Model 1': {
'Model1': {
type: 'object',
properties: {
number: {
Expand Down Expand Up @@ -144,7 +144,7 @@ lab.experiment('builder', () => {
type: 'string'
}
},
'Model 1': {
'Model1': {
type: 'object',
properties: {
number: {
Expand Down Expand Up @@ -183,7 +183,7 @@ lab.experiment('builder', () => {
}
}
},
'Model 1': {
'Model1': {
type: 'object',
properties: {
a: {
Expand Down Expand Up @@ -222,7 +222,7 @@ lab.experiment('builder', () => {
}
}
},
'Model 1': {
'Model1': {
type: 'object',
properties: {
a: {
Expand Down
4 changes: 2 additions & 2 deletions test/Integration/child-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ lab.experiment('child-models', () => {
expect(response.statusCode).to.equal(200);

expect(response.result.paths['/foo/v1/bar'].post.parameters[0].schema).to.equal({
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
});

expect(response.result.definitions['Model 1']).to.equal({
expect(response.result.definitions['Model1']).to.equal({
properties: {
outer1: {
$ref: '#/definitions/outer1'
Expand Down
10 changes: 5 additions & 5 deletions test/Integration/definitions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ lab.experiment('definitions', () => {
b: Joi.object({
c: Joi.string()
})
}).label('Model 1')
}).label('Model1')
}
}
}
Expand Down Expand Up @@ -102,9 +102,9 @@ lab.experiment('definitions', () => {

expect(response.statusCode).to.equal(200);
expect(response.result.paths['/test/'].post.parameters[0].schema).to.equal({
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
});
expect(response.result.definitions['Model 1']).to.equal(definition);
expect(response.result.definitions['Model1']).to.equal(definition);
const isValid = await Validate.test(response.result);
expect(isValid).to.be.true();
});
Expand All @@ -116,7 +116,7 @@ lab.experiment('definitions', () => {
//console.log(JSON.stringify(response.result.definitions));
expect(response.result.definitions.b).to.exists();
expect(response.result.definitions.Model).to.exists();
expect(response.result.definitions['Model 1']).to.exists();
expect(response.result.definitions['Model1']).to.exists();

const isValid = await Validate.test(response.result);
expect(isValid).to.be.true();
Expand Down Expand Up @@ -233,7 +233,7 @@ lab.experiment('definitions', () => {
expect(response.statusCode).to.equal(200);
expect(response.result.definitions.A).to.exist();
expect(response.result.definitions['A A']).to.exist();
expect(response.result.definitions['A 1']).to.exist();
expect(response.result.definitions['A1']).to.exist();
const isValid = await Validate.test(response.result);
expect(isValid).to.be.true();
});
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/path-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ lab.experiment('path', () => {
in: 'body',
name: 'body',
schema: {
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
}
}
]);
Expand Down
2 changes: 1 addition & 1 deletion test/Integration/plugin-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ lab.experiment('plugin', () => {
const response = await server.inject({ method: 'GET', url: '/swagger.json' });
//console.log(JSON.stringify(response.result));
expect(response.result.definitions).to.equal({
'Model 1': {
'Model1': {
type: 'object',
properties: {
a: {
Expand Down
4 changes: 2 additions & 2 deletions test/Integration/proxy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ lab.experiment('proxies', () => {
in: 'body',
name: 'body',
schema: {
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
}
}
]);
Expand Down Expand Up @@ -387,7 +387,7 @@ lab.experiment('proxies', () => {
required: ['a'],
type: 'object'
},
'Model 1': {
'Model1': {
properties: {
b: {
type: 'string',
Expand Down
14 changes: 7 additions & 7 deletions test/Integration/responses-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,18 +530,18 @@ lab.experiment('responses', () => {

const server = await Helper.createServer({}, routes);
const response = await server.inject({ url: '/swagger.json' });
expect(response.result.definitions['Model 1']).to.exist();
expect(response.result.definitions['Model 2']).to.exist();
expect(response.result.definitions['Model1']).to.exist();
expect(response.result.definitions['Model2']).to.exist();
expect(response.result.definitions).to.equal({
'Model 1': {
'Model1': {
type: 'object',
properties: {
value2222: {
type: 'boolean'
}
}
},
'Model 2': {
'Model2': {
type: 'object',
properties: {
value1111: {
Expand Down Expand Up @@ -873,19 +873,19 @@ lab.experiment('responses', () => {
},
'400': {
schema: {
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
},
description: '400 - Added from plugin-options'
},
'404': {
description: '404 from response status object',
schema: {
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
}
},
'429': {
schema: {
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
},
description: 'Too Many Requests'
},
Expand Down
2 changes: 1 addition & 1 deletion test/unit/property-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ lab.experiment('property - ', () => {
format: 'binary'
});
expect(propertiesNoAlt.parseProperty('x', Joi.array(), null, 'body', true, false)).to.equal({
$ref: '#/definitions/Model%201'
$ref: '#/definitions/Model1'
});
expect(propertiesNoAlt.parseProperty('x', Joi.any(), null, 'body', true, false)).to.equal({ type: 'string' });
//expect(propertiesNoAlt.parseProperty('x', Joi.func(), null, 'body', true, false)).to.equal({ 'type': 'string' });
Expand Down
4 changes: 2 additions & 2 deletions test/unit/validate-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const swaggerJSON = {
in: 'body',
name: 'body',
schema: {
$ref: '#/definitions/Model 1'
$ref: '#/definitions/Model1'
}
}
],
Expand All @@ -40,7 +40,7 @@ const swaggerJSON = {
}
},
definitions: {
'Model 1': {
'Model1': {
type: 'object',
properties: {
a: {
Expand Down

0 comments on commit 0f2b462

Please sign in to comment.