@@ -179,30 +179,31 @@ public void checkOperationIdsSet() {
179
179
@ Test
180
180
public void checkRepresentationParamExists () {
181
181
SwaggerSpecificationCreator ssc = new SwaggerSpecificationCreator ();
182
- String json = ssc .getJSON ();
182
+ ssc .getJSON ();
183
183
OpenAPI spec = ssc .getOpenAPI ();
184
184
185
185
Assert .assertNotNull ("SwaggerSpecificationCreator should not be null" , ssc );
186
- Assert .assertNotNull ("JSON should not be null" , json );
187
186
Assert .assertNotNull ("OpenAPI spec should not be null" , spec );
188
187
Assert .assertNotNull ("Paths in OpenAPI spec should not be null" , spec .getPaths ());
189
188
190
- // If we get past the assertion, continue with the original test logic
191
- for (PathItem p : spec .getPaths ().values ()) {
192
- Assert .assertNotNull ("PathItem should not be null" , p );
193
- for (Operation o : p .readOperations ()) {
194
- if (o != null ) {
195
- Assert .assertTrue ("Ensure each GET operation has the 'v' query parameter" ,
196
- operationHasRepresentationParam (o ));
197
- }
189
+ spec .getPaths ().forEach ((path , pathItem ) -> {
190
+ Operation getOperation = pathItem .getGet ();
191
+ if (getOperation != null ) {
192
+ Assert .assertTrue (
193
+ String .format ("GET operation at path %s must have 'v' query parameter" , path ),
194
+ operationHasRepresentationParam (getOperation )
195
+ );
198
196
}
199
- }
197
+ });
200
198
}
201
199
202
200
private boolean operationHasRepresentationParam (Operation operation ) {
203
- return operation .getParameters () != null &&
204
- operation .getParameters ().stream ()
205
- .anyMatch (param -> "v" .equals (param .getName ()) && "query" .equals (param .getIn ()));
201
+ if (operation .getParameters () == null ) {
202
+ return false ;
203
+ }
204
+
205
+ return operation .getParameters ().stream ()
206
+ .anyMatch (param -> "v" .equals (param .getName ()));
206
207
}
207
208
208
209
// make sure each operation that supports paging has the limit and startIndex parameters
0 commit comments