File tree 4 files changed +39
-1
lines changed
app/views/grape_swagger_rails/application
4 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1
1
### 0.2.1 (Next)
2
2
3
- * Your contribution here .
3
+ * Support Swagger-UI validatorUrl option - [ @ davidbrewer ] ( https://github.com/davidbrewer ) .
4
4
5
5
### 0.2.0 (February 23, 2016)
6
6
Original file line number Diff line number Diff line change @@ -74,6 +74,13 @@ See the official Swagger-UI documentation about [SwaggerUi Parameters](https://g
74
74
GrapeSwaggerRails.options.doc_expansion = 'list'
75
75
` ` `
76
76
77
+ You can set validatorUrl to your own locally deployed Swagger validator, or disable validation by setting this option to nil .
78
+ This is useful to avoid error messages when running Swagger - UI on a server which is not accessible from outside your network.
79
+
80
+ ` ` ` ruby
81
+ GrapeSwaggerRails.options.validator_url = nil
82
+ ` ` `
83
+
77
84
Using the ` headers` option above, you could hard- code Basic Authentication credentials.
78
85
Alternatively , you can configure Basic Authentication through the UI , as described below.
79
86
Original file line number Diff line number Diff line change 36
36
}
37
37
} ,
38
38
docExpansion : options . doc_expansion ,
39
+ validatorUrl : options . validator_url ,
39
40
apisSorter : "alpha"
40
41
} ) ;
41
42
Original file line number Diff line number Diff line change 153
153
end
154
154
end
155
155
end
156
+ context '#validator_url' do
157
+ context 'set null' do
158
+ before do
159
+ GrapeSwaggerRails . options . validator_url = nil
160
+ visit '/swagger'
161
+ end
162
+ it 'sets SwaggerUI validatorUrl to null' do
163
+ expect ( page . evaluate_script ( 'window.swaggerUi.options.validatorUrl === null && ' \
164
+ 'typeof window.swaggerUi.options.validatorUrl === "object"' ) ) . to be true
165
+ end
166
+ end
167
+ context 'set a url' do
168
+ before do
169
+ GrapeSwaggerRails . options . validator_url = 'http://www.example.com/'
170
+ visit '/swagger'
171
+ end
172
+ it 'sets SwaggerUI validatorUrl to expected url' do
173
+ expect ( page . evaluate_script ( 'window.swaggerUi.options.validatorUrl === "http://www.example.com/"' ) ) . to be true
174
+ end
175
+ end
176
+ context 'not set' do
177
+ before do
178
+ visit '/swagger'
179
+ end
180
+ it 'defaults SwaggerUI validatorUrl' do
181
+ expect ( page . evaluate_script ( 'window.swaggerUi.options.validatorUrl === undefined && ' \
182
+ 'typeof window.swaggerUi.options.validatorUrl === "undefined"' ) ) . to be true
183
+ end
184
+ end
185
+ end
156
186
after do
157
187
GrapeSwaggerRails . options = @options
158
188
end
You can’t perform that action at this time.
0 commit comments