@@ -179,30 +179,31 @@ public void checkOperationIdsSet() {
179179 @ Test
180180 public void checkRepresentationParamExists () {
181181 SwaggerSpecificationCreator ssc = new SwaggerSpecificationCreator ();
182- String json = ssc .getJSON ();
182+ ssc .getJSON ();
183183 OpenAPI spec = ssc .getOpenAPI ();
184184
185185 Assert .assertNotNull ("SwaggerSpecificationCreator should not be null" , ssc );
186- Assert .assertNotNull ("JSON should not be null" , json );
187186 Assert .assertNotNull ("OpenAPI spec should not be null" , spec );
188187 Assert .assertNotNull ("Paths in OpenAPI spec should not be null" , spec .getPaths ());
189188
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+ );
198196 }
199- }
197+ });
200198 }
201199
202200 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 ()));
206207 }
207208
208209 // make sure each operation that supports paging has the limit and startIndex parameters
0 commit comments