schema_conformist 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -5
- data/lib/schema_conformist/driver.rb +5 -1
- data/lib/schema_conformist/process_with_assertion.rb +8 -7
- data/lib/schema_conformist/railtie.rb +3 -1
- data/lib/schema_conformist/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e54cb66b8b3d2067cff927d88c713d3c6884451015d29ec012ef9de875843cc
|
4
|
+
data.tar.gz: 2244d52ab6750d662b79c1f0e6343a80a773cf82f5cb68ef5b181b92aa6ab20b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fbb90f23972a201248b92b3b757d74fca5a40b249f6f3387963cca84ebd20075823619b4af7cbf106e7ebdb7e102350a8025b7a6223209311a39b2bb6aa3ae4
|
7
|
+
data.tar.gz: 71529b799490eb6818c8336a01d78b7930dc4c6ebad10f9d031e1e9fbc5bc15ca7add1b4da222e964ba7ae38e235cc6aa5e981350dde92f7213a556ce5aa575d
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# SchemaConformist
|
2
2
|
|
3
|
-
[![Gem Version](https://badge.fury.io/rb/schema_conformist.svg)](https://badge.fury.io/rb/schema_conformist) [![Build Status](https://
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/schema_conformist.svg)](https://badge.fury.io/rb/schema_conformist) [![Build Status](https://github.com/kymmt90/schema_conformist/workflows/build/badge.svg)](https://github.com/kymmt90/schema_conformist/actions?workflow=build)
|
4
4
|
|
5
|
-
> An automatic JSON response validator for testing in Rails
|
5
|
+
> An automatic JSON request/response validator for testing in Rails
|
6
6
|
|
7
|
-
SchemaConformist is an automatic JSON response validator for your API testing in Rails.
|
7
|
+
SchemaConformist is an automatic JSON request/response validator for your API testing in Rails.
|
8
8
|
|
9
|
-
This library automatically validates that JSON responses are conformant with the schema. The schema can be described as one of [JSON Hyper Schema](http://json-schema.org/latest/json-schema-hypermedia.html), [OpenAPI 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and OpenAPI 3 (currently [3.0.2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) is latest).
|
9
|
+
This library automatically validates that JSON requests/responses are conformant with the schema. The schema can be described as one of [JSON Hyper Schema](http://json-schema.org/latest/json-schema-hypermedia.html), [OpenAPI 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and OpenAPI 3 (currently [3.0.2](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md) is latest).
|
10
10
|
|
11
11
|
This library uses [Committee](https://github.com/interagent/committee) to validate JSONs.
|
12
12
|
|
@@ -28,7 +28,7 @@ Configure `schema_path` as follows (ex. using an OpenAPI 3 schema):
|
|
28
28
|
Rails.application.config.schema_conformist.schema_path = Rails.root.join('doc', 'openapi.yaml')
|
29
29
|
```
|
30
30
|
|
31
|
-
That's all. Then all JSON responses in integration-test/request-spec are validated according to your schema.
|
31
|
+
That's all. Then all JSON requests/responses in integration-test/request-spec are validated according to your schema.
|
32
32
|
|
33
33
|
### Writing the Schema
|
34
34
|
|
@@ -44,6 +44,9 @@ Configuration options are following:
|
|
44
44
|
- Required. The path where the schema is placed
|
45
45
|
- `schema_conformist.ignored_api_paths`
|
46
46
|
- Optional. The array of API paths not to validate. Each path can be described in String literal (used for prefix search) or regular expression.
|
47
|
+
- `schema_conformist.committee.old_assert_behavior`
|
48
|
+
- Optional. Set `true` if you want to skip validating request parameters. The default value is `false`.
|
49
|
+
- cf. ["Test Assertions" in Committee README](https://github.com/interagent/committee#test-assertions)
|
47
50
|
|
48
51
|
## Contributing
|
49
52
|
|
@@ -3,7 +3,7 @@ module SchemaConformist
|
|
3
3
|
include Committee::Test::Methods
|
4
4
|
|
5
5
|
def committee_options
|
6
|
-
{ schema: committee_schema }
|
6
|
+
{ schema: committee_schema }.merge(schema_conformist_committee_options)
|
7
7
|
end
|
8
8
|
|
9
9
|
def request_object
|
@@ -23,5 +23,9 @@ module SchemaConformist
|
|
23
23
|
def schema_path
|
24
24
|
Rails.application.config.schema_conformist.schema_path
|
25
25
|
end
|
26
|
+
|
27
|
+
def schema_conformist_committee_options
|
28
|
+
Rails.application.config.schema_conformist.committee
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
@@ -2,17 +2,18 @@ module SchemaConformist
|
|
2
2
|
module ProcessWithAssertion
|
3
3
|
include SchemaConformist::Driver
|
4
4
|
|
5
|
-
def process(
|
6
|
-
super
|
5
|
+
def process(method, path, **kwargs)
|
6
|
+
super
|
7
7
|
|
8
|
-
|
9
|
-
return if ignored?(path)
|
8
|
+
return if schema_conformist_ignored_path?(path)
|
10
9
|
|
11
10
|
assert_schema_conform
|
12
11
|
end
|
13
12
|
|
14
|
-
|
15
|
-
|
13
|
+
private
|
14
|
+
|
15
|
+
def schema_conformist_ignored_path?(path)
|
16
|
+
schema_conformist_ignored_api_paths.any? do |pattern|
|
16
17
|
case pattern
|
17
18
|
when String
|
18
19
|
path.start_with?(pattern)
|
@@ -22,7 +23,7 @@ module SchemaConformist
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
25
|
-
def
|
26
|
+
def schema_conformist_ignored_api_paths
|
26
27
|
Rails.application.config.schema_conformist.ignored_api_paths
|
27
28
|
end
|
28
29
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module SchemaConformist
|
2
2
|
class Railtie < Rails::Railtie
|
3
3
|
config.before_configuration do
|
4
|
-
config.schema_conformist =
|
4
|
+
config.schema_conformist = ActiveSupport::OrderedOptions.new
|
5
5
|
config.schema_conformist.ignored_api_paths = []
|
6
6
|
config.schema_conformist.schema_path = nil
|
7
|
+
config.schema_conformist.committee = ActiveSupport::OrderedOptions.new
|
8
|
+
config.schema_conformist.committee.old_assert_behavior = false
|
7
9
|
end
|
8
10
|
end
|
9
11
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema_conformist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kohei Yamamoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,30 +30,30 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 4.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: sqlite3
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
description: SchemaConformist is an automatic JSON response validator for
|
56
|
-
testing in Rails.
|
54
|
+
version: '0'
|
55
|
+
description: SchemaConformist is an automatic JSON request/response validator for
|
56
|
+
your API testing in Rails.
|
57
57
|
email:
|
58
58
|
- kymmt90@gmail.com
|
59
59
|
executables: []
|
@@ -89,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
92
|
+
rubygems_version: 3.1.2
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
|
-
summary: An automatic JSON response validator for testing in Rails
|
95
|
+
summary: An automatic JSON request/response validator for testing in Rails
|
96
96
|
test_files: []
|