I am trying to generate swagger from my apis.I am using mule and added this jetty connector for that. My mule server is running on 8080
<jetty:connector name="jettyConnector">
<jetty:webapps directory="${app.home}/webapps" port="8083"/>
</jetty:connector>
I have added web .xml under src/main/app/webapps/swaggerdoc/WEB-INF/web.xml and the content is:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>Swagger doc</display-name>
<description>swagger doc</description>
<servlet>
<servlet-name>JerseyJaxrsConfig</servlet-name>
<servlet-class>com.wordnik.swagger.jersey.config.JerseyJaxrsConfig</servlet-class>
<init-param>
<param-name>api.version</param-name>
<param-value>1.0.0</param-value>
</init-param>
<init-param>
<param-name>swagger.api.basepath</param-name>
<param-value>http://localhost:8002/api</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.rest.types.resource;com.wordnik.swagger.jersey.listing</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
And pom file has this dependency:
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.12</version>
</dependency>
But after starting mule when I am hitting http://localhost:8080/api, its throwing "Not Authorized". I have used all annotations on the api's correctly.
Any help would be really appreciative. I am stuck on this problem from last few days.
Interface from which I am trying to generate swagger:
@Path("/api-docs")
@Api(value = "/transactions", description = "Update APIs")
public interface BaseResource {
@PUT
@ApiOperation(value = "updateTransactions", notes = "update Transaction.", httpMethod = "PUT")
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_ACCEPTED, message = "Accepted"),
@ApiResponse(code = HttpServletResponse.SC_BAD_REQUEST, message = "Bad Request"),
@ApiResponse(code = HttpServletResponse.SC_UNAUTHORIZED, message = "Unauthorized "),
@ApiResponse(code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR, message = "Internal Server Error") })
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
BaseResource.PutTransactionsResponse updateTransactions(
@ApiParam(name = "Authorization",
defaultValue = "",
required = true) @HeaderParam("Authorization") String authorizationHeader,
UpdateRequest entity)
throws Exception;
}
MULE FLOW:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:jetty="http://www.mulesoft.org/schema/mule/jetty"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
xmlns:apikit="http://www.mulesoft.org/schema/mule/apikit" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.6.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/jetty http://www.mulesoft.org/schema/mule/jetty/current/mule-jetty.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/apikit http://www.mulesoft.org/schema/mule/apikit/current/mule-apikit.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.xsd">
<context:property-placeholder location="classpath:mule-app.properties" />
<spring:beans>
<spring:bean id="apiListingJSON"
class="com.wordnik.swagger.mule.ApiListingJSON" />
<spring:bean id="swaggerConfig"
class="com.wordnik.swagger.jaxrs.config.BeanConfig">
<spring:property name="resourcePackage" value="com.rest.types.resource" />
<spring:property name="version" value="1.0.0" />
<spring:property name="basePath" value="http://0.0.0.0:8080" />
<spring:property name="scan" value="true" />
</spring:bean>
</spring:beans>
<spring:beans>
<spring:bean id="sampleResourceBean"
class="com.rest.types.resource.UpdateApiImpl" />
</spring:beans>
<flow name="services_all" doc:name="services_all">
<http:inbound-endpoint exchange-pattern="request-response"
host="0.0.0.0" port="8080" mimeType="application/json" doc:name="HTTP" />
<logger level="INFO" doc:name="Log Incoming Request"/>
<choice doc:name="ContextRootRouting">
<when
expression="#[message.inboundProperties['http.request'] contains '/api-docs']">
<object-to-string-transformer doc:name="Object to String" />
<logger message="About to call Transaction Service, #[payload]"
doc:name="Logger" />
<jersey:resources doc:name="REST">
<component>
<spring-object bean="sampleResourceBean" />
</component>
<component>
<spring-object bean="apiListingJSON" />
</component>
</jersey:resources>
</when>
</mule>