Skip to content

Commit c3941b0

Browse files
committed
feat(deps): Updated to latest jsonpolice to support the DynamicSchema class
1 parent 7985c0e commit c3941b0

3 files changed

Lines changed: 7 additions & 17 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"decamelize": "^1.2.0",
100100
"eredita": "^1.0.1",
101101
"express": "^4.15.2",
102-
"jsonpolice": "^5.1.1",
102+
"jsonpolice": "^5.2.0",
103103
"jsonref": "^3.5.0",
104104
"lodash": "^4.17.4",
105105
"mongodb": "^2.2.25",

src/api.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as _ from 'lodash';
55
import * as semver from 'semver';
66
import * as express from 'express';
77
import { normalizeUri } from 'jsonref';
8-
import { Schema } from 'jsonpolice';
8+
import { Schema, DynamicSchema } from 'jsonpolice';
99
import { Router, RouterOptions, RequestHandler, Request, Response, NextFunction } from 'express';
1010
import { Eredita } from 'eredita';
1111
import debug, { Logger } from './debug';
@@ -227,17 +227,17 @@ export class API implements Swagger {
227227
return this;
228228
}
229229

230-
registerSchema(id: string, schema: Swagger.Schema | Schema) {
230+
registerSchema(id: string, schema: Swagger.Schema | DynamicSchema) {
231231
if (!this[__schemas]) {
232232
this[__schemas] = {};
233233
this.registerTag(_.cloneDeep(__default_schema_tag));
234234
this.registerOperation('/schemas/{id}', 'get', _.cloneDeep(__default_schema_operation));
235235
}
236236

237237
let _schema: Swagger.FullSchema;
238-
if (schema instanceof Schema) {
238+
if (schema instanceof DynamicSchema) {
239239
_schema = {};
240-
Schema.attach(_schema, schema as Schema);
240+
Schema.attach(_schema, schema as DynamicSchema);
241241
} else {
242242
_schema = schema as Swagger.FullSchema;
243243
}

test/api.test.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var chai = require('chai')
55
, pem = require('pem')
66
, express = require('express')
77
, Schema = require('jsonpolice').Schema
8+
, DynamicSchema = require('jsonpolice').DynamicSchema
89
, Scopes = require('../dist/scopes').Scopes
910
, API = require('../dist/api').API
1011
, Resource = require('../dist/resource').Resource
@@ -197,21 +198,10 @@ describe('API', function() {
197198
const schema1 = { a: true, b: 2 };
198199
const schema2 = { c: 'd', e: [] };
199200

200-
class TestSchema extends Schema {
201-
constructor(scope, opts) {
202-
super(scope, opts);
203-
}
201+
class TestSchema extends DynamicSchema {
204202
async schema() {
205203
return schema2;
206204
}
207-
async validate(data, path) {
208-
return data;
209-
}
210-
init() {
211-
}
212-
default(data) {
213-
return data;
214-
}
215205
}
216206
let server;
217207

0 commit comments

Comments
 (0)