@@ -18,13 +18,13 @@ object BlackBoxUtils {
1818 fun targetUrl (config : EMConfig , sampler : Sampler <* >? = null): String {
1919
2020 /*
21- Note: bbTargetUrl and bbSwaggerUrl are already validated
21+ Note: base and schema are already validated
2222 in EMConfig (but they can be blank)
2323 */
2424
25- if (config.bbTargetUrl .isNotBlank()) {
25+ if (config.base .isNotBlank()) {
2626 // this has the priority
27- return config.bbTargetUrl
27+ return config.base
2828 } else {
2929
3030 when (config.problemType) {
@@ -40,17 +40,24 @@ object BlackBoxUtils {
4040 So, going to use same location as where the schema was downloaded from,
4141 as specified in the specs to do in these cases
4242 */
43- extractTarget(config.bbSwaggerUrl )
43+ extractTarget(config.schema )
4444 } else {
4545 // OpenAPI specs call it a "url", but it is actually a URI
46+ // TODO should check all 'servers' entries, especially if we get issues in resolving target
4647 val uri = schema.servers[0 ].url
4748 if (uri.startsWith(" //" )){
4849 // this can happen if 'scheme' is missing in V2, resulting in an invalid URL in current parser.
4950 // this is also a valid value in V3
5051 extractTarget(" http:$uri " )
5152 } else if (uri.startsWith(" /" )){
52- // this is a relative URI, so get info from schema location
53- extractTarget(config.bbSwaggerUrl)
53+ // this is a relative URI, so get info from schema location... but only if it is a valid URL
54+ if (! config.schema.startsWith(" http" )){
55+ throw SutProblemException (" Schema has no servers[0] entry with a URL." +
56+ " As the schema was not downloaded from a URL, EvoMaster cannot infer the" +
57+ " location of the API." +
58+ " Use '--base URL' to specify it manually" )
59+ }
60+ extractTarget(config.schema)
5461 } else {
5562 extractTarget(uri)
5663 }
0 commit comments