mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 06:30:52 +00:00
Do not use JSON as default Accept header when no produces present
This commit is contained in:
parent
aa03be7f76
commit
951b7a9075
@ -108,7 +108,7 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String selectHeaderAccept(String[] accepts) {
|
public static String selectHeaderAccept(String[] accepts) {
|
||||||
if (accepts.length == 0) return "application/json";
|
if (accepts.length == 0) return null;
|
||||||
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
||||||
return StringUtil.join(accepts, ",");
|
return StringUtil.join(accepts, ",");
|
||||||
}
|
}
|
||||||
@ -194,7 +194,11 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
String querystring = b.toString();
|
String querystring = b.toString();
|
||||||
|
|
||||||
Builder builder = client.resource(host + path + querystring).accept(accept);
|
Builder builder;
|
||||||
|
if (accept == null)
|
||||||
|
builder = client.resource(host + path + querystring).getRequestBuilder();
|
||||||
|
else
|
||||||
|
builder = client.resource(host + path + querystring).accept(accept);
|
||||||
for(String key : headerParams.keySet()) {
|
for(String key : headerParams.keySet()) {
|
||||||
builder = builder.header(key, headerParams.get(key));
|
builder = builder.header(key, headerParams.get(key));
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String selectHeaderAccept(String[] accepts) {
|
public static String selectHeaderAccept(String[] accepts) {
|
||||||
if (accepts.length == 0) return "application/json";
|
if (accepts.length == 0) return null;
|
||||||
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
if (StringUtil.containsIgnoreCase(accepts, "application/json")) return "application/json";
|
||||||
return StringUtil.join(accepts, ",");
|
return StringUtil.join(accepts, ",");
|
||||||
}
|
}
|
||||||
@ -194,7 +194,11 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
String querystring = b.toString();
|
String querystring = b.toString();
|
||||||
|
|
||||||
Builder builder = client.resource(host + path + querystring).accept(accept);
|
Builder builder;
|
||||||
|
if (accept == null)
|
||||||
|
builder = client.resource(host + path + querystring).getRequestBuilder();
|
||||||
|
else
|
||||||
|
builder = client.resource(host + path + querystring).accept(accept);
|
||||||
for(String key : headerParams.keySet()) {
|
for(String key : headerParams.keySet()) {
|
||||||
builder = builder.header(key, headerParams.get(key));
|
builder = builder.header(key, headerParams.get(key));
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ public class ApiInvokerTest {
|
|||||||
assertEquals("text/plain,application/xml", ApiInvoker.selectHeaderAccept(accepts));
|
assertEquals("text/plain,application/xml", ApiInvoker.selectHeaderAccept(accepts));
|
||||||
|
|
||||||
accepts = new String[] { };
|
accepts = new String[] { };
|
||||||
assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts));
|
assertNull(ApiInvoker.selectHeaderAccept(accepts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user