@Test public void shouldValidateMissingResponseBodySchema() { final Oas20Document openApiDoc = new Oas20Document(); final Oas20PathItem pathItem = new Oas20PathItem("/path"); Oas20Operation get = new Oas20Operation("get"); get.operationId = "o1"; get.responses = get.createResponses(); get.responses.addResponse("404", get.responses.createResponse("404")); get.responses.addResponse("200", get.responses.createResponse("200")); pathItem.get = get; Oas20Operation post = new Oas20Operation("post"); post.operationId = "o2"; final Oas20Parameter headerParameter = new Oas20Parameter(); headerParameter.in = "header"; final Oas20Parameter bodyParameter = new Oas20Parameter(); bodyParameter.in = "body"; Oas20Schema bodySchema = new Oas20Schema(); bodySchema.addProperty("foo", new Oas20Schema()); bodyParameter.schema = bodySchema; post.parameters = Arrays.asList(headerParameter, bodyParameter); pathItem.post = post; openApiDoc.paths = openApiDoc.createPaths(); openApiDoc.paths.addPathItem("/path", pathItem); final OpenApiModelInfo info = new OpenApiModelInfo.Builder().model(openApiDoc).build(); final OpenApiModelInfo validated = RULES.validateRequestResponseBodySchemas(info); final List<Violation> warnings = validated.getWarnings(); assertThat(warnings).hasSize(1); final Violation nonUniqueWarning = warnings.get(0); assertThat(nonUniqueWarning.error()).isEqualTo("missing-response-schema"); assertThat(nonUniqueWarning.property()).isEmpty(); assertThat(nonUniqueWarning.message()).isEqualTo("Operation GET /path does not provide a response schema for code 200"); }
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);  }