@ahmttyydn/java-integration 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +762 -0
- package/README.md +37 -0
- package/package.json +46 -0
- package/pom.xml +242 -0
- package/scalar-core/pom.xml +92 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/ScalarConstants.java +26 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/ScalarHtmlRenderer.java +135 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/ScalarProperties.java +596 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/ScalarAuthenticationOptions.java +235 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/AuthorizationCodeFlow.java +160 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/ClientCredentialsFlow.java +88 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/ImplicitFlow.java +64 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/OAuthFlow.java +185 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/PasswordFlow.java +134 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/ScalarFlows.java +113 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarApiKeySecurityScheme.java +77 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarHttpSecurityScheme.java +115 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarOAuth2SecurityScheme.java +75 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarSecurityScheme.java +45 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/config/DefaultHttpClient.java +77 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/config/ScalarAgentOptions.java +68 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/config/ScalarServer.java +197 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/config/ScalarSource.java +151 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/CredentialsLocation.java +52 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/DeveloperToolsVisibility.java +58 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/DocumentDownloadType.java +67 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/OperationSorter.java +52 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/OperationTitleSource.java +52 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/Pkce.java +57 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/PropertyOrder.java +53 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarClient.java +208 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarLayout.java +52 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarTarget.java +158 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarTheme.java +102 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/TagSorter.java +47 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/enums/ThemeMode.java +52 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/internal/ScalarConfiguration.java +425 -0
- package/scalar-core/src/main/java/com/scalar/maven/core/internal/ScalarConfigurationMapper.java +69 -0
- package/scalar-core/src/main/resources/META-INF/resources/webjars/scalar/index.html +22 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/ScalarConfigurationTest.java +144 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/ScalarHtmlRendererTest.java +104 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/ScalarPropertiesTest.java +525 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/config/DefaultHttpClientTest.java +61 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/config/ScalarAgentOptionsTest.java +80 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/config/ScalarServerTest.java +118 -0
- package/scalar-core/src/test/java/com/scalar/maven/core/config/ScalarSourceTest.java +105 -0
- package/scalar-playground-webflux/pom.xml +52 -0
- package/scalar-playground-webflux/src/main/java/com/scalar/maven/playground/CustomScalarWebFluxController.java +34 -0
- package/scalar-playground-webflux/src/main/java/com/scalar/maven/playground/PlaygroundApplication.java +27 -0
- package/scalar-playground-webflux/src/main/resources/application.properties +7 -0
- package/scalar-playground-webmvc/pom.xml +52 -0
- package/scalar-playground-webmvc/src/main/java/com/scalar/maven/playground/CustomScalarWebMvcController.java +34 -0
- package/scalar-playground-webmvc/src/main/java/com/scalar/maven/playground/PlaygroundApplication.java +27 -0
- package/scalar-playground-webmvc/src/main/resources/application.properties +7 -0
- package/scalar-webflux/pom.xml +110 -0
- package/scalar-webflux/src/main/java/com/scalar/maven/webflux/ScalarWebFluxActuatorEndpoint.java +103 -0
- package/scalar-webflux/src/main/java/com/scalar/maven/webflux/ScalarWebFluxAutoConfiguration.java +63 -0
- package/scalar-webflux/src/main/java/com/scalar/maven/webflux/ScalarWebFluxController.java +109 -0
- package/scalar-webflux/src/main/java/com/scalar/maven/webflux/SpringBootScalarProperties.java +43 -0
- package/scalar-webflux/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +2 -0
- package/scalar-webflux/src/test/java/com/scalar/maven/webflux/ScalarWebFluxActuatorEndpointTest.java +136 -0
- package/scalar-webflux/src/test/java/com/scalar/maven/webflux/ScalarWebFluxControllerTest.java +162 -0
- package/scalar-webmvc/pom.xml +103 -0
- package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/ScalarWebMvcActuatorEndpoint.java +97 -0
- package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/ScalarWebMvcAutoConfiguration.java +63 -0
- package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/ScalarWebMvcController.java +103 -0
- package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/SpringBootScalarProperties.java +43 -0
- package/scalar-webmvc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +2 -0
- package/scalar-webmvc/src/test/java/com/scalar/maven/webmvc/ScalarWebMvcActuatorEndpointTest.java +128 -0
- package/scalar-webmvc/src/test/java/com/scalar/maven/webmvc/ScalarWebMvcControllerTest.java +154 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
package com.scalar.maven.core;
|
|
2
|
+
|
|
3
|
+
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
4
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
5
|
+
import com.scalar.maven.core.config.ScalarAgentOptions;
|
|
6
|
+
import com.scalar.maven.core.enums.*;
|
|
7
|
+
import com.scalar.maven.core.internal.ScalarConfiguration;
|
|
8
|
+
import com.scalar.maven.core.internal.ScalarConfigurationMapper;
|
|
9
|
+
import org.junit.jupiter.api.Test;
|
|
10
|
+
|
|
11
|
+
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
12
|
+
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Test class for ScalarConfiguration and related functionality.
|
|
16
|
+
*/
|
|
17
|
+
public class ScalarConfigurationTest {
|
|
18
|
+
|
|
19
|
+
@Test
|
|
20
|
+
public void testEnumSerialization() throws JsonProcessingException {
|
|
21
|
+
ObjectMapper mapper = new ObjectMapper();
|
|
22
|
+
|
|
23
|
+
// Test ScalarTheme serialization
|
|
24
|
+
ScalarTheme theme = ScalarTheme.DEEP_SPACE;
|
|
25
|
+
String themeJson = mapper.writeValueAsString(theme);
|
|
26
|
+
assertEquals("\"deepSpace\"", themeJson);
|
|
27
|
+
|
|
28
|
+
// Test ScalarLayout serialization
|
|
29
|
+
ScalarLayout layout = ScalarLayout.MODERN;
|
|
30
|
+
String layoutJson = mapper.writeValueAsString(layout);
|
|
31
|
+
assertEquals("\"modern\"", layoutJson);
|
|
32
|
+
|
|
33
|
+
// Test DocumentDownloadType serialization
|
|
34
|
+
DocumentDownloadType downloadType = DocumentDownloadType.BOTH;
|
|
35
|
+
String downloadTypeJson = mapper.writeValueAsString(downloadType);
|
|
36
|
+
assertEquals("\"both\"", downloadTypeJson);
|
|
37
|
+
|
|
38
|
+
// Test DeveloperToolsVisibility serialization
|
|
39
|
+
DeveloperToolsVisibility visibility = DeveloperToolsVisibility.ALWAYS;
|
|
40
|
+
String visibilityJson = mapper.writeValueAsString(visibility);
|
|
41
|
+
assertEquals("\"always\"", visibilityJson);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Test
|
|
45
|
+
public void testEnumDeserialization() throws JsonProcessingException {
|
|
46
|
+
ObjectMapper mapper = new ObjectMapper();
|
|
47
|
+
|
|
48
|
+
// Test ScalarTheme deserialization
|
|
49
|
+
ScalarTheme theme = mapper.readValue("\"deepSpace\"", ScalarTheme.class);
|
|
50
|
+
assertEquals(ScalarTheme.DEEP_SPACE, theme);
|
|
51
|
+
|
|
52
|
+
// Test ScalarLayout deserialization
|
|
53
|
+
ScalarLayout layout = mapper.readValue("\"modern\"", ScalarLayout.class);
|
|
54
|
+
assertEquals(ScalarLayout.MODERN, layout);
|
|
55
|
+
|
|
56
|
+
// Test DocumentDownloadType deserialization
|
|
57
|
+
DocumentDownloadType downloadType = mapper.readValue("\"both\"", DocumentDownloadType.class);
|
|
58
|
+
assertEquals(DocumentDownloadType.BOTH, downloadType);
|
|
59
|
+
|
|
60
|
+
// Test DeveloperToolsVisibility deserialization
|
|
61
|
+
DeveloperToolsVisibility visibility = mapper.readValue("\"always\"", DeveloperToolsVisibility.class);
|
|
62
|
+
assertEquals(DeveloperToolsVisibility.ALWAYS, visibility);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Test
|
|
66
|
+
public void testScalarConfigurationMapping() {
|
|
67
|
+
ScalarProperties properties = new ScalarProperties();
|
|
68
|
+
properties.setTheme(ScalarTheme.DEEP_SPACE);
|
|
69
|
+
properties.setLayout(ScalarLayout.MODERN);
|
|
70
|
+
properties.setDocumentDownloadType(DocumentDownloadType.BOTH);
|
|
71
|
+
properties.setShowSidebar(false);
|
|
72
|
+
properties.setHideModels(true);
|
|
73
|
+
properties.setTelemetry(false);
|
|
74
|
+
properties.setShowDeveloperTools(DeveloperToolsVisibility.ALWAYS);
|
|
75
|
+
|
|
76
|
+
ScalarConfiguration config = ScalarConfigurationMapper.map(properties);
|
|
77
|
+
|
|
78
|
+
assertNotNull(config);
|
|
79
|
+
assertEquals(ScalarTheme.DEEP_SPACE, config.getTheme());
|
|
80
|
+
assertEquals(ScalarLayout.MODERN, config.getLayout());
|
|
81
|
+
assertEquals(DocumentDownloadType.BOTH, config.getDocumentDownloadType());
|
|
82
|
+
assertEquals(false, config.getShowSidebar());
|
|
83
|
+
assertEquals(true, config.getHideModels());
|
|
84
|
+
assertEquals(false, config.getTelemetry());
|
|
85
|
+
assertEquals(DeveloperToolsVisibility.ALWAYS, config.getShowDeveloperTools());
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@Test
|
|
89
|
+
public void testScalarConfigurationWithEnums() {
|
|
90
|
+
ScalarProperties properties = new ScalarProperties();
|
|
91
|
+
properties.setTheme(ScalarTheme.BLUE_PLANET);
|
|
92
|
+
properties.setLayout(ScalarLayout.CLASSIC);
|
|
93
|
+
properties.setDocumentDownloadType(DocumentDownloadType.JSON);
|
|
94
|
+
properties.setOperationTitleSource(OperationTitleSource.SUMMARY);
|
|
95
|
+
properties.setTagSorter(TagSorter.ALPHA);
|
|
96
|
+
properties.setOperationSorter(OperationSorter.METHOD);
|
|
97
|
+
properties.setForceThemeMode(ThemeMode.DARK);
|
|
98
|
+
properties.setSchemaPropertyOrder(PropertyOrder.ALPHA);
|
|
99
|
+
properties.setShowDeveloperTools(DeveloperToolsVisibility.NEVER);
|
|
100
|
+
|
|
101
|
+
ScalarConfiguration config = ScalarConfigurationMapper.map(properties);
|
|
102
|
+
|
|
103
|
+
assertNotNull(config);
|
|
104
|
+
assertEquals(ScalarTheme.BLUE_PLANET, config.getTheme());
|
|
105
|
+
assertEquals(ScalarLayout.CLASSIC, config.getLayout());
|
|
106
|
+
assertEquals(DocumentDownloadType.JSON, config.getDocumentDownloadType());
|
|
107
|
+
assertEquals(OperationTitleSource.SUMMARY, config.getOperationTitleSource());
|
|
108
|
+
assertEquals(TagSorter.ALPHA, config.getTagSorter());
|
|
109
|
+
assertEquals(OperationSorter.METHOD, config.getOperationsSorter());
|
|
110
|
+
assertEquals(ThemeMode.DARK, config.getForceDarkModeState());
|
|
111
|
+
assertEquals(PropertyOrder.ALPHA, config.getOrderSchemaPropertiesBy());
|
|
112
|
+
assertEquals(DeveloperToolsVisibility.NEVER, config.getShowDeveloperTools());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@Test
|
|
116
|
+
public void testScalarConfigurationMappingIncludesAgent() {
|
|
117
|
+
ScalarProperties properties = new ScalarProperties();
|
|
118
|
+
ScalarAgentOptions agent = new ScalarAgentOptions();
|
|
119
|
+
agent.setKey("production-agent-key");
|
|
120
|
+
agent.setDisabled(false);
|
|
121
|
+
properties.setAgent(agent);
|
|
122
|
+
|
|
123
|
+
ScalarConfiguration config = ScalarConfigurationMapper.map(properties);
|
|
124
|
+
|
|
125
|
+
assertNotNull(config.getAgent());
|
|
126
|
+
assertEquals("production-agent-key", config.getAgent().getKey());
|
|
127
|
+
assertEquals(false, config.getAgent().getDisabled());
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Test
|
|
131
|
+
public void testScalarConfigurationMappingWithAgentDisabled() {
|
|
132
|
+
ScalarProperties properties = new ScalarProperties();
|
|
133
|
+
ScalarAgentOptions agent = new ScalarAgentOptions();
|
|
134
|
+
agent.setDisabled(true);
|
|
135
|
+
properties.setAgent(agent);
|
|
136
|
+
|
|
137
|
+
ScalarConfiguration config = ScalarConfigurationMapper.map(properties);
|
|
138
|
+
|
|
139
|
+
assertNotNull(config.getAgent());
|
|
140
|
+
assertEquals(true, config.getAgent().getDisabled());
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
package com.scalar.maven.core;
|
|
2
|
+
|
|
3
|
+
import org.junit.jupiter.api.DisplayName;
|
|
4
|
+
import org.junit.jupiter.api.Nested;
|
|
5
|
+
import org.junit.jupiter.api.Test;
|
|
6
|
+
|
|
7
|
+
import java.io.IOException;
|
|
8
|
+
|
|
9
|
+
import static org.assertj.core.api.Assertions.assertThat;
|
|
10
|
+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
11
|
+
|
|
12
|
+
@DisplayName("ScalarHtmlRenderer")
|
|
13
|
+
class ScalarHtmlRendererTest {
|
|
14
|
+
|
|
15
|
+
@Nested
|
|
16
|
+
@DisplayName("render")
|
|
17
|
+
class Render {
|
|
18
|
+
|
|
19
|
+
@Test
|
|
20
|
+
@DisplayName("should render HTML with default properties")
|
|
21
|
+
void shouldRenderHtmlWithDefaultProperties() throws IOException {
|
|
22
|
+
ScalarProperties properties = new ScalarProperties();
|
|
23
|
+
String html = ScalarHtmlRenderer.render(properties);
|
|
24
|
+
assertThat(html)
|
|
25
|
+
.isNotNull()
|
|
26
|
+
.contains("<!doctype html>")
|
|
27
|
+
.contains("<html>")
|
|
28
|
+
.contains("<head>")
|
|
29
|
+
.contains("<title>Scalar API Reference</title>")
|
|
30
|
+
.contains("<body>")
|
|
31
|
+
.contains("<div id=\"app\"></div>")
|
|
32
|
+
.contains("Scalar.createApiReference('#app',")
|
|
33
|
+
.contains("src=\"scalar/scalar.js\"");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Test
|
|
37
|
+
@DisplayName("should render HTML with custom page title")
|
|
38
|
+
void shouldRenderHtmlWithCustomPageTitle() throws IOException {
|
|
39
|
+
ScalarProperties properties = new ScalarProperties();
|
|
40
|
+
properties.setPageTitle("My Custom API");
|
|
41
|
+
String html = ScalarHtmlRenderer.render(properties);
|
|
42
|
+
assertThat(html)
|
|
43
|
+
.isNotNull()
|
|
44
|
+
.contains("<title>My Custom API</title>");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Test
|
|
48
|
+
@DisplayName("should render HTML with custom path")
|
|
49
|
+
void shouldRenderHtmlWithCustomPath() throws IOException {
|
|
50
|
+
ScalarProperties properties = new ScalarProperties();
|
|
51
|
+
properties.setPath("/api/docs");
|
|
52
|
+
String html = ScalarHtmlRenderer.render(properties);
|
|
53
|
+
assertThat(html)
|
|
54
|
+
.isNotNull()
|
|
55
|
+
.contains("src=\"docs/scalar.js\"");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@Test
|
|
59
|
+
@DisplayName("should render script URL with last path segment for context path deployment")
|
|
60
|
+
void shouldRenderScriptUrlWithLastSegmentForContextPath() throws IOException {
|
|
61
|
+
ScalarProperties properties = new ScalarProperties();
|
|
62
|
+
properties.setPath("/myapp/scalar-ui");
|
|
63
|
+
String html = ScalarHtmlRenderer.render(properties);
|
|
64
|
+
assertThat(html)
|
|
65
|
+
.isNotNull()
|
|
66
|
+
.contains("src=\"scalar-ui/scalar.js\"");
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@Test
|
|
70
|
+
@DisplayName("should handle null properties")
|
|
71
|
+
void shouldHandleNullProperties() {
|
|
72
|
+
assertThatThrownBy(() -> ScalarHtmlRenderer.render(null))
|
|
73
|
+
.isInstanceOf(NullPointerException.class)
|
|
74
|
+
.hasMessageContaining("properties must not be null");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Test
|
|
78
|
+
@DisplayName("should handle null path in properties")
|
|
79
|
+
void shouldHandleNullPathInProperties() throws IOException {
|
|
80
|
+
ScalarProperties properties = new ScalarProperties();
|
|
81
|
+
properties.setPath(null);
|
|
82
|
+
// Should use default path when path is null
|
|
83
|
+
String html = ScalarHtmlRenderer.render(properties);
|
|
84
|
+
assertThat(html)
|
|
85
|
+
.isNotNull()
|
|
86
|
+
.contains("src=\"scalar/scalar.js\"");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@Nested
|
|
91
|
+
@DisplayName("getScalarJsContent")
|
|
92
|
+
class GetScalarJsContent {
|
|
93
|
+
|
|
94
|
+
@Test
|
|
95
|
+
@DisplayName("should return JavaScript content")
|
|
96
|
+
void shouldReturnJavaScriptContent() throws IOException {
|
|
97
|
+
byte[] jsContent = ScalarHtmlRenderer.getScalarJsContent();
|
|
98
|
+
assertThat(jsContent)
|
|
99
|
+
.isNotNull()
|
|
100
|
+
.isNotEmpty();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|