praxis 0.16.0 → 0.16.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/praxis/trait.rb +14 -3
- data/lib/praxis/version.rb +1 -1
- data/spec/praxis/trait_spec.rb +15 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5592e4df1c096fb27aa06c022cb950183635504
|
4
|
+
data.tar.gz: 681b9a079009dfe1b818018ed8c540722cfda404
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed883f867ad4143adfa89ce11404feb45ef00505470529f5cdb95bad7dd40a38f307c339505f8973d5e0a75c0053267be3e3dd48b627051caf2878e0f4d0b72f
|
7
|
+
data.tar.gz: 28d76baeba6a3b7fd66fe82f2d16dcd997d9b9c87c5a0320201f716cb91a00c2aee14c9a5fe94dab46264cc14b5b2eec2cad95a509d4a224d7fe2262078562c3
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## next
|
4
4
|
|
5
|
+
## 0.16.1
|
6
|
+
|
7
|
+
* Fixed a bug where documentation generation would fail if an application had headers in a Trait using the simplified `header` DSL.
|
8
|
+
|
5
9
|
## 0.16.0
|
6
10
|
|
7
11
|
* Overhauled traits: they're now represented by a `Trait` class, which are created from `ApiDefinition#trait`.
|
data/lib/praxis/trait.rb
CHANGED
@@ -69,7 +69,18 @@ module Praxis
|
|
69
69
|
end
|
70
70
|
|
71
71
|
@attribute_groups.each_with_object(desc) do |(name, block), hash|
|
72
|
-
|
72
|
+
type_class = if name == :headers
|
73
|
+
# Headers are special:
|
74
|
+
# Keys are strings, they have a special DSL, and are case insensitive
|
75
|
+
hash_opts = {
|
76
|
+
dsl_compiler: ActionDefinition::HeadersDSLCompiler,
|
77
|
+
case_insensitive_load: true
|
78
|
+
}
|
79
|
+
Attributor::Hash.of(key: String).construct(block, hash_opts)
|
80
|
+
else
|
81
|
+
Attributor::Hash.construct(block)
|
82
|
+
end
|
83
|
+
hash[name] = type_class.describe[:keys]
|
73
84
|
end
|
74
85
|
|
75
86
|
desc
|
@@ -80,11 +91,11 @@ module Praxis
|
|
80
91
|
@attribute_groups.each do |name, block|
|
81
92
|
target.send(name, &block)
|
82
93
|
end
|
83
|
-
|
94
|
+
|
84
95
|
if @routing
|
85
96
|
target.routing(&@routing)
|
86
97
|
end
|
87
|
-
|
98
|
+
|
88
99
|
@responses.each do |name, args|
|
89
100
|
target.response(name, **args)
|
90
101
|
end
|
data/lib/praxis/version.rb
CHANGED
data/spec/praxis/trait_spec.rb
CHANGED
@@ -19,6 +19,11 @@ describe Praxis::Trait do
|
|
19
19
|
description: "Field to sort by."
|
20
20
|
end
|
21
21
|
|
22
|
+
headers do
|
23
|
+
header "Authorization"
|
24
|
+
key "Header2", String, required: true
|
25
|
+
end
|
26
|
+
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
@@ -26,13 +31,21 @@ describe Praxis::Trait do
|
|
26
31
|
subject(:describe) { trait.describe }
|
27
32
|
|
28
33
|
its([:description]) { should eq('my awesome trait') }
|
29
|
-
|
34
|
+
|
30
35
|
its([:responses, :something]) { should eq Hash.new }
|
31
36
|
its([:responses, :nothing]) { should eq Hash.new }
|
32
|
-
|
37
|
+
|
33
38
|
its([:params, :app_name, :type, :name]) { should eq 'String' }
|
34
39
|
its([:params, :order, :type, :name]) { should eq 'String' }
|
35
40
|
its([:routing, :prefix]) { should eq '/:app_name'}
|
41
|
+
|
42
|
+
its([:headers, "Header2"]) { should include({required: true}) }
|
43
|
+
context 'using the special DSL syntax for headers' do
|
44
|
+
subject(:dsl_header) { describe[:headers]["Authorization"] }
|
45
|
+
its([:required]){ should be(true) }
|
46
|
+
its([:type]){ should eq( { :id=>"Attributor-String", :name=>"String", :family=>"string"} )}
|
47
|
+
end
|
48
|
+
|
36
49
|
end
|
37
50
|
|
38
51
|
end
|