diff --git a/package.json b/package.json index f8ed383..8c56700 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "openapi-typescript-validator", - "version": "3.2.0", + "version": "3.2.1", "description": "Generate typescript with ajv validation based on openapi schemas", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/generate/generate-compile-decoders.ts b/src/generate/generate-compile-decoders.ts index c6ff00c..70364bd 100644 --- a/src/generate/generate-compile-decoders.ts +++ b/src/generate/generate-compile-decoders.ts @@ -56,8 +56,8 @@ import { $ModelImports } from './models'; import jsonSchema from './schema.json'; const ajv = new Ajv({ strict: false }); -ajv.compile(jsonSchema); $Formats +ajv.compile(jsonSchema); // Decoders $Decoders diff --git a/tests/src/__snapshots__/custom-schema.test.ts.snap b/tests/src/__snapshots__/custom-schema.test.ts.snap index b065ff0..7548ff0 100644 --- a/tests/src/__snapshots__/custom-schema.test.ts.snap +++ b/tests/src/__snapshots__/custom-schema.test.ts.snap @@ -11,6 +11,7 @@ import { Screen, ImageComponent, ListerComponent } from \\"./models\\"; import jsonSchema from \\"./schema.json\\"; const ajv = new Ajv({ strict: false }); + ajv.compile(jsonSchema); // Decoders diff --git a/tests/src/__snapshots__/format-schema.test.ts.snap b/tests/src/__snapshots__/format-schema.test.ts.snap index 6f6d884..de1b62a 100644 --- a/tests/src/__snapshots__/format-schema.test.ts.snap +++ b/tests/src/__snapshots__/format-schema.test.ts.snap @@ -11,8 +11,8 @@ import { User, Price } from \\"./models\\"; import jsonSchema from \\"./schema.json\\"; const ajv = new Ajv({ strict: false }); -ajv.compile(jsonSchema); addFormats(ajv, { mode: \\"fast\\", formats: [\\"date\\", \\"time\\"] }); +ajv.compile(jsonSchema); // Decoders export const UserDecoder: Decoder = { @@ -53,8 +53,8 @@ import { User, Price } from \\"./models\\"; import jsonSchema from \\"./schema.json\\"; const ajv = new Ajv({ strict: false }); -ajv.compile(jsonSchema); addFormats(ajv, undefined); +ajv.compile(jsonSchema); // Decoders export const UserDecoder: Decoder = { diff --git a/tests/src/format-schema.test.ts b/tests/src/format-schema.test.ts index 897d6f9..7555563 100644 --- a/tests/src/format-schema.test.ts +++ b/tests/src/format-schema.test.ts @@ -2,6 +2,7 @@ import path from "path"; import fs from "fs"; import { generate } from "openapi-typescript-validator"; import Ajv from 'ajv'; +import spyOn = jest.spyOn; describe("format-schema - compile based", () => { const name = "format"; @@ -19,6 +20,12 @@ describe("format-schema - compile based", () => { }); }); + test("should not generate warnings on import", async () => { + const consoleWarnSpy = spyOn(console, 'warn'); + await import(path.join(generatedDir, 'decoders.ts')); + expect(consoleWarnSpy).not.toHaveBeenCalled(); + }); + test("files should match", () => { const files = fs.readdirSync(generatedDir); expect(files).toEqual([ diff --git a/tests/tsconfig.json b/tests/tsconfig.json index 5dbb5b9..e0f2904 100644 --- a/tests/tsconfig.json +++ b/tests/tsconfig.json @@ -8,7 +8,8 @@ "declaration": true, "sourceMap": true, "esModuleInterop": true, - "skipLibCheck": true + "skipLibCheck": true, + "resolveJsonModule": true }, "include": ["src/**/*"], "exclude": ["node_modules", "tests"]