Skip to content

Remove all non null values that are returned#813

Merged
aaronzi merged 6 commits into
eclipse-basyx:mainfrom
geso02:no-null-values-from-backend
Aug 13, 2025
Merged

Remove all non null values that are returned#813
aaronzi merged 6 commits into
eclipse-basyx:mainfrom
geso02:no-null-values-from-backend

Conversation

@geso02

@geso02 geso02 commented Aug 11, 2025

Copy link
Copy Markdown
Contributor

Closes #630

Description:
This pull request configures the Jackson ObjectMapper to exclude null values during JSON serialization. As a result, API responses no longer include fields with null values, leading to cleaner and more efficient payloads.

Changes:

Configured Jackson2ObjectMapperBuilder to omit null properties

API responses are now free of null fields

To resolve conflicts with springdoc-openapi-ui, the redundant @EnableWebMvc annotation was removed, as Spring Boot automatically configures MVC when using spring-boot-starter-web.

@geso02 geso02 closed this Aug 11, 2025
@geso02 geso02 reopened this Aug 11, 2025
@geso02 geso02 closed this Aug 11, 2025
@geso02 geso02 reopened this Aug 11, 2025
@geso02 geso02 marked this pull request as draft August 11, 2025 19:18
@geso02 geso02 marked this pull request as ready for review August 11, 2025 19:23
@aaronzi aaronzi requested a review from Copilot August 13, 2025 09:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request configures Jackson JSON serialization to exclude null values from API responses and resolves conflicts with springdoc-openapi-ui by removing redundant @EnableWebMvc annotations.

  • Configured Jackson ObjectMapper to omit null properties during serialization
  • Removed @EnableWebMvc annotations from RestConfiguration classes
  • Added WebMvcConfigurer implementations to register custom Jackson message converters

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
basyx.submodelregistry/.../WebMvcConfig.java New configuration class to register custom Jackson message converter
basyx.submodelregistry/.../RestConfiguration.java Removed @EnableWebMvc annotation to resolve springdoc conflicts
basyx.aasregistry/.../WebMvcConfig.java New configuration class to register custom Jackson message converter
basyx.aasregistry/.../RestConfiguration.java Removed @EnableWebMvc annotation and import to resolve springdoc conflicts

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

}

@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {

Copilot AI Aug 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation replaces all default message converters by adding only the custom converter. Consider using extendMessageConverters() instead to preserve default converters while adding the custom one, or clear and re-add all necessary converters explicitly.

Suggested change
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {

Copilot uses AI. Check for mistakes.
@Component
public class WebMvcConfig implements WebMvcConfigurer {

private MappingJackson2HttpMessageConverter converter;

Copilot AI Aug 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field should be declared as final since it's only assigned in the constructor and never modified afterwards.

Suggested change
private MappingJackson2HttpMessageConverter converter;
private final MappingJackson2HttpMessageConverter converter;

Copilot uses AI. Check for mistakes.
@Component
public class WebMvcConfig implements WebMvcConfigurer {

private MappingJackson2HttpMessageConverter converter;

Copilot AI Aug 13, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field should be declared as final since it's only assigned in the constructor and never modified afterwards.

Suggested change
private MappingJackson2HttpMessageConverter converter;
private final MappingJackson2HttpMessageConverter converter;

Copilot uses AI. Check for mistakes.
geso02 and others added 3 commits August 13, 2025 14:00
…/java/org/eclipse/digitaltwin/basyx/submodelregistry/service/configuration/WebMvcConfig.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@geso02 geso02 marked this pull request as draft August 13, 2025 12:18
- Removed custom MappingJackson2HttpMessageConverter bean
- Removed unnecessary WebMvcConfigurer
- Updated ObjectMapper bean to use existing Jackson2ObjectMapperBuilder with:
  - NON_NULL serialization inclusion
  - Disabled WRITE_DATES_AS_TIMESTAMPS
- Root cause: @EnableWebMvc was overriding Spring Boot defaults, breaking message converters and static resources
- Now relies on Spring Boot auto-configuration for converters and static resources

refs eclipse-basyx#640
@geso02 geso02 marked this pull request as ready for review August 13, 2025 15:08
@aaronzi aaronzi merged commit 1a986df into eclipse-basyx:main Aug 13, 2025
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] empty optional values are null on aas-registry

3 participants