@Test public void shouldValidateMissingResponseBodySchema() { final Oas30Document openApiDoc = new Oas30Document(); final Oas30PathItem pathItem = new Oas30PathItem("/path"); Oas30Operation get = new Oas30Operation("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; Oas30Operation post = new Oas30Operation("post"); post.operationId = "o2"; final Oas30Parameter headerParameter = new Oas30Parameter(); headerParameter.in = "header"; post.parameters = Collections.singletonList(headerParameter); post.requestBody = post.createRequestBody(); Oas30Schema bodySchema = new Oas30Schema(); bodySchema.addProperty("foo", new Oas30Schema()); Oas30MediaType requestBody = post.requestBody.createMediaType("application/json"); requestBody.schema = bodySchema; post.requestBody.content = Collections.singletonMap("application/json", requestBody); 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 reportedWarning = warnings.get(0); assertThat(reportedWarning.error()).isEqualTo("missing-response-schema"); assertThat(reportedWarning.property()).isEmpty(); assertThat(reportedWarning.message()).isEqualTo("Operation GET /path does not provide a response schema for code 200"); }
public static Oas30ValidationRules get(final APIValidationContext context) { return new Oas30ValidationRules(context); }
Oas30ValidationRules extends OpenApiValidationRules<Oas30Response, Oas30SecurityScheme, Oas30SchemaDefinition> { public static Oas30ValidationRules get(final APIValidationContext context) { return new Oas30ValidationRules(context); } }
Oas30ValidationRules extends OpenApiValidationRules<Oas30Response, Oas30SecurityScheme, Oas30SchemaDefinition> { public static Oas30ValidationRules get(final APIValidationContext context) { return new Oas30ValidationRules(context); } Oas30ValidationRules(APIValidationContext context); }
Oas30ValidationRules extends OpenApiValidationRules<Oas30Response, Oas30SecurityScheme, Oas30SchemaDefinition> { public static Oas30ValidationRules get(final APIValidationContext context) { return new Oas30ValidationRules(context); } Oas30ValidationRules(APIValidationContext context); static Oas30ValidationRules get(final APIValidationContext context); }
Oas30ValidationRules extends OpenApiValidationRules<Oas30Response, Oas30SecurityScheme, Oas30SchemaDefinition> { public static Oas30ValidationRules get(final APIValidationContext context) { return new Oas30ValidationRules(context); } Oas30ValidationRules(APIValidationContext context); static Oas30ValidationRules get(final APIValidationContext context);  }