Skip to content

Commit 1daf4d9

Browse files
committed
NullPointerException loading Swagger UI since SpringDoc 1.5.6 until the current 1.5.9. Fixes #1171.
1 parent d1ad16c commit 1daf4d9

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/utils/SpringDocDataRestUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,9 @@ private List<String> getIgnoredFields(ResourceMetadata
414414
* @param content the content
415415
*/
416416
public void buildTextUriContent(Content content) {
417-
content.computeIfPresent(RestMediaTypes.TEXT_URI_LIST_VALUE,
418-
(key, value) -> new MediaType().schema(new StringSchema()));
417+
if (content != null)
418+
content.computeIfPresent(RestMediaTypes.TEXT_URI_LIST_VALUE,
419+
(key, value) -> new MediaType().schema(new StringSchema()));
419420
}
420421

421422
}

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app26/PersonRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.util.List;
2727

28+
import org.springframework.data.jpa.repository.Query;
2829
import org.springframework.data.repository.PagingAndSortingRepository;
2930
import org.springframework.data.repository.query.Param;
3031
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@@ -34,4 +35,7 @@ public interface PersonRepository extends PagingAndSortingRepository<Person, Lon
3435

3536
List<Person> findByLastName(@Param("name") String name);
3637

38+
@Query(value = "select 1 from dual", nativeQuery = true)
39+
void testQuery();
40+
3741
}

springdoc-openapi-data-rest/src/test/resources/results/app26.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,22 @@
139139
}
140140
}
141141
},
142+
"/peopleme/search/testQuery": {
143+
"get": {
144+
"tags": [
145+
"person-search-controller"
146+
],
147+
"operationId": "executeSearch-person-get_1",
148+
"responses": {
149+
"200": {
150+
"description": "OK"
151+
},
152+
"404": {
153+
"description": "Not Found"
154+
}
155+
}
156+
}
157+
},
142158
"/peopleme/{id}": {
143159
"get": {
144160
"tags": [

0 commit comments

Comments
 (0)