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/12/07 12:04:20 UTC

[GitHub] [servicecomb-java-chassis] yanghao605 opened a new pull request, #3513: [SCB-2737] export swagger contents to temporary files

yanghao605 opened a new pull request, #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513

   Follow this checklist to help us incorporate your contribution quickly and easily:
   
    - [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/SCB) filed for the change (usually before you start working on it).  Trivial changes like typos do not require a JIRA issue.  Your pull request should address just this issue, without pulling in other changes.
    - [ ] Each commit in the pull request should have a meaningful subject line and body.
    - [ ] Format the pull request title like `[SCB-XXX] Fixes bug in ApproximateQuantiles`, where you replace `SCB-XXX` with the appropriate JIRA issue.
    - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [ ] Run `mvn clean install -Pit` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically.
    - [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   ---
   


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


[GitHub] [servicecomb-java-chassis] codecov-commenter commented on pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#issuecomment-1345488268

   # [Codecov](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#3513](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (7a87099) into [master](https://codecov.io/gh/apache/servicecomb-java-chassis/commit/fdd3734236d1b402aec43a4b32b3a61874cf55fb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (fdd3734) will **decrease** coverage by `0.04%`.
   > The diff coverage is `28.57%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #3513      +/-   ##
   ============================================
   - Coverage     74.38%   74.33%   -0.05%     
     Complexity      670      670              
   ============================================
     Files          1589     1589              
     Lines         39830    39851      +21     
     Branches       3633     3637       +4     
   ============================================
   - Hits          29627    29623       -4     
   - Misses         8720     8743      +23     
   - Partials       1483     1485       +2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...b/core/provider/producer/ProducerBootListener.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Y29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvY29yZS9wcm92aWRlci9wcm9kdWNlci9Qcm9kdWNlckJvb3RMaXN0ZW5lci5qYXZh) | `52.05% <28.57%> (-9.49%)` | :arrow_down: |
   | [.../servicecomb/registry/discovery/DiscoveryTree.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Zm91bmRhdGlvbnMvZm91bmRhdGlvbi1yZWdpc3RyeS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvcmVnaXN0cnkvZGlzY292ZXJ5L0Rpc2NvdmVyeVRyZWUuamF2YQ==) | `96.72% <0.00%> (-3.28%)` | :arrow_down: |
   | [...mb/serviceregistry/client/http/RestClientUtil.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmljZS1yZWdpc3RyeS9yZWdpc3RyeS1zZXJ2aWNlLWNlbnRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvc2VydmljZXJlZ2lzdHJ5L2NsaWVudC9odHRwL1Jlc3RDbGllbnRVdGlsLmphdmE=) | `78.50% <0.00%> (-1.87%)` | :arrow_down: |
   | [...ecomb/foundation/common/utils/SPIServiceUtils.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-Zm91bmRhdGlvbnMvZm91bmRhdGlvbi1zcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NlcnZpY2Vjb21iL2ZvdW5kYXRpb24vY29tbW9uL3V0aWxzL1NQSVNlcnZpY2VVdGlscy5qYXZh) | `92.85% <0.00%> (-1.79%)` | :arrow_down: |
   | [...mb/config/ConfigCenterConfigurationSourceImpl.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZHluYW1pYy1jb25maWcvY29uZmlnLWNjL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zZXJ2aWNlY29tYi9jb25maWcvQ29uZmlnQ2VudGVyQ29uZmlndXJhdGlvblNvdXJjZUltcGwuamF2YQ==) | `9.57% <0.00%> (-1.07%)` | :arrow_down: |
   | [...egistry/client/http/ServiceRegistryClientImpl.java](https://codecov.io/gh/apache/servicecomb-java-chassis/pull/3513/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c2VydmljZS1yZWdpc3RyeS9yZWdpc3RyeS1zZXJ2aWNlLWNlbnRlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2VydmljZWNvbWIvc2VydmljZXJlZ2lzdHJ5L2NsaWVudC9odHRwL1NlcnZpY2VSZWdpc3RyeUNsaWVudEltcGwuamF2YQ==) | `67.30% <0.00%> (-0.77%)` | :arrow_down: |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1046561068


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -45,8 +49,16 @@
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
 
+  private static final String pattern = File.separator + "%s" + File.separator + "%s.yaml";

Review Comment:
   Naming: static final should use upper case. 



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1043012380


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -44,9 +44,15 @@
 
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
+  
+  private static final String pattern = "/%s/%s.yaml";
 
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();

Review Comment:
   I'd prefer enabled by default. 



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1046561921


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -45,8 +49,16 @@
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
 
+  private static final String pattern = File.separator + "%s" + File.separator + "%s.yaml";
+
+  private static final String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "microservices";
+
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();
+    String filePath = DynamicPropertyFactory.getInstance()
+            .getStringProperty(DefinitionConst.SWAGGER_DIRECTORY, tmpDir).get() + pattern;

Review Comment:
   `microservices` sub folder it better created by code, not specified by user. 



##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -45,8 +49,16 @@
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
 
+  private static final String pattern = File.separator + "%s" + File.separator + "%s.yaml";
+
+  private static final String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "microservices";
+
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();
+    String filePath = DynamicPropertyFactory.getInstance()
+            .getStringProperty(DefinitionConst.SWAGGER_DIRECTORY, tmpDir).get() + pattern;

Review Comment:
   `microservices` sub folder is better created by code, not specified by user. 



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


[GitHub] [servicecomb-java-chassis] yanghao605 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
yanghao605 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1045190646


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -44,9 +44,15 @@
 
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
+  
+  private static final String pattern = "/%s/%s.yaml";
 
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();

Review Comment:
   giving the choice to users may be a good idea



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1043008051


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -44,9 +44,15 @@
 
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
+  
+  private static final String pattern = "/%s/%s.yaml";
 
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();
+    String filePath = DynamicPropertyFactory.getInstance()
+            .getStringProperty(DefinitionConst.SWAGGER_DIRECTORY, "/tmp/microservices").get() + pattern;

Review Comment:
   use system temporary directory `java.io.tmpdir `



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1043010294


##########
foundations/foundation-registry/src/main/java/org/apache/servicecomb/registry/definition/DefinitionConst.java:
##########
@@ -40,4 +40,8 @@ public interface DefinitionConst {
   String REGISTRY_APP_ID = "default";
 
   String REGISTRY_SERVICE_NAME = "SERVICECENTER";
+
+  String SWAGGER_EXPORT_ENABLED = "servicecomb.swagger.export.enabled";
+
+  String SWAGGER_DIRECTORY = "servicecomb.swagger.directory";

Review Comment:
   servicecomb.swagger.export.directory



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1046563008


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -123,4 +138,23 @@ public void onAfterClose(BootEvent event) {
           operationMeta.getExecutor().getClass().getName());
     }
   }
+
+  private void exportToFile(String fileName, String content) {
+    File file = new File(fileName);
+    if (!file.getParentFile().exists()) {
+      if (!file.getParentFile().mkdirs()) {
+        LOGGER.error("create file directory failed");

Review Comment:
   should return



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1057084166


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -63,6 +76,9 @@ public void onAfterTransport(BootEvent event) {
       Swagger swagger = schemaMeta.getSwagger();
       swagger.addScheme(Scheme.forValue(swaggerSchema));
       String content = SwaggerUtils.swaggerToString(swagger);
+      if (exportToFile) {

Review Comment:
   ```
         if (exportToFile) {
           exportToFile(String.format(filePath, microservice.getServiceName(), schemaMeta.getSchemaId()), content);
         } else {
         LOGGER.info("generate swagger for {}/{}/{}, swagger: {}",
             microserviceMeta.getAppId(),
             microserviceMeta.getMicroserviceName(),
             schemaMeta.getSchemaId(),
             content);
   }
   ```
   
   is better? Do you think so? By default not print contents in logs, because users can read swagger in temporary file or in service center. 
   
   



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


[GitHub] [servicecomb-java-chassis] liubao68 merged pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 merged PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513


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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1043012380


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -44,9 +44,15 @@
 
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
+  
+  private static final String pattern = "/%s/%s.yaml";
 
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();

Review Comment:
   I'd prefer to true. 



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1046561243


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -45,8 +49,16 @@
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
 
+  private static final String pattern = File.separator + "%s" + File.separator + "%s.yaml";

Review Comment:
   Naming: static final should use upper case. 



##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -45,8 +49,16 @@
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
 
+  private static final String pattern = File.separator + "%s" + File.separator + "%s.yaml";
+
+  private static final String tmpDir = System.getProperty("java.io.tmpdir") + File.separator + "microservices";

Review Comment:
   Naming: static final should use upper case. 



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


[GitHub] [servicecomb-java-chassis] liubao68 commented on a diff in pull request #3513: [SCB-2737] export swagger contents to temporary files

Posted by GitBox <gi...@apache.org>.
liubao68 commented on code in PR #3513:
URL: https://github.com/apache/servicecomb-java-chassis/pull/3513#discussion_r1046561357


##########
core/src/main/java/org/apache/servicecomb/core/provider/producer/ProducerBootListener.java:
##########
@@ -44,9 +44,15 @@
 
 public class ProducerBootListener implements BootListener {
   private static final Logger LOGGER = LoggerFactory.getLogger(ProducerBootListener.class);
+  
+  private static final String pattern = "/%s/%s.yaml";
 
   @Override
   public void onAfterTransport(BootEvent event) {
+    boolean exportToFile = DynamicPropertyFactory.getInstance()
+            .getBooleanProperty(DefinitionConst.SWAGGER_EXPORT_ENABLED, false).get();

Review Comment:
   I mean the default value be true is better. 



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