Skip to content

Commit

Permalink
fix: remove merge
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Jan 9, 2021
1 parent 009d95e commit 53efb35
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/framework/openapi.schema.validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ import { OpenAPIV3 } from './types.js';

export class OpenAPISchemaValidator {
private validator: Ajv.ValidateFunction;
constructor({
version,
extensions,
}: {
version: string;
extensions?: object;
}) {
constructor({ version }: { version: string; extensions?: object }) {
const v = new Ajv({ schemaId: 'auto', allErrors: true });
v.addMetaSchema(draftSchema);

const ver = version && parseInt(String(version), 10);
if (!ver) throw Error('version missing from OpenAPI specification');
if (ver != 3) throw Error('OpenAPI v3 specification version is required');

const schema = merge({}, openapi3Schema, extensions ?? {});
v.addSchema(schema);
this.validator = v.compile(schema);
v.addSchema(openapi3Schema);
this.validator = v.compile(openapi3Schema);
}

public validate(
Expand Down

0 comments on commit 53efb35

Please sign in to comment.