Skip to content

Commit 5012bb2

Browse files
Fixes #449.
1 parent d34a43a commit 5012bb2

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v5.0.1 (unreleased)
4+
5+
-structurizr-core: Fixes https://github.com/structurizr/java/issues/449 (allow text/plain content types when loading themes).
6+
37
## v5.0.0 (28th October 2025)
48

59
- structurizr-autolayout: Adds support for custom padding view/viewset properties: `structurizr.groupPadding`,`structurizr.boundaryPadding`, and `structurizr.deploymentNodePadding`.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ signing.secretKeyRingFile=/some/path
55
ossrhUsername=username
66
ossrhPassword=password
77

8-
version=5.0.0
8+
version=5.0.1

structurizr-client/src/main/java/com/structurizr/http/RemoteContent.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
public final class RemoteContent {
77

88
public static final String CONTENT_TYPE_JSON = "application/json";
9+
public static final String CONTENT_TYPE_PLAIN_TEXT = "text/plain";
910

1011
private final String content;
1112
private final byte[] bytes;

structurizr-client/src/main/java/com/structurizr/view/ThemeUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static void loadThemes(Workspace workspace, HttpClient httpClient) throws
9090
for (String themeLocation : workspace.getViews().getConfiguration().getThemes()) {
9191
if (Url.isUrl(themeLocation)) {
9292
RemoteContent remoteContent = httpClient.get(themeLocation);
93-
if (remoteContent.getContentType().equals(RemoteContent.CONTENT_TYPE_JSON)) {
93+
if (remoteContent.getContentType().startsWith(RemoteContent.CONTENT_TYPE_JSON) || remoteContent.getContentType().startsWith(RemoteContent.CONTENT_TYPE_PLAIN_TEXT)) {
9494
Theme theme = fromJson(remoteContent.getContentAsString());
9595
String baseUrl = themeLocation.substring(0, themeLocation.lastIndexOf('/') + 1);
9696

structurizr-client/src/test/java/com/structurizr/view/ThemeUtilsTests.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void loadThemes_DoesNothingWhenNoThemesAreDefined() throws Exception {
2626

2727
@Test
2828
@Tag("IntegrationTest")
29-
void loadThemes_LoadsThemesWhenThemesAreDefined() throws Exception {
29+
void loadThemes_LoadsThemesWhenThemesAreDefined_AndContentTypeIsApplicationJson() throws Exception {
3030
Workspace workspace = new Workspace("Name", "Description");
3131
SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name");
3232
softwareSystem.addTags("Amazon Web Services - Alexa For Business");
@@ -47,6 +47,29 @@ void loadThemes_LoadsThemesWhenThemesAreDefined() throws Exception {
4747
assertEquals("https://static.structurizr.com/themes/amazon-web-services-2020.04.30/alexa-for-business.png", style.getIcon());
4848
}
4949

50+
@Test
51+
@Tag("IntegrationTest")
52+
void loadThemes_LoadsThemesWhenThemesAreDefined_AndContentTypeIsPlainText() throws Exception {
53+
Workspace workspace = new Workspace("Name", "Description");
54+
SoftwareSystem softwareSystem = workspace.getModel().addSoftwareSystem("Name");
55+
softwareSystem.addTags("Amazon Web Services - Alexa For Business");
56+
workspace.getViews().getConfiguration().setThemes("https://raw.githubusercontent.com/structurizr/themes/refs/heads/master/amazon-web-services-2020.04.30/theme.json");
57+
58+
HttpClient httpClient = new HttpClient();
59+
httpClient.allow(".*");
60+
ThemeUtils.loadThemes(workspace, httpClient);
61+
62+
// there should still be zero styles in the workspace
63+
assertEquals(0, workspace.getViews().getConfiguration().getStyles().getElements().size());
64+
65+
// but we should be able to find a style included in the theme
66+
ElementStyle style = workspace.getViews().getConfiguration().getStyles().findElementStyle(softwareSystem);
67+
assertNotNull(style);
68+
assertEquals("#d6242d", style.getStroke());
69+
assertEquals("#d6242d", style.getColor());
70+
assertEquals("https://raw.githubusercontent.com/structurizr/themes/refs/heads/master/amazon-web-services-2020.04.30/alexa-for-business.png", style.getIcon());
71+
}
72+
5073
@Test
5174
void toJson() throws Exception {
5275
Workspace workspace = new Workspace("Name", "Description");

0 commit comments

Comments
 (0)