diff --git a/examples/http/requests.http b/examples/http/requests.http new file mode 100644 index 00000000..0b18407f --- /dev/null +++ b/examples/http/requests.http @@ -0,0 +1,16 @@ +### POST request +POST http://localhost:8080/ +Content-Type: application/json + +{ + "name": 1 +} + +### GET request +GET http://localhost:8080/?fromDate=2020-01-01 + +### GET request (with body) +GET http://localhost:8080/?fromDate=2020-01-01 +Content-Type: application/json + +{} diff --git a/examples/openapi.yaml b/examples/openapi.yaml index b67f9983..44a82b31 100644 --- a/examples/openapi.yaml +++ b/examples/openapi.yaml @@ -35,7 +35,7 @@ paths: description: Update index operationId: postIndex requestBody: - required: false + required: true content: application/json: schema: diff --git a/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/MultiReadContentCachingRequestWrapper.java b/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/MultiReadContentCachingRequestWrapper.java index b9ba01b6..850d1f9f 100644 --- a/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/MultiReadContentCachingRequestWrapper.java +++ b/spring-boot-starter/spring-boot-starter-web/src/main/java/com/getyourguide/openapi/validation/filter/MultiReadContentCachingRequestWrapper.java @@ -21,12 +21,12 @@ public MultiReadContentCachingRequestWrapper(HttpServletRequest request, int con @Override public ServletInputStream getInputStream() throws IOException { - var inputStream = super.getInputStream(); - if (inputStream.isFinished()) { - return new CachedServletInputStream(getContentAsByteArray()); + var cachedContent = getContentAsByteArray(); + if (cachedContent.length > 0) { + return new CachedServletInputStream(cachedContent); } - return inputStream; + return super.getInputStream(); } @Override