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

Use custom json schema faker. #360

Merged
merged 5 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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