rkhachatryan commented on code in PR #22139:
URL: https://github.com/apache/flink/pull/22139#discussion_r1131147499


##########
flink-docs/src/test/java/org/apache/flink/docs/rest/RestAPIDocGeneratorTest.java:
##########
@@ -60,6 +62,22 @@ void testExcludeFromDocumentation() throws Exception {
                         "This REST API should also not appear in the generated 
documentation.");
     }
 
+    @Test
+    void testAdditionalFields() {
+        final String messageHtmlEntry =
+                RestAPIDocGenerator.createMessageHtmlEntry(
+                        TestAdditionalFields.class, null, 
EmptyRequestBody.class);
+        assertThat(messageHtmlEntry)
+                .isEqualTo(
+                        "{\n"
+                                + "  \"type\" : \"object\",\n"
+                                + "  \"id\" : 
\"urn:jsonschema:org:apache:flink:docs:rest:RestAPIDocGeneratorTest:TestAdditionalFields\",\n"
+                                + "  \"additionalProperties\" : {\n"
+                                + "    \"type\" : \"string\"\n"
+                                + "  }\n"
+                                + "}");

Review Comment:
   nit: this assertion also seems a bit fragile because it includes formatting. 
Should we use something like `contains`?



##########
flink-docs/src/main/java/org/apache/flink/docs/rest/ApiGeneratorUtils.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.docs.rest;
+
+import org.apache.flink.annotation.docs.Documentation;
+import org.apache.flink.annotation.docs.FlinkJsonSchema;
+import org.apache.flink.runtime.rest.messages.MessageHeaders;
+import org.apache.flink.runtime.rest.messages.MessageParameters;
+import org.apache.flink.runtime.rest.messages.RequestBody;
+import org.apache.flink.runtime.rest.messages.ResponseBody;
+
+import java.util.Optional;
+
+/** Helper methods for generation API documentation. */
+public class ApiGeneratorUtils {

Review Comment:
   rename to `ApiSpecGeneratorUtils` or `ApiDocsGeneratorUtils`?
   (or `apiDesriptionGeneratorUtils` to satisfy both cases)



##########
flink-docs/src/test/java/org/apache/flink/docs/rest/OpenApiSpecGeneratorTest.java:
##########
@@ -131,4 +129,28 @@ public List<Tuple2<RestHandlerSpecification, 
ChannelInboundHandler>> initializeH
                     Tuple2.of(new TestEmptyMessageHeaders("operation1"), 
null));
         }
     }
+
+    @Test
+    void testAdditionalFields(@TempDir Path tmpDir) throws Exception {
+        final Path file = tmpDir.resolve("openapi_spec.yaml");
+        OpenApiSpecGenerator.createDocumentationFile(
+                "title", new TestAdditionalFieldsRestEndpoint(), 
RuntimeRestAPIVersion.V0, file);
+        final String actual = new String(Files.readAllBytes(file), 
StandardCharsets.UTF_8);
+        assertThat(actual)
+                .contains(
+                        "    AdditionalFieldsRequestBody:\n"
+                                + "      type: object\n"
+                                + "      additionalProperties:\n"
+                                + "        type: string");

Review Comment:
   nit: Do we actually want to check for spaces? Isn't it easy to break?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to