@loopback/repository-json-schema 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,42 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.12.0](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.11.4...@loopback/repository-json-schema@1.12.0) (2020-01-27)
7
+
8
+
9
+ ### Features
10
+
11
+ * **repository-json-schema:** add filter title ([2d65971](https://github.com/strongloop/loopback-next/commit/2d6597133885c16c132221cef80893093fa3d289))
12
+ * **repository-json-schema:** add title to filter schemas ([6105883](https://github.com/strongloop/loopback-next/commit/6105883967ca5853cc8990f423d9febd1eb07101))
13
+
14
+
15
+
16
+
17
+
18
+ ## [1.11.4](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.11.3...@loopback/repository-json-schema@1.11.4) (2020-01-07)
19
+
20
+ **Note:** Version bump only for package @loopback/repository-json-schema
21
+
22
+
23
+
24
+
25
+
26
+ ## [1.11.3](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.11.2...@loopback/repository-json-schema@1.11.3) (2019-12-09)
27
+
28
+ **Note:** Version bump only for package @loopback/repository-json-schema
29
+
30
+
31
+
32
+
33
+
34
+ ## [1.11.2](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.11.1...@loopback/repository-json-schema@1.11.2) (2019-11-25)
35
+
36
+ **Note:** Version bump only for package @loopback/repository-json-schema
37
+
38
+
39
+
40
+
41
+
6
42
  ## [1.11.1](https://github.com/strongloop/loopback-next/compare/@loopback/repository-json-schema@1.11.0...@loopback/repository-json-schema@1.11.1) (2019-11-12)
7
43
 
8
44
  **Note:** Version bump only for package @loopback/repository-json-schema
@@ -3,17 +3,21 @@
3
3
  // Node module: @loopback/repository-json-schema
4
4
  // This file is licensed under the MIT License.
5
5
  // License text available at https://opensource.org/licenses/MIT
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
6
9
  Object.defineProperty(exports, "__esModule", { value: true });
7
10
  const context_1 = require("@loopback/context");
8
11
  const repository_1 = require("@loopback/repository");
9
- const debugFactory = require("debug");
12
+ const debug_1 = __importDefault(require("debug"));
10
13
  const util_1 = require("util");
11
14
  const keys_1 = require("./keys");
12
- const debug = debugFactory('loopback:repository-json-schema:build-schema');
15
+ const debug = debug_1.default('loopback:repository-json-schema:build-schema');
13
16
  /**
14
17
  * @internal
15
18
  */
16
19
  function buildModelCacheKey(options = {}) {
20
+ var _a;
17
21
  // Backwards compatibility: preserve cache key "modelOnly"
18
22
  if (Object.keys(options).length === 0) {
19
23
  return "modelOnly" /* ModelOnly */;
@@ -21,7 +25,7 @@ function buildModelCacheKey(options = {}) {
21
25
  // New key schema: use the same suffix as we use for schema title
22
26
  // For example: "modelPartialWithRelations"
23
27
  // Note this new key schema preserves the old key "modelWithRelations"
24
- return 'model' + (options.title || '') + getTitleSuffix(options);
28
+ return 'model' + (_a = options.title, (_a !== null && _a !== void 0 ? _a : '')) + getTitleSuffix(options);
25
29
  }
26
30
  exports.buildModelCacheKey = buildModelCacheKey;
27
31
  /**
@@ -30,11 +34,12 @@ exports.buildModelCacheKey = buildModelCacheKey;
30
34
  * @param ctor - Contructor of class to get JSON Schema from
31
35
  */
32
36
  function getJsonSchema(ctor, options) {
37
+ var _a;
33
38
  // In the near future the metadata will be an object with
34
39
  // different titles as keys
35
40
  const cached = context_1.MetadataInspector.getClassMetadata(keys_1.JSON_SCHEMA_KEY, ctor);
36
41
  const key = buildModelCacheKey(options);
37
- let schema = cached && cached[key];
42
+ let schema = (_a = cached) === null || _a === void 0 ? void 0 : _a[key];
38
43
  if (!schema) {
39
44
  // Create new json schema from model
40
45
  // if not found in cache for specific key
@@ -271,9 +276,10 @@ function getDescriptionSuffix(rawOptions = {}) {
271
276
  * @param ctor - Constructor of class to convert from
272
277
  */
273
278
  function modelToJsonSchema(ctor, jsonSchemaOptions = {}) {
279
+ var _a, _b, _c, _d, _e;
274
280
  const options = Object.assign({}, jsonSchemaOptions);
275
- options.visited = options.visited || {};
276
- options.optional = options.optional || [];
281
+ options.visited = (_a = options.visited, (_a !== null && _a !== void 0 ? _a : {}));
282
+ options.optional = (_b = options.optional, (_b !== null && _b !== void 0 ? _b : []));
277
283
  const partial = options.partial && !options.optional.length;
278
284
  if (options.partial && !partial) {
279
285
  debug('Overriding "partial" option with "optional" option');
@@ -307,7 +313,7 @@ function modelToJsonSchema(ctor, jsonSchemaOptions = {}) {
307
313
  if (!meta.properties[p].type) {
308
314
  continue;
309
315
  }
310
- result.properties = result.properties || {};
316
+ result.properties = (_c = result.properties, (_c !== null && _c !== void 0 ? _c : {}));
311
317
  result.properties[p] = result.properties[p] || {};
312
318
  const metaProperty = Object.assign({}, meta.properties[p]);
313
319
  // populating "properties" key
@@ -315,7 +321,7 @@ function modelToJsonSchema(ctor, jsonSchemaOptions = {}) {
315
321
  // handling 'required' metadata
316
322
  const optional = options.optional.includes(p);
317
323
  if (metaProperty.required && !(partial || optional)) {
318
- result.required = result.required || [];
324
+ result.required = (_d = result.required, (_d !== null && _d !== void 0 ? _d : []));
319
325
  result.required.push(p);
320
326
  }
321
327
  // populating JSON Schema 'definitions'
@@ -337,7 +343,7 @@ function modelToJsonSchema(ctor, jsonSchemaOptions = {}) {
337
343
  debug(' additionalProperties?', result.additionalProperties);
338
344
  if (options.includeRelations) {
339
345
  for (const r in meta.relations) {
340
- result.properties = result.properties || {};
346
+ result.properties = (_e = result.properties, (_e !== null && _e !== void 0 ? _e : {}));
341
347
  const relMeta = meta.relations[r];
342
348
  const targetType = repository_1.resolveType(relMeta.target);
343
349
  const targetSchema = getJsonSchema(targetType, options);
@@ -349,6 +355,7 @@ function modelToJsonSchema(ctor, jsonSchemaOptions = {}) {
349
355
  }
350
356
  }
351
357
  function includeReferencedSchema(name, schema) {
358
+ var _a, _b;
352
359
  if (!schema || !Object.keys(schema).length)
353
360
  return;
354
361
  // promote nested definition to the top level
@@ -356,13 +363,13 @@ function modelToJsonSchema(ctor, jsonSchemaOptions = {}) {
356
363
  for (const key in schema.definitions) {
357
364
  if (key === title)
358
365
  continue;
359
- result.definitions = result.definitions || {};
366
+ result.definitions = (_a = result.definitions, (_a !== null && _a !== void 0 ? _a : {}));
360
367
  result.definitions[key] = schema.definitions[key];
361
368
  }
362
369
  delete schema.definitions;
363
370
  }
364
371
  if (result !== schema) {
365
- result.definitions = result.definitions || {};
372
+ result.definitions = (_b = result.definitions, (_b !== null && _b !== void 0 ? _b : {}));
366
373
  result.definitions[name] = schema;
367
374
  }
368
375
  }
@@ -1 +1 @@
1
- {"version":3,"file":"build-schema.js","sourceRoot":"","sources":["../src/build-schema.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAAoD;AACpD,qDAO8B;AAC9B,sCAAsC;AAEtC,+BAA6B;AAC7B,iCAAwD;AACxD,MAAM,KAAK,GAAG,YAAY,CAAC,8CAA8C,CAAC,CAAC;AA0C3E;;GAEG;AACH,SAAgB,kBAAkB,CAChC,UAAgC,EAAE;IAElC,0DAA0D;IAC1D,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;QACrC,mCAAiC;KAClC;IAED,iEAAiE;IACjE,2CAA2C;IAC3C,sEAAsE;IACtE,OAAO,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;AACnE,CAAC;AAZD,gDAYC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAC3B,IAA+B,EAC/B,OAA8B;IAE9B,yDAAyD;IACzD,2BAA2B;IAC3B,MAAM,MAAM,GAAG,2BAAiB,CAAC,gBAAgB,CAAC,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C,WAAW,CAAC;SAC3B;QAED,IAAI,MAAM,KAAK,MAAM,EAAE;YACrB,MAAM,CAAC,WAAW,SAAG,MAAM,CAAC,WAAW,uCAAI,EAAE,EAAA,CAAC;YAC9C,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;SACnC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA5HD,8CA4HC"}
@@ -1,5 +1,24 @@
1
1
  import { Model } from '@loopback/repository';
2
2
  import { JSONSchema6 as JsonSchema } from 'json-schema';
3
+ export interface FilterSchemaOptions {
4
+ /**
5
+ * Set this flag if you want the schema to set generated title property.
6
+ *
7
+ * By default the setting is enabled. (e.g. {setTitle: true})
8
+ *
9
+ */
10
+ setTitle?: boolean;
11
+ }
12
+ /**
13
+ * Build a JSON schema describing the format of the "scope" object
14
+ * used to query model instances.
15
+ *
16
+ * Note we don't take the model properties into account yet and return
17
+ * a generic json schema allowing any "where" condition.
18
+ *
19
+ * @param modelCtor - The model constructor to build the filter schema for.
20
+ */
21
+ export declare function getScopeFilterJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
3
22
  /**
4
23
  * Build a JSON schema describing the format of the "filter" object
5
24
  * used to query model instances.
@@ -9,7 +28,7 @@ import { JSONSchema6 as JsonSchema } from 'json-schema';
9
28
  *
10
29
  * @param modelCtor - The model constructor to build the filter schema for.
11
30
  */
12
- export declare function getFilterJsonSchemaFor(modelCtor: typeof Model): JsonSchema;
31
+ export declare function getFilterJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
13
32
  /**
14
33
  * Build a JSON schema describing the format of the "where" object
15
34
  * used to filter model instances to query, update or delete.
@@ -19,11 +38,11 @@ export declare function getFilterJsonSchemaFor(modelCtor: typeof Model): JsonSch
19
38
  *
20
39
  * @param modelCtor - The model constructor to build the filter schema for.
21
40
  */
22
- export declare function getWhereJsonSchemaFor(modelCtor: typeof Model): JsonSchema;
41
+ export declare function getWhereJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
23
42
  /**
24
43
  * Build a JSON schema describing the format of the "fields" object
25
44
  * used to include or exclude properties of model instances.
26
45
  *
27
46
  * @param modelCtor - The model constructor to build the filter schema for.
28
47
  */
29
- export declare function getFieldsJsonSchemaFor(modelCtor: typeof Model): JsonSchema;
48
+ export declare function getFieldsJsonSchemaFor(modelCtor: typeof Model, options?: FilterSchemaOptions): JsonSchema;
@@ -11,12 +11,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  const repository_1 = require("@loopback/repository");
14
- let EmptyModel = class EmptyModel extends repository_1.Model {
15
- };
16
- EmptyModel = __decorate([
17
- repository_1.model({ settings: { strict: false } })
18
- ], EmptyModel);
19
- const scopeFilter = getFilterJsonSchemaFor(EmptyModel);
14
+ /**
15
+ * Build a JSON schema describing the format of the "scope" object
16
+ * used to query model instances.
17
+ *
18
+ * Note we don't take the model properties into account yet and return
19
+ * a generic json schema allowing any "where" condition.
20
+ *
21
+ * @param modelCtor - The model constructor to build the filter schema for.
22
+ */
23
+ function getScopeFilterJsonSchemaFor(modelCtor, options = {}) {
24
+ let EmptyModel = class EmptyModel extends repository_1.Model {
25
+ };
26
+ EmptyModel = __decorate([
27
+ repository_1.model({ settings: { strict: false } })
28
+ ], EmptyModel);
29
+ const schema = Object.assign(Object.assign({}, getFilterJsonSchemaFor(EmptyModel, { setTitle: false })), (options.setTitle !== false && {
30
+ title: `${modelCtor.modelName}.ScopeFilter`,
31
+ }));
32
+ return schema;
33
+ }
34
+ exports.getScopeFilterJsonSchemaFor = getScopeFilterJsonSchemaFor;
20
35
  /**
21
36
  * Build a JSON schema describing the format of the "filter" object
22
37
  * used to query model instances.
@@ -26,11 +41,12 @@ const scopeFilter = getFilterJsonSchemaFor(EmptyModel);
26
41
  *
27
42
  * @param modelCtor - The model constructor to build the filter schema for.
28
43
  */
29
- function getFilterJsonSchemaFor(modelCtor) {
30
- const schema = {
31
- properties: {
32
- where: getWhereJsonSchemaFor(modelCtor),
33
- fields: getFieldsJsonSchemaFor(modelCtor),
44
+ function getFilterJsonSchemaFor(modelCtor, options = {}) {
45
+ const schema = Object.assign(Object.assign({}, (options.setTitle !== false && {
46
+ title: `${modelCtor.modelName}.Filter`,
47
+ })), { properties: {
48
+ where: getWhereJsonSchemaFor(modelCtor, options),
49
+ fields: getFieldsJsonSchemaFor(modelCtor, options),
34
50
  offset: {
35
51
  type: 'integer',
36
52
  minimum: 0,
@@ -50,24 +66,20 @@ function getFilterJsonSchemaFor(modelCtor) {
50
66
  type: 'string',
51
67
  },
52
68
  },
53
- },
54
- additionalProperties: false,
55
- };
69
+ }, additionalProperties: false });
56
70
  const modelRelations = repository_1.getModelRelations(modelCtor);
57
71
  const hasRelations = Object.keys(modelRelations).length > 0;
58
72
  if (hasRelations) {
59
- schema.properties.include = {
60
- type: 'array',
61
- items: {
62
- type: 'object',
63
- properties: {
73
+ schema.properties.include = Object.assign(Object.assign({}, (options.setTitle !== false && {
74
+ title: `${modelCtor.modelName}.IncludeFilter`,
75
+ })), { type: 'array', items: Object.assign(Object.assign({}, (options.setTitle !== false && {
76
+ title: `${modelCtor.modelName}.IncludeFilter.Items`,
77
+ })), { type: 'object', properties: {
64
78
  // TODO(bajtos) restrict values to relations defined by "model"
65
79
  relation: { type: 'string' },
66
80
  // TODO(bajtos) describe the filter for the relation target model
67
- scope: scopeFilter,
68
- },
69
- },
70
- };
81
+ scope: getScopeFilterJsonSchemaFor(modelCtor, options),
82
+ } }) });
71
83
  }
72
84
  return schema;
73
85
  }
@@ -81,13 +93,13 @@ exports.getFilterJsonSchemaFor = getFilterJsonSchemaFor;
81
93
  *
82
94
  * @param modelCtor - The model constructor to build the filter schema for.
83
95
  */
84
- function getWhereJsonSchemaFor(modelCtor) {
85
- const schema = {
86
- type: 'object',
96
+ function getWhereJsonSchemaFor(modelCtor, options = {}) {
97
+ const schema = Object.assign(Object.assign({}, (options.setTitle !== false && {
98
+ title: `${modelCtor.modelName}.WhereFilter`,
99
+ })), { type: 'object',
87
100
  // TODO(bajtos) enumerate "model" properties and operators like "and"
88
101
  // See https://github.com/strongloop/loopback-next/issues/1748
89
- additionalProperties: true,
90
- };
102
+ additionalProperties: true });
91
103
  return schema;
92
104
  }
93
105
  exports.getWhereJsonSchemaFor = getWhereJsonSchemaFor;
@@ -97,14 +109,12 @@ exports.getWhereJsonSchemaFor = getWhereJsonSchemaFor;
97
109
  *
98
110
  * @param modelCtor - The model constructor to build the filter schema for.
99
111
  */
100
- function getFieldsJsonSchemaFor(modelCtor) {
101
- const schema = {
102
- type: 'object',
103
- properties: Object.assign({}, ...Object.keys(modelCtor.definition.properties).map(k => ({
112
+ function getFieldsJsonSchemaFor(modelCtor, options = {}) {
113
+ const schema = Object.assign(Object.assign({}, (options.setTitle !== false && {
114
+ title: `${modelCtor.modelName}.Fields`,
115
+ })), { type: 'object', properties: Object.assign({}, ...Object.keys(modelCtor.definition.properties).map(k => ({
104
116
  [k]: { type: 'boolean' },
105
- }))),
106
- additionalProperties: modelCtor.definition.settings.strict === false,
107
- };
117
+ }))), additionalProperties: modelCtor.definition.settings.strict === false });
108
118
  return schema;
109
119
  }
110
120
  exports.getFieldsJsonSchemaFor = getFieldsJsonSchemaFor;
@@ -1 +1 @@
1
- {"version":3,"file":"filter-json-schema.js","sourceRoot":"","sources":["../src/filter-json-schema.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,gDAAgD;AAChD,+CAA+C;AAC/C,gEAAgE;;;;;;;;AAEhE,qDAAqE;AAIrE,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,kBAAK;CAAG,CAAA;AAA3B,UAAU;IADf,kBAAK,CAAC,EAAC,QAAQ,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,EAAC,CAAC;GAC7B,UAAU,CAAiB;AAEjC,MAAM,WAAW,GAAG,sBAAsB,CAAC,UAAU,CA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version": "1.11.1",
3
+ "version": "1.12.0",
4
4
  "description": "Converts TS classes into JSON Schemas using TypeScript's reflection API",
5
5
  "engines": {
6
6
  "node": ">=8.9"
@@ -23,19 +23,19 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@loopback/context": "^1.23.5",
27
- "@loopback/metadata": "^1.3.7",
28
- "@loopback/repository": "^1.15.4",
29
- "@types/json-schema": "^7.0.3",
26
+ "@loopback/context": "^2.0.0",
27
+ "@loopback/metadata": "^1.4.0",
28
+ "@loopback/repository": "^1.18.0",
29
+ "@types/json-schema": "^7.0.4",
30
30
  "debug": "^4.1.1"
31
31
  },
32
32
  "devDependencies": {
33
- "@loopback/build": "^2.0.16",
34
- "@loopback/eslint-config": "^4.1.4",
35
- "@loopback/testlab": "^1.9.4",
33
+ "@loopback/build": "^3.1.0",
34
+ "@loopback/eslint-config": "^5.0.2",
35
+ "@loopback/testlab": "^1.10.2",
36
36
  "@types/debug": "^4.1.5",
37
- "@types/node": "^10.17.5",
38
- "ajv": "^6.10.2"
37
+ "@types/node": "^10.17.13",
38
+ "ajv": "^6.11.0"
39
39
  },
40
40
  "files": [
41
41
  "README.md",
@@ -50,5 +50,5 @@
50
50
  "url": "https://github.com/strongloop/loopback-next.git",
51
51
  "directory": "packages/repository-json-schema"
52
52
  },
53
- "gitHead": "7f0ae6ec124c19357c3016cd11f9bc9c739dffcb"
53
+ "gitHead": "d08f135a0d1040edc61497739a8d86a866e4e29a"
54
54
  }
@@ -12,7 +12,7 @@ import {
12
12
  RelationMetadata,
13
13
  resolveType,
14
14
  } from '@loopback/repository';
15
- import * as debugFactory from 'debug';
15
+ import debugFactory from 'debug';
16
16
  import {JSONSchema6 as JSONSchema} from 'json-schema';
17
17
  import {inspect} from 'util';
18
18
  import {JSON_SCHEMA_KEY, MODEL_TYPE_KEYS} from './keys';
@@ -72,7 +72,7 @@ export function buildModelCacheKey<T extends object>(
72
72
  // New key schema: use the same suffix as we use for schema title
73
73
  // For example: "modelPartialWithRelations"
74
74
  // Note this new key schema preserves the old key "modelWithRelations"
75
- return 'model' + (options.title || '') + getTitleSuffix(options);
75
+ return 'model' + (options.title ?? '') + getTitleSuffix(options);
76
76
  }
77
77
 
78
78
  /**
@@ -88,7 +88,7 @@ export function getJsonSchema<T extends object>(
88
88
  // different titles as keys
89
89
  const cached = MetadataInspector.getClassMetadata(JSON_SCHEMA_KEY, ctor);
90
90
  const key = buildModelCacheKey(options);
91
- let schema = cached && cached[key];
91
+ let schema = cached?.[key];
92
92
 
93
93
  if (!schema) {
94
94
  // Create new json schema from model
@@ -357,8 +357,8 @@ export function modelToJsonSchema<T extends object>(
357
357
  jsonSchemaOptions: JsonSchemaOptions<T> = {},
358
358
  ): JSONSchema {
359
359
  const options = {...jsonSchemaOptions};
360
- options.visited = options.visited || {};
361
- options.optional = options.optional || [];
360
+ options.visited = options.visited ?? {};
361
+ options.optional = options.optional ?? [];
362
362
  const partial = options.partial && !options.optional.length;
363
363
 
364
364
  if (options.partial && !partial) {
@@ -404,7 +404,7 @@ export function modelToJsonSchema<T extends object>(
404
404
  continue;
405
405
  }
406
406
 
407
- result.properties = result.properties || {};
407
+ result.properties = result.properties ?? {};
408
408
  result.properties[p] = result.properties[p] || {};
409
409
 
410
410
  const metaProperty = Object.assign({}, meta.properties[p]);
@@ -416,7 +416,7 @@ export function modelToJsonSchema<T extends object>(
416
416
  const optional = options.optional.includes(p as keyof T);
417
417
 
418
418
  if (metaProperty.required && !(partial || optional)) {
419
- result.required = result.required || [];
419
+ result.required = result.required ?? [];
420
420
  result.required.push(p);
421
421
  }
422
422
 
@@ -444,7 +444,7 @@ export function modelToJsonSchema<T extends object>(
444
444
 
445
445
  if (options.includeRelations) {
446
446
  for (const r in meta.relations) {
447
- result.properties = result.properties || {};
447
+ result.properties = result.properties ?? {};
448
448
  const relMeta = meta.relations[r];
449
449
  const targetType = resolveType(relMeta.target);
450
450
  const targetSchema = getJsonSchema(targetType, options);
@@ -464,14 +464,14 @@ export function modelToJsonSchema<T extends object>(
464
464
  if (result !== schema && schema.definitions) {
465
465
  for (const key in schema.definitions) {
466
466
  if (key === title) continue;
467
- result.definitions = result.definitions || {};
467
+ result.definitions = result.definitions ?? {};
468
468
  result.definitions[key] = schema.definitions[key];
469
469
  }
470
470
  delete schema.definitions;
471
471
  }
472
472
 
473
473
  if (result !== schema) {
474
- result.definitions = result.definitions || {};
474
+ result.definitions = result.definitions ?? {};
475
475
  result.definitions[name] = schema;
476
476
  }
477
477
  }
@@ -6,10 +6,41 @@
6
6
  import {getModelRelations, Model, model} from '@loopback/repository';
7
7
  import {JSONSchema6 as JsonSchema} from 'json-schema';
8
8
 
9
- @model({settings: {strict: false}})
10
- class EmptyModel extends Model {}
9
+ export interface FilterSchemaOptions {
10
+ /**
11
+ * Set this flag if you want the schema to set generated title property.
12
+ *
13
+ * By default the setting is enabled. (e.g. {setTitle: true})
14
+ *
15
+ */
16
+ setTitle?: boolean;
17
+ }
18
+
19
+ /**
20
+ * Build a JSON schema describing the format of the "scope" object
21
+ * used to query model instances.
22
+ *
23
+ * Note we don't take the model properties into account yet and return
24
+ * a generic json schema allowing any "where" condition.
25
+ *
26
+ * @param modelCtor - The model constructor to build the filter schema for.
27
+ */
28
+ export function getScopeFilterJsonSchemaFor(
29
+ modelCtor: typeof Model,
30
+ options: FilterSchemaOptions = {},
31
+ ): JsonSchema {
32
+ @model({settings: {strict: false}})
33
+ class EmptyModel extends Model {}
11
34
 
12
- const scopeFilter = getFilterJsonSchemaFor(EmptyModel);
35
+ const schema: JsonSchema = {
36
+ ...getFilterJsonSchemaFor(EmptyModel, {setTitle: false}),
37
+ ...(options.setTitle !== false && {
38
+ title: `${modelCtor.modelName}.ScopeFilter`,
39
+ }),
40
+ };
41
+
42
+ return schema;
43
+ }
13
44
 
14
45
  /**
15
46
  * Build a JSON schema describing the format of the "filter" object
@@ -20,12 +51,18 @@ const scopeFilter = getFilterJsonSchemaFor(EmptyModel);
20
51
  *
21
52
  * @param modelCtor - The model constructor to build the filter schema for.
22
53
  */
23
- export function getFilterJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
54
+ export function getFilterJsonSchemaFor(
55
+ modelCtor: typeof Model,
56
+ options: FilterSchemaOptions = {},
57
+ ): JsonSchema {
24
58
  const schema: JsonSchema = {
59
+ ...(options.setTitle !== false && {
60
+ title: `${modelCtor.modelName}.Filter`,
61
+ }),
25
62
  properties: {
26
- where: getWhereJsonSchemaFor(modelCtor),
63
+ where: getWhereJsonSchemaFor(modelCtor, options),
27
64
 
28
- fields: getFieldsJsonSchemaFor(modelCtor),
65
+ fields: getFieldsJsonSchemaFor(modelCtor, options),
29
66
 
30
67
  offset: {
31
68
  type: 'integer',
@@ -58,14 +95,20 @@ export function getFilterJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
58
95
 
59
96
  if (hasRelations) {
60
97
  schema.properties!.include = {
98
+ ...(options.setTitle !== false && {
99
+ title: `${modelCtor.modelName}.IncludeFilter`,
100
+ }),
61
101
  type: 'array',
62
102
  items: {
103
+ ...(options.setTitle !== false && {
104
+ title: `${modelCtor.modelName}.IncludeFilter.Items`,
105
+ }),
63
106
  type: 'object',
64
107
  properties: {
65
108
  // TODO(bajtos) restrict values to relations defined by "model"
66
109
  relation: {type: 'string'},
67
110
  // TODO(bajtos) describe the filter for the relation target model
68
- scope: scopeFilter,
111
+ scope: getScopeFilterJsonSchemaFor(modelCtor, options),
69
112
  },
70
113
  },
71
114
  };
@@ -83,13 +126,20 @@ export function getFilterJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
83
126
  *
84
127
  * @param modelCtor - The model constructor to build the filter schema for.
85
128
  */
86
- export function getWhereJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
129
+ export function getWhereJsonSchemaFor(
130
+ modelCtor: typeof Model,
131
+ options: FilterSchemaOptions = {},
132
+ ): JsonSchema {
87
133
  const schema: JsonSchema = {
134
+ ...(options.setTitle !== false && {
135
+ title: `${modelCtor.modelName}.WhereFilter`,
136
+ }),
88
137
  type: 'object',
89
138
  // TODO(bajtos) enumerate "model" properties and operators like "and"
90
139
  // See https://github.com/strongloop/loopback-next/issues/1748
91
140
  additionalProperties: true,
92
141
  };
142
+
93
143
  return schema;
94
144
  }
95
145
 
@@ -100,9 +150,16 @@ export function getWhereJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
100
150
  * @param modelCtor - The model constructor to build the filter schema for.
101
151
  */
102
152
 
103
- export function getFieldsJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
153
+ export function getFieldsJsonSchemaFor(
154
+ modelCtor: typeof Model,
155
+ options: FilterSchemaOptions = {},
156
+ ): JsonSchema {
104
157
  const schema: JsonSchema = {
158
+ ...(options.setTitle !== false && {
159
+ title: `${modelCtor.modelName}.Fields`,
160
+ }),
105
161
  type: 'object',
162
+
106
163
  properties: Object.assign(
107
164
  {},
108
165
  ...Object.keys(modelCtor.definition.properties).map(k => ({
@@ -111,5 +168,6 @@ export function getFieldsJsonSchemaFor(modelCtor: typeof Model): JsonSchema {
111
168
  ),
112
169
  additionalProperties: modelCtor.definition.settings.strict === false,
113
170
  };
171
+
114
172
  return schema;
115
173
  }