You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2022/01/25 08:33:01 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #2702: [SCB-2380] optimize swaager load logic

liubao68 commented on a change in pull request #2702:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2702#discussion_r791468176



##########
File path: swagger/swagger-generator/generator-core/src/main/java/org/apache/servicecomb/swagger/generator/core/AbstractSwaggerGenerator.java
##########
@@ -311,6 +314,21 @@ protected void scanMethods() {
         throw new IllegalStateException(
             String.format("OperationId must be unique. method=%s:%s.", cls.getName(), method.getName()));
       }
+      Map<String, Model> originsDefinitions = swagger.getDefinitions();
+      if (!CollectionUtils.isEmpty(originsDefinitions)) {
+        originsDefinitions.forEach((key, value) -> {
+          if (definitions.containsKey(key) && !value.equals(definitions.get(key))) {
+            throw new IllegalArgumentException(
+                "the parameter typeName '" + key + "' duplicate in '" + this.cls.getName()
+                    + "', need to rename it");
+          }
+        });
+        definitions.putAll(originsDefinitions);
+      }
+      swagger.setDefinitions(null);

Review comment:
       It's a bit complicated. 
   
   Maybe you can have a very simple solution to extend Swagger `public void addDefinition(String key, Model model)` method




-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org