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


##########
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 =
+                                        modelConverterContext
+                                                .getDefinedModels()
+                                                .get(clazz.getSimpleName());

Review Comment:
   Should we handle the case when this call returns null?
   
   I guess `modelConverterContext.resolve(annotatedType)` might be more complex 
than just lookup by class simple name



##########
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:
   Shouldn't `definedModel` be returned instead of the resolved one?
   (I guess not, just want to double-check)



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