fakeit 0.8.1 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b596171f4bdda96b6782f7292abbadee787e56f045d75449792f64c86b370abf
4
- data.tar.gz: f9d429ed7328142a0b7f53e3352d782bf5b096ce449e88ada902b6205b916010
3
+ metadata.gz: dbb5973b840c21eddd94a398c62a312bbbf21dba4b06323ca4ab8bf2fd7318f4
4
+ data.tar.gz: 3a2d30ed95aa61b39f68c3ddce26815ee7156f5a620a2fea097bf2d3466d5be6
5
5
  SHA512:
6
- metadata.gz: 9ee0a08eae71abb26ee679615022fe3eb363e90233714f0eb34bccca973a1d68dbc16badcd0520456a30fc7e0966df7405bb551e27664c101fea8482ce3d78d6
7
- data.tar.gz: de08d3b1e0f0118c85bc61d8e22d812ac591a439dace0a7dc5279a9801d21a50cdf1f6f8baf6378e35487ac9ba565e30630e949e179ec2e10f8f3092e4df1840
6
+ metadata.gz: 35fe9c896913f0a946586ad4945960b01e3b665c1eb101d7265ec67bb1b3e59e91e224b72ef2d330455f770e6546d97d172f7d63a2849a16e3a94053196fbad0
7
+ data.tar.gz: a0425724e4c9fb66f2feda3adc505c752b9b001ac8db6aee75715a20a06478434696bf4b082887b9c8e34470d029fdc7e88d236e32837307aa9ac0339dca34fe
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fakeit (0.8.1)
4
+ fakeit (0.9.0)
5
5
  faker (= 2.13.0)
6
6
  openapi_parser (= 0.12.1)
7
7
  rack (~> 2.0)
data/README.md CHANGED
@@ -35,6 +35,7 @@ After tried several existing options, we cannot find a best solution to meet all
35
35
  * Load specification from local or remote
36
36
  * Support hot reload local specification
37
37
  * Support specification in yaml or json format
38
+ * [Experimental] Support plain text and binary response, e.g. `application/pdf`
38
39
 
39
40
  ## Installation
40
41
 
@@ -66,6 +67,12 @@ Or use the [docker image](https://hub.docker.com/r/realfengjia/fakeit)
66
67
  -v, --version
67
68
  -h, --help
68
69
 
70
+ **Notes:**
71
+ * See [here](docs/random.md) for Openapi properties supported in random response generation
72
+ * See [here](docs/static.md) for default value in static response generation
73
+ * Regarding `--use-example` mode, property without example specified will still be randomly or statically generated
74
+ * Random response generation can not handle recursive schema reference. If you do need it in your spec file, please provide `example` property for the recursive part of schema and specify `--use-example` option.
75
+
69
76
  ### Configuration endpoint
70
77
 
71
78
  Mock server behaviour can be changed on the fly
@@ -93,12 +100,6 @@ Request and response:
93
100
  }
94
101
  ```
95
102
 
96
- **Notes:**
97
- * See [here](docs/random.md) for Openapi properties supported in random response generation
98
- * See [here](docs/static.md) for default value in static response generation
99
- * Regarding `--use-example` mode, property without example specified will still be randomly or statically generated
100
- * Random response generation can not handle recursive schema reference. If you do need it in your spec file, please provide `example` property for the recursive part of schema and specify `--use-example` option.
101
-
102
103
  ## Development
103
104
 
104
105
  After checking out the repo, run `bundle install` to install dependencies. Then, run `rake` to run the tests.
@@ -20,7 +20,7 @@ module Fakeit
20
20
  response_schema
21
21
  &.schema
22
22
  &.to_example(example_options)
23
- &.then(&JSON.method(:generate))
23
+ &.then(&method(:serialise))
24
24
  .to_s
25
25
  end
26
26
 
@@ -28,11 +28,15 @@ module Fakeit
28
28
 
29
29
  private
30
30
 
31
+ def serialise(body) = body.is_a?(String) ? body : JSON.generate(body)
32
+
31
33
  def example_options
32
34
  { use_example: @app_options.use_example, use_static: @app_options.method(:use_static?), depth: 0 }
33
35
  end
34
36
 
35
- def response_content = response.last.content&.find { |k, _| k =~ %r{^application/.*json} }
37
+ def response_content
38
+ response.last.content&.find { |k, _| k =~ %r{^application/.*json} || k == 'application/pdf' }
39
+ end
36
40
 
37
41
  def response_schema = response_content&.last
38
42
 
@@ -1,3 +1,3 @@
1
1
  module Fakeit
2
- VERSION = '0.8.1'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fakeit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Feng
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-01 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler