@tsofist/schema-forge 3.7.0 → 3.7.1

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.
@@ -4,13 +4,15 @@ const error_1 = require("@tsofist/stem/lib/error");
4
4
  const is_empty_1 = require("@tsofist/stem/lib/object/is-empty");
5
5
  const ts_json_schema_generator_1 = require("ts-json-schema-generator");
6
6
  const typescript_1 = require("typescript");
7
+ const helpers_tsc_1 = require("./helpers-tsc");
7
8
  {
8
9
  // Support for @inheritDoc tag to enforce inheritance of annotations
9
10
  // todo rework
10
11
  // eslint-disable-next-line @typescript-eslint/unbound-method
11
12
  const getAnnotations = ts_json_schema_generator_1.ExtendedAnnotationsReader.prototype.getAnnotations;
12
13
  ts_json_schema_generator_1.ExtendedAnnotationsReader.prototype.getAnnotations = function getAnnotationsWithInheritance(node) {
13
- // if (!hasJSDocTag(node, 'inheritDoc')) return getAnnotations.call(this, node);
14
+ if (!(0, helpers_tsc_1.hasJSDocTag)(node, 'inheritDoc'))
15
+ return getAnnotations.call(this, node);
14
16
  // @ts-expect-error access to private property
15
17
  const checker = this.typeChecker || (0, error_1.raise)('TypeChecker is not available');
16
18
  const result = {};
@@ -189,10 +189,34 @@ describe('generator for a6', () => {
189
189
  format: 'uuid',
190
190
  description: 'This is Collection item ID (inherits from UUID)',
191
191
  });
192
- expect(registry.getValidator('test#/definitions/CollectionItemID2').schema).toStrictEqual({
192
+ expect(registry.getSchema('test#/definitions/CollectionItemID2')).toStrictEqual({
193
193
  $ref: '#/definitions/UUID',
194
+ description: 'This is Collection item ID (non-inherits from UUID)',
195
+ $comment: 'This is a comment for CollectionItemID2',
196
+ });
197
+ expect(registry.getSchema('test#/definitions/CollectionItemID3')).toStrictEqual({
194
198
  format: 'uuid',
199
+ type: 'string',
200
+ });
201
+ expect(registry.getSchema('test#/definitions/CollectionItemID4')).toStrictEqual({
202
+ $ref: '#/definitions/UUID',
203
+ description: 'This is Collection item ID (non-inherits from UUID)',
204
+ format: 'uuid',
205
+ });
206
+ expect(registry.getSchema('test#/definitions/CollectionItemID6')).toStrictEqual({
207
+ $ref: '#/definitions/UUID',
195
208
  description: 'This is Collection item ID (non-inherits from UUID)',
209
+ dbFK: true,
210
+ });
211
+ expect(registry.getSchema('test#/definitions/CollectionItemID7')).toStrictEqual({
212
+ $ref: '#/definitions/UUID',
213
+ description: 'This is Collection item ID (non-inherits from UUID)',
214
+ dbFK: true,
215
+ format: 'uuid',
216
+ });
217
+ expect(registry.getSchema('test#/definitions/CollectionItemID5')).toStrictEqual({
218
+ format: 'uuid',
219
+ type: 'string',
196
220
  });
197
221
  {
198
222
  const rec = registry.getValidator('test#/definitions/PRec<CollectionItem,UUID>').schema;
@@ -209,6 +233,31 @@ describe('generator for a6', () => {
209
233
  description: 'This is Collection item ID (inherits from UUID)',
210
234
  });
211
235
  }
236
+ {
237
+ const rec = registry.getValidator('test#/definitions/Rec<number,CollectionItemID4>').schema;
238
+ expect(rec).toBeTruthy();
239
+ expect(rec.propertyNames).toStrictEqual({
240
+ format: 'uuid',
241
+ description: 'This is Collection item ID (non-inherits from UUID)',
242
+ });
243
+ }
244
+ {
245
+ const rec = registry.getValidator('test#/definitions/Rec<number,CollectionItemID6>').schema;
246
+ expect(rec).toBeTruthy();
247
+ expect(rec.propertyNames).toStrictEqual({
248
+ dbFK: true,
249
+ description: 'This is Collection item ID (non-inherits from UUID)',
250
+ });
251
+ }
252
+ {
253
+ const rec = registry.getValidator('test#/definitions/Rec<number,CollectionItemID7>').schema;
254
+ expect(rec).toBeTruthy();
255
+ expect(rec.propertyNames).toStrictEqual({
256
+ dbFK: true,
257
+ format: 'uuid',
258
+ description: 'This is Collection item ID (non-inherits from UUID)',
259
+ });
260
+ }
212
261
  });
213
262
  });
214
263
  describe('generator for a5', () => {
@@ -273,7 +322,7 @@ describe('generator for a5', () => {
273
322
  $ref: '#/definitions/UUID',
274
323
  dbFK: true,
275
324
  description: 'Foreign Key Column Type.',
276
- format: 'uuid',
325
+ // format: 'uuid',
277
326
  });
278
327
  expect(registry.getValidator('test#/definitions/Some').schema).toStrictEqual({
279
328
  type: 'object',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsofist/schema-forge",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "description": "Generate JSON schema from TypeScript types",
5
5
  "author": "Andrew Berdnikov <tsofistgudmen@gmail.com>",
6
6
  "license": "LGPL-3.0",