@Test public void shouldFindCyclicSelfReferencesInParameters() { final Oas20Document openApiDoc = new Oas20Document(); final Oas20PathItem pathItem = new Oas20PathItem("/api"); final Oas20Operation operation = new Oas20Operation("post"); final Oas20Parameter parameter = new Oas20Parameter(); parameter.$ref = "#/definitions/A"; operation.parameters = new ArrayList<>(); operation.parameters.add(parameter); pathItem.post = operation; openApiDoc.paths = openApiDoc.createPaths(); openApiDoc.paths.addPathItem("/api", pathItem); Oas20SchemaDefinition schemaDefinition = new Oas20SchemaDefinition("A"); schemaDefinition.type = "object"; Oas20Schema propertySchema = new Oas20Schema(); propertySchema.$ref = "#/definitions/A"; schemaDefinition.properties = new HashMap<>(); schemaDefinition.properties.put("cyclic", propertySchema); openApiDoc.definitions = openApiDoc.createDefinitions(); openApiDoc.definitions.addDefinition("A", schemaDefinition); assertThat(CyclicValidationCheck.hasCyclicReferences(getSchemaDefinitions(openApiDoc))).isTrue(); }
static boolean hasCyclicReferences(final Map<String, ? extends OasSchema> schemaDefinitions) { if (schemaDefinitions.isEmpty()) { return false; } final Map<String, Set<String>> references = collectReferences(schemaDefinitions); return isCyclic(references); }
CyclicValidationCheck { static boolean hasCyclicReferences(final Map<String, ? extends OasSchema> schemaDefinitions) { if (schemaDefinitions.isEmpty()) { return false; } final Map<String, Set<String>> references = collectReferences(schemaDefinitions); return isCyclic(references); } }
CyclicValidationCheck { static boolean hasCyclicReferences(final Map<String, ? extends OasSchema> schemaDefinitions) { if (schemaDefinitions.isEmpty()) { return false; } final Map<String, Set<String>> references = collectReferences(schemaDefinitions); return isCyclic(references); } private  CyclicValidationCheck(); }
CyclicValidationCheck { static boolean hasCyclicReferences(final Map<String, ? extends OasSchema> schemaDefinitions) { if (schemaDefinitions.isEmpty()) { return false; } final Map<String, Set<String>> references = collectReferences(schemaDefinitions); return isCyclic(references); } private  CyclicValidationCheck();  }
CyclicValidationCheck { static boolean hasCyclicReferences(final Map<String, ? extends OasSchema> schemaDefinitions) { if (schemaDefinitions.isEmpty()) { return false; } final Map<String, Set<String>> references = collectReferences(schemaDefinitions); return isCyclic(references); } private  CyclicValidationCheck();   }