Skip to content

Commit

Permalink
fixes for actuator and swagger ui, application/json must be added to the
Browse files Browse the repository at this point in the history
default cotnent types served by the application
  • Loading branch information
GordeaS authored and GordeaS committed Mar 14, 2024
1 parent 3bc8dc7 commit 09bba09
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 40 deletions.
2 changes: 1 addition & 1 deletion k8s/base/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
image: europeana/set-api
env:
- name: SPRING_CONFIG_NAME
value: "set.common,set.user"
value: "application,set.common,set.user"
- name: SPRING_CONFIG_ADDITIONAL_LOCATION
value: "/opt/app/config/set.user.properties"
ports:
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
<includeOnlyProperty>git.branch</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
Expand Down
16 changes: 1 addition & 15 deletions set-integration-testing/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
</exclusion>
</exclusions>
</dependency>


<!-- Test dependencies -->
<dependency>
<groupId>commons-io</groupId>
Expand Down
19 changes: 3 additions & 16 deletions set-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,30 +135,17 @@

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>


<!-- aspectj /profiling -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>

<!-- swagger -->
<!--
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${version.swagger}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
-->
<!-- spring doc dependencies -->
<dependency>
<groupId>org.springdoc</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;

@Configuration
@OpenAPIDefinition
public class SpringDocConfig {

private final BuildProperties buildProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ public class WebMvcConfig implements WebMvcConfigurer {
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/v2/api-docs").allowedOrigins("*").allowedMethods("GET")
.exposedHeaders(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS)
.allowCredentials(false).maxAge(600L); // in seconds
registry.addMapping("/v3/api-docs").allowedOrigins("*").allowedMethods("GET")
.exposedHeaders(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS)
.allowCredentials(false).maxAge(600L); // in seconds

registry.addMapping("/v3/api-docs/**").allowedOrigins("*").allowedMethods("GET")
.exposedHeaders(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS)
.allowCredentials(false).maxAge(600L); // in seconds

registry.addMapping("/v2/api-docs/**").allowedOrigins("*").allowedMethods("GET")
.exposedHeaders(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS)
.allowCredentials(false).maxAge(600L); // in seconds

registry.addMapping("/actuator/**").allowedOrigins("*").allowedMethods("GET")
.exposedHeaders(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN, HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS)
Expand Down Expand Up @@ -88,8 +89,16 @@ public void configureContentNegotiation(ContentNegotiationConfigurer configurer)
// releases
configurer.favorPathExtension(true);

// use registered extensions instead of defaults
configurer.useRegisteredExtensionsOnly(true);

configurer.mediaTypes(getMediaTypesMapping());


// use application/ld+json if no Content-Type is specified
configurer.defaultContentType(MediaType.valueOf(HttpHeaders.CONTENT_TYPE_JSONLD));
//configurer.defaultContentType(MediaType.valueOf(HttpHeaders.CONTENT_TYPE_JSONLD));
configurer.defaultContentType(MediaType.valueOf(HttpHeaders.CONTENT_TYPE_JSON_UTF8),
MediaType.valueOf(HttpHeaders.CONTENT_TYPE_JSONLD));

configurer.mediaTypes(getMediaTypesMapping());
}
Expand Down
1 change: 0 additions & 1 deletion set-web/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ info.app.description=Europeana User Sets API provides support for creation of Us
org.springframework.boot.logging.LoggingSystem= org.springframework.boot.logging.log4j2.Log4J2LoggingSystem

## management / actuator / swagger
#springfox.documentation.swagger-ui.enabled=true
management.security.enabled=false

management.endpoints.web.exposure.include=health,info
Expand Down

0 comments on commit 09bba09

Please sign in to comment.