feat(api-docs): reintroduce API doc generation (#289)
- reintroduces API doc generation via API_DOCS_ENABLED - accessible publicly via /api/docs and /api/openapi.json
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package org.booklore.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.util.StreamUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ScalarControllerTest {
|
||||
|
||||
private final ScalarController controller = new ScalarController();
|
||||
|
||||
@Test
|
||||
void shouldForwardToStaticScalarPage() {
|
||||
assertThat(controller.scalar()).isEqualTo("forward:/scalar.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
void staticScalarPageShouldDisableTelemetryAndPointToApiDocs() throws IOException {
|
||||
String html = StreamUtils.copyToString(
|
||||
new ClassPathResource("static/scalar.html").getInputStream(),
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
assertThat(html).contains("data-url=\"/api/openapi.json\"");
|
||||
assertThat(html).contains("\"telemetry\":false");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user