Java 带码头的骡子中昂首阔步的一代

Java 带码头的骡子中昂首阔步的一代,java,jetty,mule,swagger,Java,Jetty,Mule,Swagger,我正在尝试从我的API生成swagger。我使用mule并为此添加了这个jetty连接器。我的mule服务器在8080上运行 <jetty:connector name="jettyConnector"> <jetty:webapps directory="${app.home}/webapps" port="8083"/> </jetty:connector> 骡流: <?xml version="1.0" encoding

我正在尝试从我的API生成swagger。我使用mule并为此添加了这个jetty连接器。我的mule服务器在8080上运行

 <jetty:connector name="jettyConnector">
        <jetty:webapps directory="${app.home}/webapps" port="8083"/>
    </jetty:connector>
骡流:

<?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>

我们在swagger core存储库中有一个mule特定模块,其中包含一个教程和一个示例,它完全不依赖/不需要jetty

本教程包含您需要的所有信息,包括依赖项和到示例的链接


如果可能的话,我会选择在这里找到的1.5版本——即使该版本的Mule模块尚未发布(但可以从develop_2.0分支编译)。

您可以在系统中包含有关文件权限的信息吗?什么类型的文件权限?我以sudo的身份运行mule。您的Jetty连接器代码似乎指定端口8083而不是8080。应该是8080吗?我试过了,但因为骡子是用8080跑的。它抛出bind exceptionI尝试了第一种方法,但出现了以下错误:com.wordnik.swagger.annotations.Api.hidden()Z。接下来是:我需要更多的信息—完整的堆栈跟踪和您采取的确切步骤。如果这个项目是公开的,并且可以查看,这也会有所帮助。这个错误已经消失了,但我没有得到完整的炫耀文件。我已经在我的原始问题中更新了课堂。但我只得到这么多。{“apiVersion”:“1.0.0”,“swaggerVersion”:“1.2”,“API”:[{“path”:“/transactions”,“description”:“update API”}]}这就是您应该得到的。如果点击
/api docs/transactions
,您将获得详细的操作。很好,当我点击/api docs/transactions时,出现了这个错误。未找到com.wordnik.swagger.model.apiliting类的序列化程序,也未找到创建BeanSerializer的属性(为避免异常,请在\u EMPTY\u bean上禁用SerializationConfig.Feature.FAIL\u))。我已将javax.ws.rs.ext.MessageBodyWriter文件添加到服务目录。
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.12</version>
</dependency>
@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;


}
<?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>