Skip to content

Describe model schema in generated $resource #223

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

Merged
merged 1 commit into from
Jun 2, 2016

Conversation

bajtos
Copy link
Member

@bajtos bajtos commented May 30, 2016

  • 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

* @description
* The schema of the model represented by this $resource
*/
R.schema = <%- JSON.stringify(meta.modelSchema, null, 2) -%>;
Copy link
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
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
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
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
Copy link
Contributor

davidcheung commented May 31, 2016

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
Contributor

@bajtos other than comments above LGTM

@davidcheung davidcheung assigned bajtos and unassigned davidcheung May 31, 2016
@bajtos
Copy link
Member Author

bajtos commented Jun 1, 2016

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
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