-
Notifications
You must be signed in to change notification settings - Fork 537
Closed
Description
From the OpenAPI spec for MediaType:
encoding: A map between a property name and its encoding information. The key, being the property name, MUST exist in the schema as a property.
It is an error if the encoding map contains a key that is not defined as a property name in the content (object) schema. But this error is not recognized. The following test fails because it doesn't report the encoding for non-existent property "Z" as an error.
@Test
public void testEncodingNotApplicable() {
String json =
"{"
+ " \"openapi\": \"3.0.0\","
+ " \"info\": {"
+ " \"title\": \"Encodings\","
+ " \"version\": \"0.0.0\""
+ " },"
+ " \"paths\": {"
+ " \"/resource\": {"
+ " \"post\": {"
+ " \"requestBody\": {"
+ " \"content\": {"
+ " \"multipart/form-data\": {"
+ " \"schema\": {"
+ " \"type\": \"object\","
+ " \"properties\": {"
+ " \"X\": {"
+ " \"type\": \"integer\""
+ " },"
+ " \"Y\": {"
+ " \"type\": \"integer\""
+ " }"
+ " }"
+ " },"
+ " \"encoding\": {"
+ " \"Z\": {"
+ " \"contentType\": \"application/json\""
+ " }"
+ " }"
+ " }"
+ " }"
+ " },"
+ " \"responses\": {"
+ " \"default\": {"
+ " \"description\": \"None\""
+ " }"
+ " }"
+ " }"
+ " }"
+ " }"
+ "}"
;
OpenAPIV3Parser parser = new OpenAPIV3Parser();
SwaggerParseResult result = parser.readContents(json, null, null);
assertEquals( result.getMessages().size(), 1, "Error messages");
}
Metadata
Metadata
Assignees
Labels
No labels