Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception logged when generating schema for delete method of Spring Data repository #2869

Closed
clementdenis opened this issue Jan 21, 2025 · 0 comments

Comments

@clementdenis
Copy link

Describe the bug

When generating OpenAPI schema for a Spring Data repository with an exposed delete method (named deleteItemResource in default repository), an exception is logged as WARN.

This is caused by the return value of this method being null (in org.springdoc.core.data.DataRestResponseService#buildEntityResponse) and passed to org.springdoc.core.converters.SortOpenAPIConverter#resolve, that does not handle this case.

It does not prevent the schema to be generated, but this is annoying (especially when caching is disabled for development, as it will be logged on every page reload).

This happens both with OpenAPI 3.0 and 3.1.

2025-01-21T10:38:30.493+01:00  WARN 24396 --- [test-springdoc] [nio-8080-exec-5] o.s.c.utils.SpringDocAnnotationsUtils    : Graceful exception occurred

java.lang.IllegalArgumentException: argument "t" is null
	at com.fasterxml.jackson.databind.ObjectMapper._assertNotNull(ObjectMapper.java:5072) ~[jackson-databind-2.18.2.jar:2.18.2]
	at com.fasterxml.jackson.databind.ObjectMapper.constructType(ObjectMapper.java:2252) ~[jackson-databind-2.18.2.jar:2.18.2]
	at org.springdoc.core.converters.SortOpenAPIConverter.resolve(SortOpenAPIConverter.java:82) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at io.swagger.v3.core.converter.ModelConverterContextImpl.resolve(ModelConverterContextImpl.java:97) ~[swagger-core-jakarta-2.2.27.jar:2.2.27]
	at io.swagger.v3.core.converter.ModelConverters.resolveAsResolvedSchema(ModelConverters.java:192) ~[swagger-core-jakarta-2.2.27.jar:2.2.27]
	at org.springdoc.core.utils.SpringDocAnnotationsUtils.extractSchema(SpringDocAnnotationsUtils.java:136) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.service.GenericResponseService.calculateSchema(GenericResponseService.java:563) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.service.GenericResponseService.buildContent(GenericResponseService.java:541) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestResponseService.buildEntityResponse(DataRestResponseService.java:153) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestOperationService.buildEntityOperation(DataRestOperationService.java:166) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestOperationService.buildOperation(DataRestOperationService.java:136) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestRouterOperationService.buildRouterOperation(DataRestRouterOperationService.java:292) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestRouterOperationService.buildRouterOperation(DataRestRouterOperationService.java:231) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestRouterOperationService.buildRouterOperationList(DataRestRouterOperationService.java:183) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.data.DataRestRouterOperationService.buildEntityRouterOperationList(DataRestRouterOperationService.java:130) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.providers.SpringRepositoryRestResourceProvider.findControllers(SpringRepositoryRestResourceProvider.java:382) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.core.providers.SpringRepositoryRestResourceProvider.getRouterOperations(SpringRepositoryRestResourceProvider.java:214) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.webmvc.api.OpenApiResource.lambda$getPaths$1(OpenApiResource.java:157) ~[springdoc-openapi-starter-webmvc-api-2.8.3.jar:2.8.3]
	at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[na:na]
	at org.springdoc.webmvc.api.OpenApiResource.lambda$getPaths$2(OpenApiResource.java:156) ~[springdoc-openapi-starter-webmvc-api-2.8.3.jar:2.8.3]
	at java.base/java.util.Optional.ifPresent(Optional.java:178) ~[na:na]
	at org.springdoc.webmvc.api.OpenApiResource.getPaths(OpenApiResource.java:152) ~[springdoc-openapi-starter-webmvc-api-2.8.3.jar:2.8.3]
	at org.springdoc.api.AbstractOpenApiResource.getOpenApi(AbstractOpenApiResource.java:370) ~[springdoc-openapi-starter-common-2.8.3.jar:2.8.3]
	at org.springdoc.webmvc.api.OpenApiResource.openapiJson(OpenApiResource.java:127) ~[springdoc-openapi-starter-webmvc-api-2.8.3.jar:2.8.3]
	at org.springdoc.webmvc.api.OpenApiWebMvcResource.openapiJson(OpenApiWebMvcResource.java:117) ~[springdoc-openapi-starter-webmvc-api-2.8.3.jar:2.8.3]

To Reproduce
Steps to reproduce the behavior:

  • Create a Spring Boot project with Spring Data JPA and REST, add SpringDoc dependency
  • Create an Entity with an id, create a repository for this entity
  • Launch the application and access Swagger UI

=> the exception is logged

  • What version of spring-boot you are using? 3.4.1
  • What modules and versions of springdoc-openapi are you using? 2.8.3

Expected behavior

No exception is logged

Additional context

This can be worked around by setting logger level at ERROR for this class:

logging:
  level:
    org.springdoc.core.utils.SpringDocAnnotationsUtils: ERROR
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

No branches or pull requests

1 participant