Skip to content

Commit

Permalink
Merge pull request #1235 from iushankin/issue-1234
Browse files Browse the repository at this point in the history
Fixed #1234: The Mule module doesn't support BeanConfig
  • Loading branch information
webron committed Jul 7, 2015
2 parents 437ad10 + aebb8f4 commit 4b46966
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
5 changes: 5 additions & 0 deletions modules/swagger-mule/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,10 @@
<artifactId>jsr311-api</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import io.swagger.config.Scanner;
import io.swagger.config.ScannerFactory;
import io.swagger.config.SwaggerConfig;
import io.swagger.jaxrs.Reader;
import io.swagger.jaxrs.listing.SwaggerSerializers;
import io.swagger.models.Swagger;
Expand Down Expand Up @@ -42,11 +43,9 @@ protected synchronized void scan(Application app) {
if (classes != null) {
Reader reader = new Reader(swagger);
swagger = reader.read(classes);
// This loads the Swagger root information from the mule-swagger-integration.xml instead of
// the Bootstrap initializer. Should I leave both ways in, or support only one ? The new API doesn't
// seem work very well in the bean xml syntax

// swagger = ((SwaggerConfig) scanner).configure(swagger);
if (scanner instanceof SwaggerConfig) {
swagger = ((SwaggerConfig) scanner).configure(swagger);
}
}
}
initialized = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.swagger.mule;

import io.swagger.jaxrs.config.BeanConfig;
import io.swagger.models.Swagger;

import org.testng.Assert;
import org.testng.annotations.Test;

public class ApiListingJSONTest {

@Test(description = "test Swagger initialization from BeanConfig")
public void initializeTest() {
final BeanConfig bc = new BeanConfig();
bc.setTitle("Petstore Sample API");
bc.setHost("petstore.swagger.io");
bc.setBasePath("/api");
bc.setScan(true);

final ApiListingJSON listing = new ApiListingJSON();
// Initializing by Swagger object
ApiListingJSON.init(new Swagger());
// Reading configuration and scanning resources
listing.scan(null);

final Swagger sw = ApiListingJSON.swagger;
Assert.assertNotNull(sw);
Assert.assertEquals(sw.getInfo().getTitle(), "Petstore Sample API");
Assert.assertEquals(sw.getHost(), "petstore.swagger.io");
Assert.assertEquals(sw.getBasePath(), "/api");
}
}
12 changes: 12 additions & 0 deletions modules/swagger-mule/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<logger name="io.swagger" level="error"/>
<root level="error">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

0 comments on commit 4b46966

Please sign in to comment.