3636
3737package nl .dtls .fairdatapoint .api .controller .search ;
3838
39- import io .swagger .v3 .oas .annotations .media .Schema ;
4039import io .swagger .v3 .oas .annotations .tags .Tag ;
4140import jakarta .servlet .http .HttpServletResponse ;
4241import org .eclipse .rdf4j .http .server .readonly .sparql .EvaluateResult ;
@@ -57,6 +56,8 @@ public class SearchSparqlController {
5756
5857 private static final String [] ALL_GRAPHS = {};
5958
59+ private static final String JSON_MEDIA_TYPES = "application/json, application/ld+json" ;
60+
6061 private final Repository rdf4jRepository ;
6162
6263 private final SparqlQueryEvaluator sparqlQueryEvaluator ;
@@ -76,15 +77,18 @@ public SearchSparqlController(Repository rdf4jRepository, SparqlQueryEvaluator s
7677 * as defined in <code>org.eclipse.rdf4j.http.server.readonly.sparql.QueryTypes.formats</code>.
7778 */
7879 @ PreAuthorize ("isAuthenticated()" )
79- @ PostMapping (path = "/search/sparql" , consumes = MediaType .APPLICATION_JSON_VALUE )
80+ @ PostMapping (
81+ path = "/search/sparql" ,
82+ consumes = MediaType .APPLICATION_JSON_VALUE ,
83+ produces = { MediaType .APPLICATION_JSON_VALUE , "application/ld+json" }
84+ )
8085 public void sparqlPost (
81- @ Schema (example = MediaType .APPLICATION_JSON_VALUE )
82- @ RequestHeader (value = HttpHeaders .ACCEPT ) String acceptHeader ,
86+ @ RequestHeader (value = HttpHeaders .ACCEPT , defaultValue = JSON_MEDIA_TYPES ) String acceptHeader ,
8387 @ RequestBody SparqlQuery sparqlQuery ,
8488 HttpServletResponse response
8589 ) throws IOException {
8690 // enforce default accept header for wildcard
87- final String accept = ("*/*" .equals (acceptHeader )) ? MediaType . APPLICATION_JSON_VALUE : acceptHeader ;
91+ final String accept = ("*/*" .equals (acceptHeader )) ? JSON_MEDIA_TYPES : acceptHeader ;
8892 try {
8993 final EvaluateResultHttpResponse result = new EvaluateResultHttpResponse (response );
9094 sparqlQueryEvaluator .evaluate (
0 commit comments