Skip to content
This repository has been archived by the owner on Oct 30, 2022. It is now read-only.

Commit

Permalink
Use custom json schema faker. (#360)
Browse files Browse the repository at this point in the history
* Use @meeshkanml/json-schema-faker.

* Delete outdated comment.

* Bump json-schema-faker version.

* Use default import for jsf if exists.

* Fix formatting.
  • Loading branch information
Kimmo Sääskilahti authored and Carolyn Stransky committed Dec 18, 2019
1 parent 9b4cf36 commit 902e5f9
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 37 deletions.
84 changes: 50 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/unmock-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"dependencies": {
"@meeshkanml/jsonschema": "^0.0.1",
"@meeshkanml/json-schema-faker": "^0.0.2",
"@types/sinon": "^7.0.13",
"@types/whatwg-url": "^6.4.0",
"ajv": "^6.10.0",
Expand All @@ -27,7 +28,6 @@
"io-ts": "^2.0.1",
"json-pointer": "^0.6.0",
"json-schema-deref-sync": "^0.10.1",
"json-schema-faker": "^0.5.0-rc17",
"json-schema-poet": "0.0.9",
"json-schema-strictly-typed": "0.0.14",
"loas3": "^0.1.4",
Expand Down
10 changes: 8 additions & 2 deletions packages/unmock-core/src/generator.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/**
* Implements the logic for generating a response from a service file
*/
// No type definitions for json-schema-faker :/
// @ts-ignore
import jsfRequire = require("@meeshkanml/json-schema-faker");
// Use default import if exists. Seems that default is needed in browser but
// not available in Node.js/React Native.
const jsf = jsfRequire.hasOwnProperty("default")
? jsfRequire.default
: jsfRequire;
import * as jsonschema from "@meeshkanml/jsonschema";
// Try fixing broken imports in Node <= 8 by using require instead of default import
const jsf = require("json-schema-faker"); // tslint:disable-line:no-var-requires
import { array } from "fp-ts/lib/Array";
import { fold, isNone, none, Option, some } from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/pipeable";
Expand Down

0 comments on commit 902e5f9

Please sign in to comment.