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


##########
flink-docs/src/main/java/org/apache/flink/docs/rest/OpenApiSpecGenerator.java:
##########
@@ -452,7 +447,26 @@ private static Content createContentWithMediaType(String 
mediaType, Schema schem
     }
 
     private static Schema<?> getSchema(Type type) {
-        return modelConverterContext.resolve(new 
AnnotatedType(type).resolveAsRef(true));
+        final AnnotatedType annotatedType = new 
AnnotatedType(type).resolveAsRef(true);
+        final Schema<?> schema = modelConverterContext.resolve(annotatedType);
+        if (type instanceof Class<?>) {
+            final Class<?> clazz = (Class<?>) type;
+            ApiGeneratorUtils.findAdditionalFieldType(clazz)
+                    .map(OpenApiSpecGenerator::getSchema)
+                    .ifPresent(
+                            additionalPropertiesSchema -> {
+                                // We can not reuse the schema instance 
returned by the converter
+                                // above, because it's a different instance 
than the resolver has
+                                // defined, so we wouldn't see the changes 
later when populating
+                                // OpenAPI components.
+                                final Schema<?> definedModel =

Review Comment:
   Nope, the `#schema` returned by resolved is a wrapper that contains a 
reference to the `#definedModel` (which is a component)
   
   The valuable property here is that if more endpoints would be using the same 
class as a body, we only need to define the structure of the class; in this 
case, `#/components/schemas/AdditionalFieldsRequestBody` only needs to be 
defined once.
   
   Thanks for the question; it pushed me in the right direction to finally 
understand what's going on there. I'll adjust the comment to reflect the 
finding.



-- 
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