Skip to content

Commit 8156f9d

Browse files
committed
fix: add model/entity descriptions
1 parent ad0229b commit 8156f9d

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

docs/site/Model-generator.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ The tool will prompt you for:
4141
been supplied with a valid model class name, the prompt is skipped. It will
4242
present you with a list of available models from `src/models` including the
4343
**Entity** and **Model** at the top of the list.
44+
- An **Entity** is a persisted model with an identity (ID).
45+
- A **Model** is a business domain object.
46+
- For more information, see
47+
[here](https://loopback.io/doc/en/lb4/Model.html#overview).
4448

4549
The tool will next recursively prompt you for the model's properties until a
4650
blank one is entered. Properties will be prompted for as follows:

docs/site/OpenAPI-generator.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,10 @@ export class AccountController {
234234

235235
Try out the following specs or your own with `lb4 openapi`:
236236

237-
- https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml
238-
- https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/uspto.yaml
239-
- https://api.apis.guru/v2/specs/api2cart.com/1.0.0/swagger.json
240-
- https://api.apis.guru/v2/specs/amazonaws.com/codecommit/2015-04-13/swagger.json
237+
- [Swagger Petstore API](https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore-expanded.yaml)
238+
- [USPTO Data Set API](https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/uspto.yaml)
239+
- [Swagger API2Cart](https://api.apis.guru/v2/specs/api2cart.com/1.0.0/swagger.json)
240+
- [AWS CodeCommit API](https://api.apis.guru/v2/specs/amazonaws.com/codecommit/2015-04-13/swagger.json)
241241

242-
For more real world OpenAPI specs, see https://api.apis.guru/v2/list.json.
242+
For more real world OpenAPI specs, see
243+
[https://api.apis.guru/v2/list.json](https://api.apis.guru/v2/list.json).

packages/cli/generators/model/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ const path = require('path');
1414

1515
const PROMPT_BASE_MODEL_CLASS = 'Please select the model base class';
1616
const ERROR_NO_MODELS_FOUND = 'Model was not found in';
17-
const BASE_MODELS = [
18-
'Entity',
19-
'Model',
17+
const BASE_MODELS = ['Entity', 'Model'];
18+
const CLI_BASE_MODELS = [
19+
{
20+
name: `Entity ${chalk.gray('(A persisted model with an ID)')}`,
21+
value: 'Entity',
22+
},
23+
{name: `Model ${chalk.gray('(A business domain object)')}`, value: 'Model'},
2024
{type: 'separator', line: '----- Custom Models -----'},
2125
];
2226
const MODEL_TEMPLATE_PATH = 'model.ts.ejs';
@@ -99,7 +103,7 @@ module.exports = class ModelGenerator extends ArtifactGenerator {
99103
if (this.shouldExit()) return;
100104
const availableModelBaseClasses = [];
101105

102-
availableModelBaseClasses.push(...BASE_MODELS);
106+
availableModelBaseClasses.push(...CLI_BASE_MODELS);
103107

104108
try {
105109
debug(`model list dir ${this.artifactInfo.modelDir}`);
@@ -150,6 +154,9 @@ module.exports = class ModelGenerator extends ArtifactGenerator {
150154
},
151155
])
152156
.then(props => {
157+
if (typeof props.modelBaseClass === 'object')
158+
props.modelBaseClass = props.modelBaseClass.value;
159+
153160
Object.assign(this.artifactInfo, props);
154161
debug(`props after model base class prompt: ${inspect(props)}`);
155162
this.log(

0 commit comments

Comments
 (0)