Skip to content

Describe model schema in generated $resource - #223

Merged
bajtos merged 1 commit into
masterfrom
feature/include-schema
Jun 2, 2016
Merged

bajtos merged 1 commit into
masterfrom
feature/include-schema

Conversation

@bajtos

@bajtos bajtos commented May 30, 2016

Copy link
Copy Markdown
Member
  • Add a new option to include model schema in generated $resources.
  • Add a new API flavour generateServices(app, options) to tame overgrowing number of arguments.

This patch supersedes #194.

/to @davidcheung please review
/cc @akera-io

Comment thread lib/services.template.ejs
* @description
* The schema of the model represented by this $resource
*/
R.schema = <%- JSON.stringify(meta.modelSchema, null, 2) -%>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would it be better to use <%-: meta.modelSchema | q %>?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good catch, will apply your proposal.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually, on the second thought, I think it's better to explicitly call JSON.stringify here. The intention of the q filter is to produce a quoted string. The fact that it calls JSON.stringify under the hood is an implementation detail that we should not rely on, as it may change in the future (in theory).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

agreed, make sense

@davidcheung

davidcheung commented May 31, 2016 •

Copy link
Copy Markdown
Contributor

Please note that this should be landed with strongloop/loopback-sdk-angular-cli#34 using options since angular-sdk-cli isnt using options yet

module.exports = function generateServices(app, options) {

https://github.com/akera-io/loopback-sdk-angular-cli/blob/a5979f765710e4b96b46922d61da1f0c716fcbad/bin/lb-ng#L33


placeholder for link to documentation once landed
https://docs.strongloop.com/display/public/LB/AngularJS+JavaScript+SDK#AngularJSJavaScriptSDK-lb-ngcommand

@davidcheung

Copy link
Copy Markdown
Contributor

@bajtos other than comments above LGTM

@davidcheung davidcheung assigned bajtos and unassigned davidcheung May 31, 2016
@bajtos

bajtos commented Jun 1, 2016

Copy link
Copy Markdown
Member Author

Please note that this should be landed with strongloop/loopback-sdk-angular-cli#34 using options since angular-sdk-cli isnt using options yet

I was careful to preserve support for old API generateServices(app, ngModuleName, apiUrl), to allow dependants like loopback-sdk-angular-cli to update later as time permits. See

if (typeof options === 'string') {
// legacy API: generateServices(app, ngModuleName, apiUrl)
options = {
ngModuleName: arguments[1],
apiUrl: arguments[2],
};
}

@davidcheung

Copy link
Copy Markdown
Contributor

right, all the tests are passing too
@bajtos LGTM 👍

I was careful to preserve support for old API generateServices(app, ngModuleName, apiUrl), to allow dependants like loopback-sdk-angular-cli to update later as time permits.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants