@@ -27,8 +27,13 @@ class Tag < Representable::Decorator
27
27
class Error < Representable ::Decorator
28
28
include Representable ::JSON
29
29
30
- property :code , documentation : { type : 'string' , desc : 'Error code' }
30
+ property :code , documentation : { type : 'string' , hidden : -> { false } , desc : 'Error code' }
31
31
property :message , documentation : { type : 'string' , desc : 'Error message' }
32
+ property :developer_message , documentation : { type : 'string' , hidden : -> { !developer? } , desc : 'Developer hidden error message' }
33
+
34
+ def self . developer?
35
+ false
36
+ end
32
37
end
33
38
34
39
class Something < Representable ::Decorator
@@ -100,6 +105,17 @@ def app
100
105
)
101
106
end
102
107
108
+ it 'should document specified models with hidden property' do
109
+ allow ( ThisApi ::Representers ::Error ) . to receive ( :developer? ) . and_return ( true )
110
+ expect ( subject [ 'definitions' ] [ 'Error' ] ) . to eq (
111
+ 'type' => 'object' ,
112
+ 'description' => 'This returns something' ,
113
+ 'properties' => { 'code' => { 'description' => 'Error code' , 'type' => 'string' } ,
114
+ 'message' => { 'description' => 'Error message' , 'type' => 'string' } ,
115
+ 'developer_message' => { 'description' => 'Developer hidden error message' , 'type' => 'string' } }
116
+ )
117
+ end
118
+
103
119
it 'should document specified models as show action' do
104
120
expect ( subject [ 'paths' ] [ '/something/{id}' ] [ 'get' ] [ 'responses' ] ) . to eq (
105
121
'200' => {
0 commit comments