Skip to content

Commit f58103f

Browse files
Merge branch 'release-2.2'
2 parents 2b42dea + 1cbcd1a commit f58103f

15 files changed

+1611
-1144
lines changed

build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ allprojects {
3737
subprojects {
3838
group 'net.slkdev.swagger.confluence'
3939

40-
version '2.1'
40+
version '2.2'
4141

4242
if (project.hasProperty("release")) {
4343
version += '-RELEASE'
@@ -68,6 +68,7 @@ subprojects {
6868

6969
repositories {
7070
mavenLocal()
71+
jcenter()
7172
mavenCentral()
7273
}
7374

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ LOG4J2_VERSION=2.5
77
MOCKITO_VERSION=1.10.19
88
SLF4J_VERSION=1.7.19
99
SPRING_VERSION=4.2.5.RELEASE
10-
SWAGGER2MARKUP_VERSION=0.9.2
10+
SWAGGER2MARKUP_VERSION=1.0.0

swagger-confluence-core/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ bintray {
3636
dependencies {
3737
compile "org.slf4j:slf4j-api:$SLF4J_VERSION"
3838

39-
compile "io.github.robwin:swagger2markup:$SWAGGER2MARKUP_VERSION"
39+
compile "io.github.swagger2markup:swagger2markup:$SWAGGER2MARKUP_VERSION"
4040
compile "org.springframework:spring-core:$SPRING_VERSION"
4141
compile "org.springframework:spring-web:$SPRING_VERSION"
4242
compile "org.asciidoctor:asciidoctorj:$ASCIIDOCTORJ_VERSION"

swagger-confluence-core/src/main/java/net/slkdev/swagger/confluence/service/impl/SwaggerToAsciiDocServiceImpl.java

+18-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@
1515
*/
1616
package net.slkdev.swagger.confluence.service.impl;
1717

18-
import io.github.robwin.markup.builder.MarkupLanguage;
19-
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
18+
import io.github.swagger2markup.*;
19+
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
20+
import io.github.swagger2markup.markup.builder.MarkupLanguage;
2021
import net.slkdev.swagger.confluence.exception.SwaggerConfluenceConfigurationException;
2122
import net.slkdev.swagger.confluence.exception.SwaggerConfluenceInternalSystemException;
2223
import net.slkdev.swagger.confluence.service.SwaggerToAsciiDocService;
24+
import org.apache.commons.io.FileUtils;
2325
import org.slf4j.Logger;
2426
import org.slf4j.LoggerFactory;
2527

@@ -28,6 +30,7 @@
2830
import java.io.IOException;
2931
import java.net.URISyntaxException;
3032
import java.net.URL;
33+
import java.nio.charset.StandardCharsets;
3134

3235
public class SwaggerToAsciiDocServiceImpl implements SwaggerToAsciiDocService {
3336

@@ -45,13 +48,24 @@ public String convertSwaggerToAsciiDoc(final String swaggerSchemaPath) {
4548
throw new SwaggerConfluenceConfigurationException("Error Locating Swagger Schema", e);
4649
}
4750

51+
4852
final String swaggerAsciiDoc;
4953

5054
try {
51-
swaggerAsciiDoc = Swagger2MarkupConverter.from(swaggerSchemaFile.getAbsolutePath())
55+
final Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
5256
.withMarkupLanguage(MarkupLanguage.ASCIIDOC)
57+
.withOutputLanguage(Language.EN)
58+
.withPathsGroupedBy(GroupBy.AS_IS)
59+
.withOperationOrdering(OrderBy.AS_IS)
60+
.build();
61+
62+
final String swaggerSchema = FileUtils.readFileToString(swaggerSchemaFile, StandardCharsets.UTF_8);
63+
64+
swaggerAsciiDoc = Swagger2MarkupConverter.from(swaggerSchema)
65+
.withConfig(config)
5366
.build()
54-
.asString();
67+
.toString();
68+
5569
} catch (IOException e) {
5670
throw new SwaggerConfluenceInternalSystemException(
5771
"Error Converting Swagger Schema to AsciiDoc", e);

swagger-confluence-core/src/main/java/net/slkdev/swagger/confluence/service/impl/XHtmlToConfluenceServiceImpl.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,8 @@ private void addExistingPageData(final ConfluencePage confluencePage) {
497497
private static HttpHeaders buildHttpHeaders(final String confluenceAuthentication) {
498498
final HttpHeaders headers = new HttpHeaders();
499499
headers.set("Authorization", String.format("Basic %s", confluenceAuthentication));
500-
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
501-
headers.setContentType(MediaType.APPLICATION_JSON);
500+
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON_UTF8));
501+
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
502502

503503
return headers;
504504
}

swagger-confluence-core/src/test/java/net/slkdev/swagger/confluence/service/impl/XHtmlToConfluenceServiceImplTest.java

+16-16
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public class XHtmlToConfluenceServiceImplTest {
5757

5858
private static final String POST_RESPONSE = "{\"id\":\"1\"}";
5959

60-
private static final List<Integer> CATEGORY_INDEXES = Arrays.asList(1, 6, 25);
60+
private static final List<Integer> CATEGORY_INDEXES = Arrays.asList(1, 6, 25, 31);
6161

6262
@Mock
6363
private RestTemplate restTemplate;
@@ -158,7 +158,7 @@ public void testCreatePageWithPaginationModeCategory(){
158158
"/swagger-petstore-xhtml-example.html")
159159
);
160160

161-
for(int i = 0; i < 4; i++) {
161+
for(int i = 0; i < 5; i++) {
162162
when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET),
163163
any(RequestEntity.class), eq(String.class))).thenReturn(responseEntity);
164164
when(responseEntity.getBody()).thenReturn(GET_RESPONSE_NOT_FOUND);
@@ -171,12 +171,12 @@ public void testCreatePageWithPaginationModeCategory(){
171171

172172
xHtmlToConfluenceService.postXHtmlToConfluence(swaggerConfluenceConfig, xhtml);
173173

174-
verify(restTemplate, times(4)).exchange(any(URI.class), eq(HttpMethod.GET),
174+
verify(restTemplate, times(5)).exchange(any(URI.class), eq(HttpMethod.GET),
175175
any(RequestEntity.class), eq(String.class));
176-
verify(restTemplate, times(4)).exchange(any(URI.class), eq(HttpMethod.POST),
176+
verify(restTemplate, times(5)).exchange(any(URI.class), eq(HttpMethod.POST),
177177
httpEntityCaptor.capture(), eq(String.class));
178178

179-
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getValue();
179+
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getAllValues().get(3);
180180

181181
final String expectedPostBody = IOUtils.readFull(
182182
AsciiDocToXHtmlServiceImplTest.class.getResourceAsStream(
@@ -201,7 +201,7 @@ public void testUpdatePageWithPaginationModeCategory(){
201201

202202
final ResponseEntity<String> postResponseEntity = new ResponseEntity<>(POST_RESPONSE, HttpStatus.OK);
203203

204-
for(int i = 0; i < 4; i++) {
204+
for(int i = 0; i < 5; i++) {
205205
when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET),
206206
any(RequestEntity.class), eq(String.class))).thenReturn(responseEntity);
207207
when(responseEntity.getBody()).thenReturn(GET_RESPONSE_FOUND);
@@ -213,12 +213,12 @@ public void testUpdatePageWithPaginationModeCategory(){
213213

214214
xHtmlToConfluenceService.postXHtmlToConfluence(swaggerConfluenceConfig, xhtml);
215215

216-
verify(restTemplate, times(4)).exchange(any(URI.class), eq(HttpMethod.GET),
216+
verify(restTemplate, times(5)).exchange(any(URI.class), eq(HttpMethod.GET),
217217
any(RequestEntity.class), eq(String.class));
218-
verify(restTemplate, times(4)).exchange(any(URI.class), eq(HttpMethod.PUT),
218+
verify(restTemplate, times(5)).exchange(any(URI.class), eq(HttpMethod.PUT),
219219
httpEntityCaptor.capture(), eq(String.class));
220220

221-
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getValue();
221+
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getAllValues().get(3);
222222

223223
final String expectedPostBody = IOUtils.readFull(
224224
AsciiDocToXHtmlServiceImplTest.class.getResourceAsStream(
@@ -254,12 +254,12 @@ public void testCreatePageWithPaginationModeIndividual(){
254254

255255
xHtmlToConfluenceService.postXHtmlToConfluence(swaggerConfluenceConfig, xhtml);
256256

257-
verify(restTemplate, times(31)).exchange(any(URI.class), eq(HttpMethod.GET),
257+
verify(restTemplate, times(34)).exchange(any(URI.class), eq(HttpMethod.GET),
258258
any(RequestEntity.class), eq(String.class));
259-
verify(restTemplate, times(31)).exchange(any(URI.class), eq(HttpMethod.POST),
259+
verify(restTemplate, times(34)).exchange(any(URI.class), eq(HttpMethod.POST),
260260
httpEntityCaptor.capture(), eq(String.class));
261261

262-
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getValue();
262+
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getAllValues().get(30);
263263

264264
final String expectedPostBody = IOUtils.readFull(
265265
AsciiDocToXHtmlServiceImplTest.class.getResourceAsStream(
@@ -289,7 +289,7 @@ public void testUpdatePageWithPaginationModeIndividual(){
289289
when(restTemplate.exchange(any(URI.class), eq(HttpMethod.GET),
290290
any(RequestEntity.class), eq(String.class))).thenReturn(responseEntity);
291291

292-
for(int i = 0; i < 31; i++) {
292+
for(int i = 0; i < 34; i++) {
293293
if(i > 0) {
294294
returnJson.add(GET_RESPONSE_FOUND);
295295
}
@@ -315,12 +315,12 @@ public void testUpdatePageWithPaginationModeIndividual(){
315315

316316
xHtmlToConfluenceService.postXHtmlToConfluence(swaggerConfluenceConfig, xhtml);
317317

318-
verify(restTemplate, times(34)).exchange(any(URI.class), eq(HttpMethod.GET),
318+
verify(restTemplate, times(38)).exchange(any(URI.class), eq(HttpMethod.GET),
319319
any(RequestEntity.class), eq(String.class));
320-
verify(restTemplate, times(31)).exchange(any(URI.class), eq(HttpMethod.PUT),
320+
verify(restTemplate, times(34)).exchange(any(URI.class), eq(HttpMethod.PUT),
321321
httpEntityCaptor.capture(), eq(String.class));
322322

323-
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getValue();
323+
final HttpEntity<String> capturedHttpEntity = httpEntityCaptor.getAllValues().get(30);
324324

325325
final String expectedPostBody = IOUtils.readFull(
326326
AsciiDocToXHtmlServiceImplTest.class.getResourceAsStream(

0 commit comments

Comments
 (0)