public String generate(String protocol) {
        if (protocol == null) {
            protocol = defaultProtocol;
        }
        Swagger swagger = new Swagger();

        swagger.setInfo(getInfo());
        swagger.setBasePath(basePath);

        Map<Class<?>, Object> interfaceMapRef = new HashMap<>();
        List<ProviderBootstrap> providerBootstraps = RpcRuntimeContext.getProviderConfigs();
        for (ProviderBootstrap providerBootstrap : providerBootstraps) {
            ProviderConfig providerConfig = providerBootstrap.getProviderConfig();
            List<ServerConfig> server = providerConfig.getServer();
            for (ServerConfig serverConfig : server) {
                if (serverConfig.getProtocol().equals(protocol)) {
                    interfaceMapRef.put(providerConfig.getProxyClass(), providerConfig.getRef());
                    break;
                }
            }
        }

        Reader.read(swagger, interfaceMapRef, "");
        String result = null;
        try {
            result = Json.mapper().writeValueAsString(swagger);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }

        return result;
    }
@author <a href=mailto:orezsilence@163.com>zhangchengxi</a>
doc-swagger/src/main/java/com/alipay/sofa/rpc/doc/swagger/generate/GenerateService.java