Swagger: skipping unknown type "$new_AccessToken".
Description/Steps to reproduce
Fresh install loopback, then run node .
Expected result
No error
Result
Swagger: skipping unknown type "$new_AccessToken".
Web server listening at: http://localhost:3000
Browse your REST API at http://localhost:3000/explorer
Additional information
Version: loopback 3.11.1 loopback-swagger 4.3.0 loopback-explorer 2.0.2
win32 x64 6.11.3
Same here.
I tested with some versions and problem only appears in loopback >= 3.14.0
i'm back at 3.13.0 as temporary solution
Not sure if its relevant to everyones situation, however i ran into this issue when running with docker. I had a docker-compose file that was running the container. In the docker-compose file I was running the container with user "Node". Removing this user and using the default user made the issue go away.
Still present in 3.16.0... @bajtos - I would like to fix it, but I can't find any reference of where and what is this causing...
not impressed by the non feedback on this...
I’ll take a look today.
From what I remember about our swagger spec generator, we are intentionally omitting type definitions that are not used by any publicly exposed methods, to prevent the swagger spec to be polluted with built-in models like Role and ACL that are known to LoopBack runtime, but that are not relevant for the REST API.
I suspect the code detecting relations (and deciding which models to include) does not know that $new_AccessToken definition is a part of AccessToken model. I may be wrong though, I'll leave it up to you @raymondfeng to investigate more.
Thank you guys!
works for me. Thank you @raymondfeng @bajtos
I am still reproducing this error with dynamically created models on boot time.
PACKAGE: { "compression": "^1.0.3", "cors": "^2.5.2", "helmet": "^1.3.0", "loopback": "^3.17.0", "loopback-boot": "^3.1.0", "loopback-swagger" : "^5.5.0", "loopback-component-explorer": "^5.2.0", "serve-favicon": "^2.0.1", "strong-error-handler": "^2.0.0" }
CODE:
'use strict';
var loopback = require('loopback');
var boot = require('loopback-boot');
var app = module.exports = loopback({localRegistry: true});
var ds = loopback.createDataSource('postgresql', {
"host": "localhost",
"port": 5432,
"database": "db",
"username": "user",
"password": "pass"
});
var acceptedTables = [
'users',
'organisation',
'expectation',
'location',
'tags',
'telephone',
'email',
'experience',
'project',
'skill',
'education',
'language',
'activity',
'hobby',
'social',
'link',
'document',
'user_organisation',
'users_data',
'document_permissions',
'tag_relations'
]
var modelDefinitionsConf = {views: true};
var modelConfig = { schema: 'public' };
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function generateModelName(modelName){
var nameArr = modelName.split(/_|-/);
var nameArr = nameArr.map(function(el){ return el[0].toUpperCase() + el.substr(1); });
return nameArr.join('');
}
app.start = function() {
return app.listen(function() {
app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, '');
ds.discoverModelDefinitions(modelDefinitionsConf, function(err, data){
for (var el in data) {
(function(modelName){
if (acceptedTables.indexOf(modelName) >= 0) {
ds.discoverSchema(modelName, function (err, schema) {
var model = ds.createModel(schema.name, schema.properties, schema.options);
app.model(model, {public : true, dataSource: ds });
})
}
})(data[el].name)
}
});
if (app.get('loopback-component-explorer')) {
var explorerPath = app.get('loopback-component-explorer').mountPath;
console.log('Browse your REST API at %s%s', baseUrl, explorerPath);
}
});
};
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) {
if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module)
app.start();
});
@twboc could you please open a new issue for the problem you are experiencing and be more specific about the kind of error you are seeing? This issue is specifically about $new_AccessToken, which is not part of your discovered/auto-imported models AFAICT.
I am closing this issue as fixed.