Skip to content

Commit

Permalink
fix: Fix several bugs (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
CH3CHO authored Oct 17, 2024
1 parent c22a018 commit d625928
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ class WasmPluginServiceImpl implements WasmPluginService {
private static final String EXAMPLE_RAW_PROPERTY_NAME = "x-example-raw";

private static final Pattern YAML_CONTENT_PATTERN = Pattern.compile("^(\\s*)(\\S.*)\\s*$");
private static final String YAML_V3_SCHEMA_PROPERTY_KEY = "openAPIV3Schema:";
private static final String CONFIG_SCHEMA_PROPERTY_KEY = "configSchema:";
private static final String OPEN_API_V3_SCHEMA_PROPERTY_KEY = "openAPIV3Schema:";
private static final String YAML_EXAMPLE_PROPERTY_KEY = "example:";

private volatile List<PluginCacheItem> builtInPlugins = Collections.emptyList();
Expand Down Expand Up @@ -186,7 +187,7 @@ private void fillPluginConfigExample(Plugin plugin, String content) {
private String extractConfigExample(String content) throws IOException {
StringBuilder builder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new StringReader(content))) {
boolean foundSchema = false, foundExample = false;
boolean foundConfigSchema = false, foundOpenApiV3Schema = false, foundExample = false;
String schemaOuterIndentation = null, exampleOuterIndentation = null, exampleInnerIndentation = null;
String line;
while ((line = reader.readLine()) != null) {
Expand All @@ -200,10 +201,16 @@ private String extractConfigExample(String content) throws IOException {
String indentation = yamlContentMatcher.group(1);
String unindentedContent = yamlContentMatcher.group(2);

if (!foundSchema) {
if (!foundOpenApiV3Schema) {
if (!foundConfigSchema) {
if (unindentedContent.startsWith(CONFIG_SCHEMA_PROPERTY_KEY)) {
foundConfigSchema = true;
}
continue;
}
// We only care about finding the openAPIV3Schema property now.
if (unindentedContent.startsWith(YAML_V3_SCHEMA_PROPERTY_KEY)) {
foundSchema = true;
if (unindentedContent.startsWith(OPEN_API_V3_SCHEMA_PROPERTY_KEY)) {
foundOpenApiV3Schema = true;
schemaOuterIndentation = indentation;
}
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public static String normalizeDomainName(String name) {
}

public static String joinLabelSelectors(String... selectors) {
return String.join(Separators.COMMA, selectors);
return String.join(Separators.COMMA,
Arrays.stream(selectors).filter(StringUtils::isNotBlank).toArray(String[]::new));
}

public static String buildDomainLabelSelector(String domainName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ spec:
example:
allows:
- consumer1
- consumer2
- consumer2
configSchema:
openAPIV3Schema:
type: object
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ function findRouteByPath(route: Route, pathname?: string): Route | undefined {
return route;
}

if (route.children) {
for (const child of route.children) {
const childRoutes = route.routes || route.children;
if (childRoutes) {
for (const child of childRoutes) {
const matchedRoute = findRouteByPath(child, pathname);
if (matchedRoute) {
return matchedRoute;
Expand Down

0 comments on commit d625928

Please sign in to comment.