-
Notifications
You must be signed in to change notification settings - Fork 99
Expose new models created after the explorer is initiated #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,7 +100,7 @@ describe('swagger definition', function() { | |
| var app = givenAppWithSwagger(); | ||
|
|
||
| var getReq = getAPIDeclaration(app, 'products'); | ||
| getReq.end(function(err, res) { | ||
| getReq.end(function (err, res) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: we use |
||
| if (err) return done(err); | ||
| var data = res.body.models.product; | ||
| expect(data.id).to.equal('product'); | ||
|
|
@@ -326,6 +326,27 @@ describe('swagger definition', function() { | |
| }); | ||
| }); | ||
|
|
||
| describe('Allow model remoting after initiation', function () { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: we use |
||
| it('should be able to access models remoted after initiation', function (done) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: we use |
||
| var app = givenAppWithSwagger(); | ||
|
|
||
| var Catalog = loopback.PersistedModel.extend('catalog', { | ||
| name: {type: 'string', required: true} | ||
| }); | ||
| Catalog.attachTo(loopback.memory()); | ||
| app.model(Catalog); | ||
|
|
||
| var getReq = getAPIDeclaration(app, 'catalogs'); | ||
|
|
||
| getReq.end(function (err, res) { | ||
| if (err) return done(err); | ||
| var data = res.body.models.catalog; | ||
| expect(data.id).to.equal('catalog'); | ||
| done(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| function getSwaggerResources(app, restPath, classPath) { | ||
| return request(app) | ||
| .get(urlJoin(restPath || '/explorer', '/resources', classPath || '')) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it should be easy to filter routes for a given class only - see the code in
addRouteToAPISpecwhich is looking up the class name and shared class using the route metadata.Once we have a function "return the sub-array of routes that are for the given class", this hack will be no longer necessary.