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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2498e7738d76689742c8f8d3486e1e194c3c0e23
4
- data.tar.gz: 989b01e640dd2ad1dbc8d67a320add322d76ec36
3
+ metadata.gz: c5592e4df1c096fb27aa06c022cb950183635504
4
+ data.tar.gz: 681b9a079009dfe1b818018ed8c540722cfda404
5
5
  SHA512:
6
- metadata.gz: a0007fdd60eb2186c06e2d8652a4daa1e09bd8dd7d7f1c84109605d946bf32070fccb177c3fdaf4129d498610a957b44ca4a3aed4f53ddb9699ff9abbd7f2a7c
7
- data.tar.gz: 729ea4407e325d64658f690e8f6ae9e6716bb494b36b0cf97a33e2f372901e65cf4e4330e4a4648ce867f60db3e0cbf34ae7f2d906455c83ae7bc1e2563c6660
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
- hash[name] = Attributor::Hash.construct(block).describe[:keys]
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
@@ -1,3 +1,3 @@
1
1
  module Praxis
2
- VERSION = '0.16.0'
2
+ VERSION = '0.16.1'
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: praxis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Blanquer