@Test public void shouldValidateOperationUniqueness() { final Oas20Document openApiDoc = new Oas20Document(); final Oas20PathItem pathItem = new Oas20PathItem("/path"); Oas20Operation get = new Oas20Operation("get"); get.operationId = "o1"; pathItem.get = get; Oas20Operation post = new Oas20Operation("post"); post.operationId = "o2"; pathItem.post = post; openApiDoc.paths = openApiDoc.createPaths(); openApiDoc.paths.addPathItem("/path", pathItem); final Oas20PathItem otherPathItem = new Oas20PathItem("/other"); Oas20Operation patch = new Oas20Operation("patch"); patch.operationId = "o2"; otherPathItem.patch = patch; Oas20Operation put = new Oas20Operation("put"); put.operationId = "o3"; otherPathItem.put = put; openApiDoc.paths.addPathItem("/other", otherPathItem); final Oas20PathItem morePathItem = new Oas20PathItem("/more"); Oas20Operation options = new Oas20Operation("options"); options.operationId = "o4"; morePathItem.options = options; Oas20Operation delete = new Oas20Operation("delete"); delete.operationId = "o3"; morePathItem.delete = delete; openApiDoc.paths.addPathItem("/more", morePathItem); final OpenApiModelInfo info = new OpenApiModelInfo.Builder().model(openApiDoc).build(); final OpenApiModelInfo validated = RULES.validateUniqueOperationIds(info); final List<Violation> warnings = validated.getWarnings(); assertThat(warnings).hasSize(1); final Violation nonUniqueWarning = warnings.get(0); assertThat(nonUniqueWarning.error()).isEqualTo("non-unique-operation-ids"); assertThat(nonUniqueWarning.property()).isNull(); assertThat(nonUniqueWarning.message()).isEqualTo("Found operations with non unique operationIds: o2, o3"); }
public static Oas20ValidationRules get(final APIValidationContext context) { return new Oas20ValidationRules(context); }
Oas20ValidationRules extends OpenApiValidationRules<Oas20Response, Oas20SecurityScheme, Oas20SchemaDefinition> { public static Oas20ValidationRules get(final APIValidationContext context) { return new Oas20ValidationRules(context); } }
Oas20ValidationRules extends OpenApiValidationRules<Oas20Response, Oas20SecurityScheme, Oas20SchemaDefinition> { public static Oas20ValidationRules get(final APIValidationContext context) { return new Oas20ValidationRules(context); } Oas20ValidationRules(APIValidationContext context); }
Oas20ValidationRules extends OpenApiValidationRules<Oas20Response, Oas20SecurityScheme, Oas20SchemaDefinition> { public static Oas20ValidationRules get(final APIValidationContext context) { return new Oas20ValidationRules(context); } Oas20ValidationRules(APIValidationContext context); static Oas20ValidationRules get(final APIValidationContext context); }
Oas20ValidationRules extends OpenApiValidationRules<Oas20Response, Oas20SecurityScheme, Oas20SchemaDefinition> { public static Oas20ValidationRules get(final APIValidationContext context) { return new Oas20ValidationRules(context); } Oas20ValidationRules(APIValidationContext context); static Oas20ValidationRules get(final APIValidationContext context);  }