Skip to content

added '-s' flag to pass the includeSchema option to loopback-sdk-angular - #43

Closed
janhapke wants to merge 2 commits into
strongloop:masterfrom
janhapke:feature/include-schema
Closed

janhapke wants to merge 2 commits into
strongloop:masterfrom
janhapke:feature/include-schema

Conversation

@janhapke

@janhapke janhapke commented Jul 5, 2016

Copy link
Copy Markdown
Contributor

I noticed that an option 'includeSchema' was recently added to loopback-sdk-angular and I needed this feature in lb-ng. I added a new flag '-s' that passes this option.

However, I had some issues while implementing this:

  • I needed to require master version of loopback-sdk-angular: package.json
  • I didn't know how to properly 'inject' models into loopback for testing purposes, so I hacked something together that works but doesn't feel right: test/fixtures/app.js

I still hope the pull request is useful and maybe somebody can point out a solution for the proper way to inject testing models.

@slnode

slnode commented Jul 5, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch? To accept patch and trigger a build add comment ".ok\W+to\W+test."

@davidcheung

Copy link
Copy Markdown
Contributor

@janhapke Thanks for your contribution!

yes we havent published the option to npm yet :(, for dev purposes, you can use npm link, what it does is it creates a symlink(shortcut) to your master branch

I needed to require master version of loopback-sdk-angular: package.json


as for creating the model, perhaps you could try something like https://github.com/strongloop/loopback-sdk-angular-cli/blob/master/test/fixtures/async-app/boot/boot.js

I didn't know how to properly 'inject' models into loopback for testing purposes, so I hacked something together that works but doesn't feel right

cc/ @bajtos

@slnode

slnode commented Jul 13, 2016

Copy link
Copy Markdown

Can one of the admins verify this patch?

@davidcheung

Copy link
Copy Markdown
Contributor

@slnode ok to test

Comment thread bin/lb-ng Outdated

console.error('Generating %j for the API endpoint %j', ngModuleName, apiUrl);
var result = generator.services(app, ngModuleName, apiUrl);
var result = generator.services(app, {ngModuleName: ngModuleName, apiUrl: apiUrl, includeSchema: includeSchema});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

please split the options argument on multiple lines:

generator.services(app, {
  // ...
});

@davidcheung

Copy link
Copy Markdown
Contributor

this will also close duplicate PR #34

@janhapke

Copy link
Copy Markdown
Contributor Author

@bajtos thank you for your feedback, I have implemented your suggestions.

However the created models are still not properly returned by the rest handlers get classes method (which is used to generate the schema), so I left a portion of the hack in the test fixture.
I still cannot figure out what is going wrong there. Adding public: true, as suggested by @davidcheung didn't solve it either.

@bajtos

bajtos commented Jul 15, 2016

Copy link
Copy Markdown
Member

@janhapke what Node version are you using? I found that when running on Node v6, the output of lb-ng gets trimmed. The TestModel is included, but R.schema is in the part that's trimmed. When running on Node v0.10, everything works fine.

You can check this by running the following command:

$ DEBUG=*,-mocha* mocha -g schema

Here is my test/fixtures/app.js that works correctly (on Node v0.10):

// Copyright IBM Corp. 2014,2015. All Rights Reserved.
// Node module: loopback-sdk-angular-cli
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var loopback = require('loopback');
var app = loopback();

app.set('restApiRoot', '/rest-api-root');

app.dataSource('db', { connector: 'memory' });
var TestModel = app.registry.createModel(
    'TestModel',
    { foobaz: 'string' }
);
app.model(TestModel, { dataSource: 'db' });

module.exports = app;

@bajtos

bajtos commented Jul 15, 2016

Copy link
Copy Markdown
Member

I asked @davidcheung to look into this problem. We should fix it in a standalone pull request out of scope of your work here, @janhapke.

@davidcheung

davidcheung commented Jul 18, 2016 •

Copy link
Copy Markdown
Contributor

Loosely related #45

@bajtos bajtos added the feature label Sep 6, 2016
@bajtos

bajtos commented Sep 6, 2016

Copy link
Copy Markdown
Member

Now that #45 fixed the problem of trimmed CLI output, I think it's time to resume work on this patch.

@janhapke could you please rebase your patch on top of the latest master and fix the fixture app per my #43 (comment)?

@bajtos

bajtos commented Oct 6, 2016

Copy link
Copy Markdown
Member

Closing in favour of #55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants