File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
app/views/grape_swagger_rails/application Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 11### 0.2.1 (Next)
22
33* Your contribution here.
4+ * Support Swagger-UI validatorUrl option - [ @davidbrewer ] ( https://github.com/davidbrewer ) .
45
56### 0.2.0 (February 23, 2016)
67
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
7474GrapeSwaggerRails.options.doc_expansion = 'list'
7575` ` `
7676
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+
7784Using the ` headers` option above, you could hard- code Basic Authentication credentials.
7885Alternatively , you can configure Basic Authentication through the UI , as described below.
7986
Original file line number Diff line number Diff line change 3636 }
3737 } ,
3838 docExpansion : options . doc_expansion ,
39+ validatorUrl : options . validator_url ,
3940 apisSorter : "alpha"
4041 } ) ;
4142
Original file line number Diff line number Diff line change 153153 end
154154 end
155155 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
156186 after do
157187 GrapeSwaggerRails . options = @options
158188 end
You can’t perform that action at this time.
0 commit comments