Skip to content

Commit

Permalink
Merge pull request #13021 from Avishka-Shamendra/apim-governance-core
Browse files Browse the repository at this point in the history
Key Manager Visibility, Gateway Visibility Bug Fixes and Other Fixes
  • Loading branch information
tharindu1st authored Feb 28, 2025
2 parents ee51dda + ebb7e76 commit 18be033
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public Environment(Environment environment) {
this.additionalProperties = new HashMap<>(environment.additionalProperties);
this.visibilityRoles = environment.visibilityRoles;
this.visibility = environment.visibility;
this.permissions = environment.permissions;
}
private GatewayVisibilityPermissionConfigurationDTO permissions = new GatewayVisibilityPermissionConfigurationDTO();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.wso2.carbon.apimgt.rest.api.util.utils.RestApiUtil;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
Expand Down Expand Up @@ -74,10 +75,11 @@ public Response swaggerYamlGet() throws APIManagementException {
if (openAPIDef == null) {
synchronized (LOCK_GOV_OPENAPI_DEF) {
if (openAPIDef == null) {
String definition = IOUtils
.toString(this.getClass().getClassLoader().getResourceAsStream("governance-api.yaml"),
StandardCharsets.UTF_8);
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
try (InputStream defStream = this.getClass()
.getClassLoader().getResourceAsStream("governance-api.yaml")) {
String definition = IOUtils.toString(defStream, StandardCharsets.UTF_8);
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -4780,11 +4781,11 @@ public static boolean hasIntersection(String[] arr1, String[] arr2) {
Set<String> set = new HashSet<>();

for (String element : arr1) {
set.add(element);
set.add(element.toLowerCase(Locale.ENGLISH));
}

for (String element : arr2) {
if (set.contains(element)) {
if (set.contains(element.toLowerCase(Locale.ENGLISH))) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5374,11 +5374,11 @@ public static boolean hasIntersection(String[] arr1, String[] arr2) {
Set<String> set = new HashSet<>();

for (String element : arr1) {
set.add(element);
set.add(element.toLowerCase(Locale.ENGLISH));
}

for (String element : arr2) {
if (set.contains(element)) {
if (set.contains(element.toLowerCase(Locale.ENGLISH))) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;

@Path("/swagger.yaml")
@Consumes({ "text/yaml" })
Expand Down Expand Up @@ -62,9 +64,11 @@ public Response swaggerYamlGet() throws APIManagementException {
if (openAPIDef == null) {
synchronized (LOCK_ADMIN_OPENAPI_DEF) {
if (openAPIDef == null) {
String definition = IOUtils
.toString(this.getClass().getResourceAsStream("/admin-api.yaml"), "UTF-8");
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
try (InputStream defStream = this.getClass()
.getClassLoader().getResourceAsStream("admin-api.yaml")) {
String definition = IOUtils.toString(defStream, StandardCharsets.UTF_8);
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.api.APIManagementException;
import org.wso2.carbon.apimgt.impl.definitions.OAS2Parser;
import org.wso2.carbon.apimgt.impl.definitions.OAS3Parser;
import org.wso2.carbon.apimgt.rest.api.util.utils.RestApiUtil;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -63,9 +65,11 @@ public Response swaggerYamlGet() throws APIManagementException {
if (openAPIDef == null) {
synchronized (LOCK_STORE_OPENAPI_DEF) {
if (openAPIDef == null) {
String definition = IOUtils
.toString(this.getClass().getResourceAsStream("/gateway-api.yaml"), "UTF-8");
openAPIDef = new OAS2Parser().removeExamplesFromSwagger(definition);
try (InputStream defStream = this.getClass()
.getClassLoader().getResourceAsStream("gateway-api.yaml")) {
String definition = IOUtils.toString(defStream, StandardCharsets.UTF_8);
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.wso2.carbon.apimgt.rest.api.util.utils.RestApiUtil;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -66,9 +68,11 @@ public Response swaggerYamlGet() throws APIManagementException {
if (openAPIDef == null) {
synchronized (LOCK_PUBLISHER_OPENAPI_DEF) {
if (openAPIDef == null) {
String definition = IOUtils
.toString(this.getClass().getResourceAsStream("/publisher-api.yaml"), "UTF-8");
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
try (InputStream defStream = this.getClass()
.getClassLoader().getResourceAsStream("publisher-api.yaml")) {
String definition = IOUtils.toString(defStream, StandardCharsets.UTF_8);
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.wso2.carbon.apimgt.rest.api.util.utils.RestApiUtil;

import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -67,9 +69,11 @@ public Response swaggerYamlGet() throws APIManagementException {
if (openAPIDef == null) {
synchronized (LOCK_STORE_OPENAPI_DEF) {
if (openAPIDef == null) {
String definition = IOUtils
.toString(this.getClass().getResourceAsStream("/devportal-api.yaml"), "UTF-8");
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
try (InputStream defStream = this.getClass()
.getClassLoader().getResourceAsStream("devportal-api.yaml")) {
String definition = IOUtils.toString(defStream, StandardCharsets.UTF_8);
openAPIDef = new OAS3Parser().removeExamplesFromOpenAPI(definition);
}
}
}
}
Expand Down

0 comments on commit 18be033

Please sign in to comment.