File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 94
94
:spec \" /swagger.json\"
95
95
:options {:ui {:jsonEditor true}
96
96
:spec {}}
97
- :data {:info {:version \" 1.0.0\"
97
+ :data {:basePath \" /app\"
98
+ :info {:version \" 1.0.0\"
98
99
:title \" Sausages\"
99
100
:description \" Sausage description\"
100
101
:termsOfService \" http://helloreverb.com/terms/\"
109
110
(if options
110
111
(let [{:keys [ui spec data] {ui-options :ui spec-options :spec } :options } (merge swagger-defaults options)]
111
112
(c/routes
112
- (if ui (apply swagger-ui ui (mapcat identity (merge ui-options (if spec {:swagger-docs spec}) ))))
113
+ (if ui (apply swagger-ui ui (mapcat identity (merge (if spec {:swagger-docs ( apply str ( remove clojure.string/blank? [( :basePath data) spec]))}) ui-options ))))
113
114
(if spec (apply swagger-docs spec (mapcat identity data))))))))
114
115
115
116
(defn validate
Original file line number Diff line number Diff line change 170
170
:path-params [foo :- String]
171
171
identity))
172
172
=> {" /:foo.json" {:get {:parameters {:path {:foo String}}}}})
173
+
174
+ (facts
175
+ (tabular
176
+ (fact " swagger-routes basePath can be changed"
177
+ (let [app (api (swagger-routes ?given-options))]
178
+ (->
179
+ (get* app " /swagger.json" )
180
+ (nth 1 )
181
+ :basePath )
182
+ => ?expected-base-path
183
+ (nth (raw-get* app " /conf.js" ) 1 ) => (str " window.API_CONF = {\" url\" :\" " ?expected-swagger-docs-path " \" };" )))
184
+ ?given-options ?expected-swagger-docs-path ?expected-base-path
185
+ {} " /swagger.json" " /"
186
+ {:data {:basePath " /app" }} " /app/swagger.json" " /app"
187
+ {:data {:basePath " /app" } :options {:ui {:swagger-docs " /imaginary.json" }}} " /imaginary.json" " /app" ))
You can’t perform that action at this time.
0 commit comments