@@ -27,8 +27,8 @@ exports.init = function (app, opt) {
27
27
fs . readFile ( opt . swaggerUI + '/index.html' , function ( err , data ) {
28
28
if ( err ) fn ( err ) ;
29
29
var html = data . toString ( ) ;
30
- var regex = / d i s c o v e r y U r l : " ( .* ?) , / ;
31
- html = html . replace ( regex , 'discoveryUrl: "' + opt . basePath + '/api-docs.json"' ) ;
30
+ var regex = / d i s c o v e r y U r l : ( .* ?) , / ;
31
+ html = html . replace ( regex , 'discoveryUrl: "' + opt . basePath + '/api-docs.json", ' ) ;
32
32
fs . writeFile ( opt . swaggerUI + '/index.html' , html , function ( err ) {
33
33
if ( err ) throw err ;
34
34
} ) ;
@@ -52,12 +52,9 @@ exports.init = function (app, opt) {
52
52
if ( match != null ) {
53
53
result = _ . clone ( descriptor ) ;
54
54
if ( match [ 1 ] != null ) {
55
- resource = _ . find ( resources , function ( res ) {
56
- return match [ 1 ] === '/' + path . basename ( req . path ) ;
57
- } ) ;
58
- if ( resource == null ) {
59
- return res . send ( 404 ) ;
60
- }
55
+ resource = resources [ match [ 1 ] ] ;
56
+ if ( ! resource )
57
+ return res . send ( 404 ) ;
61
58
result . resourcePath = resource . resourcePath ;
62
59
result . apis = resource . apis ;
63
60
result . models = resource . models ;
@@ -130,7 +127,7 @@ function readYml(file, fn) {
130
127
api . resourcePath = resource . resourcePath ;
131
128
api . description = resource . description ;
132
129
descriptor . apis . push ( api ) ;
133
- resources [ resource . path ] = resource ;
130
+ resources [ resource . resourcePath ] = resource ;
134
131
fn ( ) ;
135
132
} ;
136
133
0 commit comments