fakeit 0.8.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +7 -6
- data/lib/fakeit/openapi/operation.rb +6 -2
- data/lib/fakeit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb5973b840c21eddd94a398c62a312bbbf21dba4b06323ca4ab8bf2fd7318f4
|
4
|
+
data.tar.gz: 3a2d30ed95aa61b39f68c3ddce26815ee7156f5a620a2fea097bf2d3466d5be6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35fe9c896913f0a946586ad4945960b01e3b665c1eb101d7265ec67bb1b3e59e91e224b72ef2d330455f770e6546d97d172f7d63a2849a16e3a94053196fbad0
|
7
|
+
data.tar.gz: a0425724e4c9fb66f2feda3adc505c752b9b001ac8db6aee75715a20a06478434696bf4b082887b9c8e34470d029fdc7e88d236e32837307aa9ac0339dca34fe
|
data/Gemfile.lock
CHANGED
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(&
|
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
|
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
|
|
data/lib/fakeit/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|