Use javax.ws.rs.core.MediaType 28/104928/5
authortobias.pobocik <tobias.pobocik@pantheon.tech>
Thu, 16 Mar 2023 14:07:15 +0000 (15:07 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 28 Mar 2023 08:22:14 +0000 (10:22 +0200)
sal-rest-docgen depends on JAX-RS, hence we can use its constants for
the (constant) 'produces' field.

JIRA: NETCONF-979
Change-Id: I0ed1793cedcf0653e1d5b5cf4f1f6267ce144a46
Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/BaseYangSwaggerGenerator.java

index 5881b2d12199f92aec455e528de724c7bd972ff0..63ad10ae974c5a67d280e675b51139109c86c770 100644 (file)
@@ -28,7 +28,6 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Range;
 import java.io.IOException;
 import java.time.format.DateTimeParseException;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -40,6 +39,7 @@ import java.util.Optional;
 import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
+import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriInfo;
 import org.opendaylight.mdsal.dom.api.DOMSchemaService;
 import org.opendaylight.netconf.sal.rest.doc.impl.ApiDocServiceImpl.OAversion;
@@ -75,6 +75,7 @@ public abstract class BaseYangSwaggerGenerator {
     private static final String SWAGGER_VERSION = "2.0";
     private static final String OPEN_API_VERSION = "3.0.3";
     private static final ObjectMapper MAPPER = new ObjectMapper();
+    private static final List<String> PRODUCES = List.of(MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON);
 
     private final DefinitionGenerator jsonConverter = new DefinitionGenerator();
     private final DOMSchemaService schemaService;
@@ -331,7 +332,7 @@ public abstract class BaseYangSwaggerGenerator {
         doc.setSchemes(ImmutableList.of(schema));
         doc.setHost(host);
         doc.setBasePath(basePath);
-        doc.setProduces(Arrays.asList("application/xml", "application/json"));
+        doc.setProduces(PRODUCES);
         return doc;
     }