sober_swag 0.2.0 → 0.3.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/.github/workflows/ruby.yml +7 -1
- data/Gemfile.lock +10 -10
- data/README.md +1 -3
- data/example/Gemfile.lock +1 -1
- data/lib/sober_swag/compiler/type.rb +5 -1
- data/lib/sober_swag/serializer/conditional.rb +5 -1
- data/lib/sober_swag/serializer/mapped.rb +3 -1
- data/lib/sober_swag/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: c404cf1bad19f06280ce4c8a2002899ed37e9e68e0fc910d270b4e14dc38dab6
|
4
|
+
data.tar.gz: 29333042d89f5f3de762143ef60566bbbb45640a948c8b5720c4563b236a1d64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b84c508452f4dfd1250e0b6255d11173e2eb8382669adb75d3356f842a9ce7e6155410f5c233c6a8eae00697db0a561b3e466cfa9704996fb8de76c164f9c6b
|
7
|
+
data.tar.gz: 45f28285e80a666f45f6b8ef3b598fb68c321da83022ee3d13b8532bf97cc9b2fe3eaed36ca3d670fe75b44a37263d349ce76dde44f4ed80bdb5583bb4e7f342
|
data/.github/workflows/ruby.yml
CHANGED
@@ -38,7 +38,13 @@ jobs:
|
|
38
38
|
bundle config path vendor/bundle
|
39
39
|
bundle install
|
40
40
|
- name: Run tests
|
41
|
-
run: bundle exec rake
|
41
|
+
run: COVERAGE=1 bundle exec rake
|
42
|
+
- name: Upload Coverage
|
43
|
+
uses: actions/upload-artifact@master
|
44
|
+
if: always()
|
45
|
+
with:
|
46
|
+
name: coverage-report
|
47
|
+
path: coverage
|
42
48
|
- uses: actions/cache@v2
|
43
49
|
with:
|
44
50
|
path: example/vendor/bundle
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
sober_swag (0.
|
4
|
+
sober_swag (0.2.0)
|
5
5
|
activesupport
|
6
6
|
dry-struct (~> 1.0)
|
7
7
|
dry-types (~> 1.2)
|
@@ -9,7 +9,7 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
activesupport (6.0.3.
|
12
|
+
activesupport (6.0.3.2)
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
14
|
i18n (>= 0.7, < 2)
|
15
15
|
minitest (~> 5.1)
|
@@ -18,9 +18,9 @@ GEM
|
|
18
18
|
ast (2.4.1)
|
19
19
|
coderay (1.1.2)
|
20
20
|
concurrent-ruby (1.1.6)
|
21
|
-
diff-lcs (1.
|
21
|
+
diff-lcs (1.4.4)
|
22
22
|
docile (1.3.2)
|
23
|
-
dry-configurable (0.11.
|
23
|
+
dry-configurable (0.11.6)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
25
|
dry-core (~> 0.4, >= 0.4.7)
|
26
26
|
dry-equalizer (~> 0.2)
|
@@ -47,7 +47,7 @@ GEM
|
|
47
47
|
dry-equalizer (~> 0.3)
|
48
48
|
dry-inflector (~> 0.1, >= 0.1.2)
|
49
49
|
dry-logic (~> 1.0, >= 1.0.2)
|
50
|
-
i18n (1.8.
|
50
|
+
i18n (1.8.3)
|
51
51
|
concurrent-ruby (~> 1.0)
|
52
52
|
ice_nine (0.11.2)
|
53
53
|
method_source (0.9.2)
|
@@ -66,15 +66,15 @@ GEM
|
|
66
66
|
rspec-core (~> 3.9.0)
|
67
67
|
rspec-expectations (~> 3.9.0)
|
68
68
|
rspec-mocks (~> 3.9.0)
|
69
|
-
rspec-core (3.9.
|
70
|
-
rspec-support (~> 3.9.
|
71
|
-
rspec-expectations (3.9.
|
69
|
+
rspec-core (3.9.2)
|
70
|
+
rspec-support (~> 3.9.3)
|
71
|
+
rspec-expectations (3.9.2)
|
72
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
73
73
|
rspec-support (~> 3.9.0)
|
74
74
|
rspec-mocks (3.9.1)
|
75
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
76
76
|
rspec-support (~> 3.9.0)
|
77
|
-
rspec-support (3.9.
|
77
|
+
rspec-support (3.9.3)
|
78
78
|
rubocop (0.88.0)
|
79
79
|
parallel (~> 1.10)
|
80
80
|
parser (>= 2.7.1.1)
|
@@ -97,7 +97,7 @@ GEM
|
|
97
97
|
tzinfo (1.2.7)
|
98
98
|
thread_safe (~> 0.1)
|
99
99
|
unicode-display_width (1.7.0)
|
100
|
-
zeitwerk (2.
|
100
|
+
zeitwerk (2.4.0)
|
101
101
|
|
102
102
|
PLATFORMS
|
103
103
|
ruby
|
data/README.md
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|

|
4
4
|

|
5
5
|
|
6
|
-
***NOTE: THIS GEM IS HIGHLY EXPERIMENTAL AND PROBABLY SHOULD NOT YET BE USED IN PRODUCTION***.
|
7
|
-
|
8
6
|
SoberSwag is a combination of [Dry-Types](https://dry-rb.org/gems/dry-types/1.2/) and [Swagger](https://swagger.io/) that makes your Rails APIs more awesome.
|
9
7
|
Other tools generate documenation from a DSL.
|
10
8
|
This generates documentation from *types*, which (conveniently) also lets you get supercharged strong-params-on-steroids.
|
@@ -51,7 +49,7 @@ You define the type of parameters you accept, and we reject anything that doesn'
|
|
51
49
|
### Typed Responses
|
52
50
|
|
53
51
|
Want to go further and type your responses too?
|
54
|
-
Use SoberSwag
|
52
|
+
Use SoberSwag output objects, a serializer library heavily inspired by [Blueprinter](https://github.com/procore/blueprinter)
|
55
53
|
|
56
54
|
```ruby
|
57
55
|
PersonOutputObject = SoberSwag::OutputObject.define do
|
data/example/Gemfile.lock
CHANGED
@@ -22,6 +22,8 @@ module SoberSwag
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def primitive_def(value)
|
25
|
+
value = value.primitive if value.is_a?(Dry::Types::Nominal)
|
26
|
+
|
25
27
|
return nil unless value.is_a?(Class)
|
26
28
|
|
27
29
|
if (name = primitive_name(value))
|
@@ -129,7 +131,7 @@ module SoberSwag
|
|
129
131
|
when Dry::Types::Sum
|
130
132
|
{ oneOf: normalize(parsed_type).elements.map { |t| self.class.new(t.value).schema_stub } }
|
131
133
|
else
|
132
|
-
raise
|
134
|
+
raise SoberSwag::Compiler::Error, "Cannot generate a schema stub for #{type} (#{type.class})"
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
@@ -239,6 +241,8 @@ module SoberSwag
|
|
239
241
|
def ensure_uncomplicated(key, value)
|
240
242
|
return if value[:type]
|
241
243
|
|
244
|
+
return value[:oneOf].each { |member| ensure_uncomplicated(key, member) } if value[:oneOf]
|
245
|
+
|
242
246
|
raise TooComplicatedError, <<~ERROR
|
243
247
|
Property #{key} has object-schema #{value}, but this type of param should be simple (IE a primitive of some kind)
|
244
248
|
ERROR
|
data/lib/sober_swag/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sober_swag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Super
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|