Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ results

npm-debug.log
node_modules

intl/*
!intl/en/
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

// Globalization
var SG = require('strong-globalize');
SG.SetRootDir(__dirname);
var g = SG();

var V2Generator = require('./lib/codegen/generator-v2');
var V12Generator = require('./lib/codegen/generator-v1.2');
var generateModels = require('./lib/codegen/json-schema');
Expand All @@ -15,7 +20,7 @@ function getGenerator(spec) {
} else if (spec && spec.swaggerVersion === '1.2') {
generator = new V12Generator();
} else {
throw new Error('Swagger spec version is not supported');
throw new Error(g.f('{{Swagger spec}} version is not supported'));
}
return generator;
}
Expand Down Expand Up @@ -60,7 +65,7 @@ exports.generateModels = function(spec, options) {
} else if (spec && spec.swaggerVersion === '1.2') {
models = spec.models;
} else {
throw new Error('Swagger spec version is not supported');
throw new Error(g.f('{{Swagger spec}} version is not supported'));
}
return generateModels(models, options || {});
};
Expand Down
7 changes: 7 additions & 0 deletions intl/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"47a65938fb7d8999530eb834c7f88bfe": "{{Swagger spec}} version is not supported",
"f56715842719b19ea94d85dd1f024684": "Warning: detected multiple remote methods at the same HTTP endpoint. {{Swagger operation ids}} will NOT be unique.",
"887507f75b7a4051e4c604f1f187d7be": "Warning: unknown LDL type {0}, using \"{{any}}\" instead",
"ea289bffae13f78fad7794b62395008d": "Route exists with no class: {0}",
"8695812bf6bbddb8096a6084b3214375": "{{Swagger}}: skipping unknown type {0}."
}
9 changes: 6 additions & 3 deletions lib/specgen/route-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

'use strict';

// Globalization
var g = require('strong-globalize')();

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -321,9 +324,9 @@ function createUniqueOperationId(methodName, verb, path, operationIdRegistry) {
var baseId = id;
id = createLongOperationId(baseId, verb, path);
if (id in operationIdRegistry) {
console.warn('Warning: detected multiple remote methods ' +
'at the same HTTP endpoint. ' +
'Swagger operation ids will be NOT unique.');
g.warn('Warning: detected multiple remote methods ' +
'at the same HTTP endpoint. ' +
'{{Swagger operation ids}} will NOT be unique.');
}

// Rename the first operation so that all operation ids of
Expand Down
6 changes: 5 additions & 1 deletion lib/specgen/schema-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

'use strict';

// Globalization
var g = require('strong-globalize')();

var assert = require('assert');
var typeConverter = require('./type-converter');

Expand Down Expand Up @@ -140,7 +143,8 @@ exports.getLdlTypeName = function(ldlType) {
return 'any';
}

console.error('Warning: unknown LDL type %j, using "any" instead', ldlType);
var msg = g.f('Warning: unknown LDL type %j, using "{{any}}" instead', ldlType);
console.error(msg);
return 'any';
};

Expand Down
5 changes: 4 additions & 1 deletion lib/specgen/swagger-spec-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

'use strict';

// Globalization
var g = require('strong-globalize')();

/**
* Module dependencies.
*/
Expand Down Expand Up @@ -85,7 +88,7 @@ module.exports = function createSwaggerObject(loopbackApplication, opts) {
})[0];

if (!classDef) {
console.error('Route exists with no class: %j', route);
g.error('Route exists with no class: %j', route);
return;
}

Expand Down
5 changes: 4 additions & 1 deletion lib/specgen/type-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

'use strict';

// Globalization
var g = require('strong-globalize')();

var _ = require('lodash');

module.exports = TypeRegistry;
Expand Down Expand Up @@ -74,7 +77,7 @@ TypeRegistry.prototype.getDefinitions = function() {
for (var ref in this._referenced) {
if (ref in defs) continue;
// https://github.com/strongloop/loopback-explorer/issues/71
console.warn('Swagger: skipping unknown type %j.', ref);
g.warn('{{Swagger}}: skipping unknown type %j.', ref);
}

return defs;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"debug": "^2.2.0",
"ejs": "^1.0.0",
"lodash": "^3.10.1",
"strong-globalize": "^2.6.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^2.6.2 but its a nitpick

Copy link
Contributor

@superkhau superkhau Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now ^2.6.6, but a nit since ^ picks it up anyways during install.

"underscore.string": "~2.3.3"
}
}