Skip to content

Commit

Permalink
Reihenfolge Registrierung HttpMessageConverter korritiert
Browse files Browse the repository at this point in the history
  • Loading branch information
oboehm committed Jan 6, 2024
1 parent 3633f62 commit c82d1a3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
16 changes: 8 additions & 8 deletions service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,14 @@
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring6</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.webjars</groupId>-->
<!-- <artifactId>bootstrap</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.webjars</groupId>-->
<!-- <artifactId>jquery</artifactId>-->
<!-- </dependency>-->

<!-- logging -->
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions service/src/main/java/gdv/xport/srv/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void addInterceptors(InterceptorRegistry registry) {
*/
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
// see https://github.com/springdoc/springdoc-openapi/issues/624
// see https://github.com/springdoc/springdoc-openapi/issues/2143
converters.add(new StringHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter());
converters.add(new DatenpaketHttpMessageConverter(MediaType.TEXT_HTML));
converters.add(new DatenpaketHttpMessageConverter(MediaType.TEXT_XML, MediaType.APPLICATION_XML));
converters.add(new DatenpaketHttpMessageConverter(MediaType.TEXT_PLAIN));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Configuration
public class SwaggerConfig {

@Value("${application.version: application.version}")
@Value("${spring.application.version: 7.0}")
private String version;

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import gdv.xport.util.URLReader;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
Expand All @@ -39,7 +40,6 @@
import patterntesting.runtime.log.LogWatch;
import patterntesting.runtime.util.Converter;

import jakarta.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
Expand Down Expand Up @@ -93,7 +93,7 @@ public final class DatenpaketController {
@PostMapping("/v1/Abweichungen")
public @ResponseBody
List<Model> validate(
@Parameter(description = "Datenpaket im GDV-Format (alternativ als Parameter)") @RequestParam(required = false) String text,
@Parameter(description = "Datenpaket im GDV-Format (alternativ als Parameter)") @RequestParam(value = "text", required = false) String text,
HttpServletRequest request) throws IOException {
String body = IOUtils.toString(request.getInputStream(), StandardCharsets.ISO_8859_1);
String content = (StringUtils.isBlank(text)) ? body : text;
Expand All @@ -111,7 +111,7 @@ List<Model> validate(
@Operation(summary = "validiert den eingegebenen Text im GDV-Format und gibt die gefundenen Abweichungen zurueck")
@PostMapping("/v1/Abweichungen/form")
public List<Model> validate(
@Parameter(description = "Eingabe-Formular mit Text im GDV-Format") @RequestParam MultiValueMap map) {
@Parameter(description = "Eingabe-Formular mit Text im GDV-Format") @RequestParam("map") MultiValueMap map) {
String content = Objects.toString(map.getFirst("text"), "");
return validate(content);
}
Expand Down Expand Up @@ -167,7 +167,7 @@ private List<Model> validate(String content) {
example = "http://www.gdv-online.de/vuvm/musterdatei_bestand/musterdatei_041222.txt") @RequestParam("uri") URI uri,
@Parameter(description = "Ausgabe-Format (HTML, XML, JSON, CSV oder TEXT);" +
" normalerweise wird das Format ueber den Accept-Header vorgegeben, kann aber hierueber explizit gesetzt werden.",
example = "JSON") @RequestParam(required = false) String format,
example = "JSON") @RequestParam(value = "format", required = false) String format,
HttpServletRequest request) throws IOException {
String content = readFrom(uri);
return getDatenpaketResponseEntity(format, content, request);
Expand All @@ -190,7 +190,7 @@ private List<Model> validate(String content) {
return service.importDatenpaket(content);
}

private static String readFrom(@RequestParam("uri") URI uri) throws IOException {
private static String readFrom(URI uri) throws IOException {
LogWatch watch = new LogWatch();
LOG.info("Reading Datenpakete from {}...", uri);
URLReader urlReader = new URLReader(uri.toURL());
Expand Down Expand Up @@ -284,12 +284,12 @@ private ResponseEntity<Datenpaket> getDatenpaketResponseEntity(String format, St
@Operation(summary = "dient zum Laden und Anzeigen einer Datei im GDV-Format")
@PostMapping("/v1/Datenpaket/uploaded")
public @ResponseBody Datenpaket uploadDatenpaket (
@RequestParam("file") MultipartFile file) throws IOException {
@RequestParam MultipartFile file) throws IOException {
String text = readFrom(file);
return importDatenpaketFrom(text);
}

private String readFrom(@RequestParam("file") MultipartFile file) throws IOException {
private String readFrom(MultipartFile file) throws IOException {
LogWatch watch = new LogWatch();
LOG.info("Reading Datenpakete from {}...", file);
String text = new String(file.getBytes());
Expand Down
3 changes: 3 additions & 0 deletions service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ spring.profiles.active=default
server.port=2517

springdoc.api-docs.path=/v3/api-docs
springdoc.swagger-ui.url=/v3/api-docs
springdoc.swagger-ui.config-url=/v3/api-docs/swagger-config
springdoc.writer-with-default-pretty-printer=true

server.forward-headers-strategy=framework

0 comments on commit c82d1a3

Please sign in to comment.