fake-schema-cli
JSON-Schema-Faker CLI
Last updated 4 months ago by atomsfat .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install fake-schema-cli 
SYNC missed versions from official npm registry.

fake-schema-cli

Another CLI for json-schema-faker. With Stdin support.

Based on

Install

npm install -g fake-schema-cli

Usage

 Usage: fake-schema <file> -y -l es_MX -r user

  Options:

    -r, --rootSchema <value>         Set root schema from definitions, useful when faking Swagger specs.
    -l, --locale [value]             Faker locale. Review Faker.js for more details.
    -i, --max-items <n>              Configure a maximum amount of items to generate in an array. This will override the maximum items found inside a JSON Schema
    -m, --max-length <n>             Configure a maximum length to allow generating strings for. This will override the maximum length found inside a JSON Schema
    -p, --optionals-probability <n>  When 0.0, only required properties will be generated; when 1.0, all properties are generated
    -y, --yaml                       YAML input
    -h, --help                       output usage information

Examples (using httpie )

  • Faking local JSON Schemes

cat InnerReferences.yaml | fake-schema -y -l es_MX

  • Faking local JSON Schemes with color

cat InnerReferences.yaml | fake-schema -y -l es_MX | jq .

  • Faking remotes JSON Schemes

http http://json-schema.org/learn/examples/address.schema.json | fake-schema

  • Update result

http http://json-schema.org/learn/examples/address.schema.json | node lib/index.js | jq '.locality|="atoms"'

  • Pipe web services
http http://json-schema.org/learn/examples/address.schema.json | fake-schema | http POST httpbin.org/post
  • Save to file via redirect output

cat InnerReferences.yaml | fake-schema -y -l es_MX > file

Motivation

The website-jsf is awesome but I just want to write bash script to populate environments,.

#!/usr/bin/env bash

USER_ID=$(http :8080/swagger.yaml | fake-schema -y -r user | http POST :8080/api/user | jq .id)
http :8080/swagger.yaml | fake-schema -y -r purchase | jq  "'.user.id|=\"$USER_ID\"'" | http post :8080/api/purchase 

Tools used on examples

Current Tags

  • 0.1.0                                ...           latest (4 months ago)

5 Versions

  • 0.1.0                                ...           4 months ago
  • 0.0.4                                ...           2 years ago
  • 0.0.3                                ...           2 years ago
  • 0.0.2                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (5)
Dev Dependencies (10)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |