/*
 * 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 com.gemstone.gemfire.rest.internal.web.swagger.config;

import javax.servlet.ServletContext;

import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.distributed.internal.InternalDistributedSystem;
import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;
import com.gemstone.gemfire.internal.lang.StringUtils;
import com.mangofactory.swagger.core.SwaggerPathProvider;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.util.UriComponentsBuilder;

@SuppressWarnings("unused")
public class RestApiPathProvider implements SwaggerPathProvider {

  @Autowired
  private ServletContext servletContext;

  private final String docsLocation;

  private SwaggerPathProvider defaultPathProvider;

  public RestApiPathProvider(final String docsLocation) {
    Assert.isTrue(!StringUtils.isBlank(docsLocation),
        "The docs location must be specified!");

    this.docsLocation = "http://"
        + InternalDistributedSystem.getAnyInstance().getConfig()
            .getHttpServiceBindAddress()
        + ":"
        + InternalDistributedSystem.getAnyInstance().getConfig()
            .getHttpServicePort();
  }

  @Override
  public String getApiResourcePrefix() {
    return defaultPathProvider.getApiResourcePrefix();
  }

  @Override
  public String getAppBasePath() {
    return UriComponentsBuilder.fromHttpUrl(docsLocation)
        .path(servletContext.getContextPath()).build().toString();
  }

  @Override
  public String getSwaggerDocumentationBasePath() {
    return UriComponentsBuilder.fromHttpUrl(getAppBasePath())
        .pathSegment("api-docs/").build().toString();
  }

  @Override
  public String getRequestMappingEndpoint(String requestMappingPattern) {
    return defaultPathProvider.getRequestMappingEndpoint(requestMappingPattern);
  }

  public void setDefaultPathProvider(
      final SwaggerPathProvider defaultSwaggerPathProvider) {
    this.defaultPathProvider = defaultSwaggerPathProvider;
  }

}

@@ -930,19 +930,47 @@
 ire.
-cache.Cache
+distributed.internal.DistributionConfig
 ;%0Aim
@@ -1047,69 +1047,8 @@
 em;%0A
-import com.gemstone.gemfire.internal.cache.GemFireCacheImpl;%0A
 impo
@@ -1729,47 +1729,35 @@
     
-this.docsLocation = %22http://%22%0A        +
+DistributionConfig config =
  Int
@@ -1811,141 +1811,175 @@
 ig()
+;
 %0A    
-        .getHttpServiceBindAddress()%0A        + %22:%22%0A        + InternalDistributedSystem.getAnyInstance().getConfig()%0A            
+String scheme = config.getHttpServiceSSLEnabled() ? %22https%22 : %22http%22;%0A%0A    this.docsLocation = scheme + %22://%22 + config.getHttpServiceBindAddress() + %22:%22 + config
 .get

Fix https access for REST Swagger UI