Skip to content

Commit ec28d62

Browse files
authored
Fix #21921 by marking required path parameters as @NotNull (#21951)
1 parent 0edcc9d commit ec28d62

File tree

142 files changed

+402
-402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+402
-402
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{! PathParam is always required, no @NotNull necessary }}{{>beanValidationCore}}
1+
{{! PathParam is always required }}@NotNull {{>beanValidationCore}}

samples/client/petstore/spring-cloud-date-time/src/main/java/org/openapitools/api/DefaultApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public interface DefaultApi {
5454
)
5555

5656
ResponseEntity<Void> get(
57-
@ApiParam(value = "A date path parameter", required = true, defaultValue = "1972-01-01") @PathVariable("date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
57+
@NotNull @ApiParam(value = "A date path parameter", required = true, defaultValue = "1972-01-01") @PathVariable("date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
5858
@NotNull @ApiParam(value = "A date-time query parameter", required = true, defaultValue = "1973-12-19T03:39:57-08:00") @Valid @RequestParam(value = "dateTime", required = true, defaultValue = "1973-12-19T03:39:57-08:00") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime dateTime,
5959
@NotNull @ApiParam(value = "A date header parameter", required = true, defaultValue = "1974-01-01") @RequestHeader(value = "X-Order-Date", required = true, defaultValue = "1974-01-01") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate xOrderDate,
6060
@ApiParam(value = "A date cookie parameter", defaultValue = "1975-01-01") @CookieValue(name = "loginDate", required = false, defaultValue = "1975-01-01") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate loginDate
@@ -85,7 +85,7 @@ ResponseEntity<Void> get(
8585
)
8686

8787
ResponseEntity<Void> updatePetWithForm(
88-
@ApiParam(value = "A date path parameter", required = true, defaultValue = "1970-01-01") @PathVariable("date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
88+
@NotNull @ApiParam(value = "A date path parameter", required = true, defaultValue = "1970-01-01") @PathVariable("date") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) LocalDate date,
8989
@ApiParam(value = "Updated last visit timestamp", defaultValue = "1971-12-19T03:39:57-08:00") @Valid @RequestParam(value = "visitDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) OffsetDateTime visitDate
9090
);
9191

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/api/PetApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ResponseEntity<Void> addPet(
9898
)
9999

100100
ResponseEntity<Void> deletePet(
101-
@Parameter(name = "petId", description = "Pet id to delete", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
101+
@NotNull @Parameter(name = "petId", description = "Pet id to delete", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
102102
@Parameter(name = "api_key", description = "", in = ParameterIn.HEADER) @RequestHeader(value = "api_key", required = false) @Nullable String apiKey
103103
);
104104

@@ -212,7 +212,7 @@ ResponseEntity<List<Pet>> findPetsByTags(
212212
)
213213

214214
ResponseEntity<Pet> getPetById(
215-
@Parameter(name = "petId", deprecated = true, description = "ID of pet to return", required = true, in = ParameterIn.PATH) @PathVariable("petId") @Deprecated Long petId
215+
@NotNull @Parameter(name = "petId", deprecated = true, description = "ID of pet to return", required = true, in = ParameterIn.PATH) @PathVariable("petId") @Deprecated Long petId
216216
);
217217

218218

@@ -280,7 +280,7 @@ ResponseEntity<Void> updatePet(
280280
)
281281

282282
ResponseEntity<Void> updatePetWithForm(
283-
@Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
283+
@NotNull @Parameter(name = "petId", description = "ID of pet that needs to be updated", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
284284
@Parameter(name = "name", description = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
285285
@Parameter(name = "status", description = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
286286
);
@@ -318,7 +318,7 @@ ResponseEntity<Void> updatePetWithForm(
318318
)
319319

320320
ResponseEntity<ModelApiResponse> uploadFile(
321-
@Parameter(name = "petId", description = "ID of pet to update", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
321+
@NotNull @Parameter(name = "petId", description = "ID of pet to update", required = true, in = ParameterIn.PATH) @PathVariable("petId") Long petId,
322322
@Parameter(name = "additionalMetadata", description = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
323323
@Parameter(name = "file", description = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
324324
);

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/api/StoreApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public interface StoreApi {
6464
)
6565

6666
ResponseEntity<Void> deleteOrder(
67-
@Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("orderId") String orderId
67+
@NotNull @Parameter(name = "orderId", description = "ID of the order that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("orderId") String orderId
6868
);
6969

7070

@@ -131,7 +131,7 @@ ResponseEntity<Map<String, Integer>> getInventory(
131131
)
132132

133133
ResponseEntity<Order> getOrderById(
134-
@Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, in = ParameterIn.PATH) @PathVariable("orderId") Long orderId
134+
@NotNull @Min(1L) @Max(5L) @Parameter(name = "orderId", description = "ID of pet that needs to be fetched", required = true, in = ParameterIn.PATH) @PathVariable("orderId") Long orderId
135135
);
136136

137137

samples/client/petstore/spring-cloud-deprecated/src/main/java/org/openapitools/api/UserApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ ResponseEntity<Void> createUsersWithListInput(
160160
)
161161

162162
ResponseEntity<Void> deleteUser(
163-
@Parameter(name = "username", description = "The name that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
163+
@NotNull @Parameter(name = "username", description = "The name that needs to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
164164
);
165165

166166

@@ -195,7 +195,7 @@ ResponseEntity<Void> deleteUser(
195195
)
196196

197197
ResponseEntity<User> getUserByName(
198-
@Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
198+
@NotNull @Parameter(name = "username", description = "The name that needs to be fetched. Use user1 for testing.", required = true, in = ParameterIn.PATH) @PathVariable("username") String username
199199
);
200200

201201

@@ -293,7 +293,7 @@ ResponseEntity<Void> logoutUser(
293293
)
294294

295295
ResponseEntity<Void> updateUser(
296-
@Parameter(name = "username", description = "name that need to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username,
296+
@NotNull @Parameter(name = "username", description = "name that need to be deleted", required = true, in = ParameterIn.PATH) @PathVariable("username") String username,
297297
@Parameter(name = "User", description = "Updated user object", required = true) @Valid @RequestBody User user
298298
);
299299

samples/client/petstore/spring-cloud-feign-without-url/src/main/java/org/openapitools/api/PetApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ ResponseEntity<Pet> addPet(
9797
)
9898

9999
ResponseEntity<Void> deletePet(
100-
@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId,
100+
@NotNull @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId,
101101
@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) @Nullable String apiKey
102102
);
103103

@@ -210,7 +210,7 @@ ResponseEntity<List<Pet>> findPetsByTags(
210210
)
211211

212212
ResponseEntity<Pet> getPetById(
213-
@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId
213+
@NotNull @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId
214214
);
215215

216216

@@ -290,7 +290,7 @@ ResponseEntity<Pet> updatePet(
290290
)
291291

292292
ResponseEntity<Void> updatePetWithForm(
293-
@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId,
293+
@NotNull @ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId,
294294
@ApiParam(value = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
295295
@ApiParam(value = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
296296
);
@@ -330,7 +330,7 @@ ResponseEntity<Void> updatePetWithForm(
330330
)
331331

332332
ResponseEntity<ModelApiResponse> uploadFile(
333-
@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
333+
@NotNull @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
334334
@ApiParam(value = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
335335
@ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
336336
);

samples/client/petstore/spring-cloud-feign-without-url/src/main/java/org/openapitools/api/StoreApi.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface StoreApi {
5353
)
5454

5555
ResponseEntity<Void> deleteOrder(
56-
@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId
56+
@NotNull @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId
5757
);
5858

5959

@@ -118,7 +118,7 @@ ResponseEntity<Map<String, Integer>> getInventory(
118118
)
119119

120120
ResponseEntity<Order> getOrderById(
121-
@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId
121+
@NotNull @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId
122122
);
123123

124124

samples/client/petstore/spring-cloud-feign-without-url/src/main/java/org/openapitools/api/UserApi.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ResponseEntity<Void> createUsersWithListInput(
149149
)
150150

151151
ResponseEntity<Void> deleteUser(
152-
@ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username
152+
@NotNull @ApiParam(value = "The name that needs to be deleted", required = true) @PathVariable("username") String username
153153
);
154154

155155

@@ -182,7 +182,7 @@ ResponseEntity<Void> deleteUser(
182182
)
183183

184184
ResponseEntity<User> getUserByName(
185-
@ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username
185+
@NotNull @ApiParam(value = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username
186186
);
187187

188188

@@ -278,7 +278,7 @@ ResponseEntity<Void> logoutUser(
278278
)
279279

280280
ResponseEntity<Void> updateUser(
281-
@ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username,
281+
@NotNull @ApiParam(value = "name that need to be deleted", required = true) @PathVariable("username") String username,
282282
@ApiParam(value = "Updated user object", required = true) @Valid @RequestBody User user
283283
);
284284

samples/client/petstore/spring-cloud-tags/src/main/java/org/openapitools/api/PetController.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ResponseEntity<Void> addPet(
9393
)
9494

9595
ResponseEntity<Void> deletePet(
96-
@ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId,
96+
@NotNull @ApiParam(value = "Pet id to delete", required = true) @PathVariable("petId") Long petId,
9797
@ApiParam(value = "") @RequestHeader(value = "api_key", required = false) @Nullable String apiKey
9898
);
9999

@@ -210,7 +210,7 @@ ResponseEntity<List<Pet>> findPetsByTags(
210210
)
211211

212212
ResponseEntity<Pet> getPetById(
213-
@ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId
213+
@NotNull @ApiParam(value = "ID of pet to return", required = true) @PathVariable("petId") Long petId
214214
);
215215

216216

@@ -282,7 +282,7 @@ ResponseEntity<Void> updatePet(
282282
)
283283

284284
ResponseEntity<Void> updatePetWithForm(
285-
@ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId,
285+
@NotNull @ApiParam(value = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId,
286286
@ApiParam(value = "Updated name of the pet") @Valid @RequestParam(value = "name", required = false) String name,
287287
@ApiParam(value = "Updated status of the pet") @Valid @RequestParam(value = "status", required = false) String status
288288
);
@@ -321,7 +321,7 @@ ResponseEntity<Void> updatePetWithForm(
321321
)
322322

323323
ResponseEntity<ModelApiResponse> uploadFile(
324-
@ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
324+
@NotNull @ApiParam(value = "ID of pet to update", required = true) @PathVariable("petId") Long petId,
325325
@ApiParam(value = "Additional data to pass to server") @Valid @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata,
326326
@ApiParam(value = "file to upload") @RequestPart(value = "file", required = false) MultipartFile file
327327
);

samples/client/petstore/spring-cloud-tags/src/main/java/org/openapitools/api/StoreController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface StoreController {
5353
)
5454

5555
ResponseEntity<Void> deleteOrder(
56-
@ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId
56+
@NotNull @ApiParam(value = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId
5757
);
5858

5959

@@ -118,7 +118,7 @@ ResponseEntity<Map<String, Integer>> getInventory(
118118
)
119119

120120
ResponseEntity<Order> getOrderById(
121-
@Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId
121+
@NotNull @Min(1L) @Max(5L) @ApiParam(value = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId
122122
);
123123

124124

0 commit comments

Comments
 (0)