mirror of
https://gitlab.com/restcountries/restcountries.git
synced 2026-03-31 15:07:46 +01:00
revert for 5 days: endpoint all must specify the fields
This commit is contained in:
@@ -27,13 +27,6 @@ public class CountryControllerV2 {
|
|||||||
|
|
||||||
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
|
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
|
||||||
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
|
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
|
||||||
if (fields.isEmpty()) {
|
|
||||||
return ControllerHelper.badAllRequest();
|
|
||||||
}
|
|
||||||
var totalFields = fields.get().split(",").length;
|
|
||||||
if (totalFields > 10) {
|
|
||||||
return ControllerHelper.badAllRequest();
|
|
||||||
}
|
|
||||||
List<Country> countries = CountryServiceV2.getInstance().getAll();
|
List<Country> countries = CountryServiceV2.getInstance().getAll();
|
||||||
return checkFieldsAndParseCountries(fields, countries);
|
return checkFieldsAndParseCountries(fields, countries);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,13 +18,6 @@ public class CountryControllerV3 extends ControllerV3Helper {
|
|||||||
|
|
||||||
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
|
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
|
||||||
public HttpResponse<Object> getAllCountries(@QueryValue("fields") Optional<String> fields) {
|
public HttpResponse<Object> getAllCountries(@QueryValue("fields") Optional<String> fields) {
|
||||||
if (fields.isEmpty()) {
|
|
||||||
return ControllerHelper.badAllRequest();
|
|
||||||
}
|
|
||||||
var totalFields = fields.get().split(",").length;
|
|
||||||
if (totalFields > 10) {
|
|
||||||
return ControllerHelper.badAllRequest();
|
|
||||||
}
|
|
||||||
var countries = CountryServiceV3.getInstance().getAll();
|
var countries = CountryServiceV3.getInstance().getAll();
|
||||||
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
|
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,6 @@ public class CountryControllerV31 extends ControllerV3Helper {
|
|||||||
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
|
@Get(uri = "all", produces = MediaType.APPLICATION_JSON)
|
||||||
@Schema(name = "RestCountries")
|
@Schema(name = "RestCountries")
|
||||||
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
|
public Object getAllCountries(@QueryValue("fields") Optional<String> fields) {
|
||||||
if (fields.isEmpty()) {
|
|
||||||
return ControllerHelper.badAllRequest();
|
|
||||||
}
|
|
||||||
var totalFields = fields.get().split(",").length;
|
|
||||||
if (totalFields > 10) {
|
|
||||||
return ControllerHelper.badAllRequest();
|
|
||||||
}
|
|
||||||
var countries = CountryServiceV31.getInstance().getAll();
|
var countries = CountryServiceV31.getInstance().getAll();
|
||||||
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
|
return ControllerHelper.ok(checkFieldsAndParseCountries(fields, countries));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user