2012-08-16 5 views
0

maven plugin enunciate에 대한 docs goal을 실행할 때 "다차원 배열에 아직 지원이 없습니다"라는 오류가 발생합니다. 프로세스를 폭파하는 것을 피할 수있는 방법이 있습니까 (예 : API의 나머지 문서 생성)?API 클래스 (다큐먼트 목표)에서 다차원 배열 관련 문제를 해결하기위한 해결 방법이 있습니까?

double 배열로 클래스를 반환하는 API 메소드에서 @ org.codehaus.enunciate.doc.ExcludeFromDocumentation을 시도했습니다. double 배열을 사용하는 클래스에서 @ org.codehaus.enunciate.XmlTransient를 시도했습니다.

필자는 enunciate 문서에서 문서가 표시되는지 여부에 영향을주는 문서를 보았습니다.

나는 당신의 아이디어를 듣고 기쁘게 생각합니다!

감사합니다.

편집 : 내가 할 수있는 최선의 방법은 임시 디렉토리에 프로젝트를 덤프하고 API에 도달 할 필요가없는 모든 모듈을 추출하고, 두 배 배열로 클래스를 삭제하고, REST API의 Java 메소드 부분을 대체하는 것입니다. String을 사용한 서명. 이것은 적어도 enunciate를 통해 API 문서 페이지를 만들고 javadoc을 통해 설명을 제공 할 수있게 해줍니다. 그러나, 정말 하나 :)

편집 알고 있다면 알려주세요, 더 우아한 해결책을 가지고 싶어요 2 : 예 치어 : 주요

<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>com.company.services.rest.service</groupId> 
<artifactId>service-rest-api</artifactId> 
<packaging>pom</packaging> 
<version>1.1</version> 
<name>service REST API</name> 
<dependencies> 
     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jaxrs</artifactId> 
     <version>2.2.1.GA</version> 
     </dependency> 
     <dependency> 
     <groupId>com.sun.xml.bind</groupId> 
     <artifactId>jaxb-impl</artifactId> 
     <version>2.2.4</version> 
     <scope>provided</scope> 
     </dependency> 
     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>jaxrs-api</artifactId> 
     <version>2.2.1.GA</version> 
     </dependency> 
     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jackson-provider</artifactId> 
     <version>2.2.1.GA</version> 
     </dependency> 
     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-jaxb-provider</artifactId> 
     <version>2.2.1.GA</version> 
     <exclusions> 
      <exclusion> 
      <groupId>com.sun.xml.bind</groupId> 
      <artifactId>jaxb-impl</artifactId> 
      </exclusion> 
     </exclusions> 
     </dependency> 
     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>resteasy-multipart-provider</artifactId> 
     <version>2.2.1.GA</version> 
     </dependency> 
     <dependency> 
     <groupId>org.jboss.resteasy</groupId> 
     <artifactId>tjws</artifactId> 
     <version>2.2.1.GA</version> 
     </dependency> 
    </dependencies> 
    <build> 
    <plugins> 
    <plugin> 
     <groupId>org.codehaus.enunciate</groupId> 
     <artifactId>maven-enunciate-plugin</artifactId> 
     <version>1.26</version> 
     <configuration> 
     <forceWarPackaging>false</forceWarPackaging> 
     <configFile>/tmp/enunciate-work/enunciate.xml</configFile> 
     </configuration> 
     <executions> 
     <execution> 
      <goals> 
      <goal>docs</goal> 
      </goals> 
     </execution> 
     </executions> 
    </plugin> 
    </plugins> 
    </build> 

파일 위치 SRC// 자바/COM/기업/서비스/사용자/나머지 :

package com.company.services.service.rest; 

import javax.ws.rs.POST; 
import javax.ws.rs.Produces; 
import javax.ws.rs.Consumes; 
import javax.ws.rs.Path; 
import javax.ws.rs.core.MediaType; 

@Path("/") 
public interface ServiceResource { 
    @POST 
    @Path("/statuschanges") 
    @Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) 
    @Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML}) 
    public ServiceStatusChanges getServiceStatusChangeLogs(String string); 
} 

package com.company.services.service.rest; 

import java.io.Serializable; 
import javax.xml.bind.annotation.XmlRootElement; 

@XmlRootElement 
public class ServiceStatusChanges implements Serializable { 
    private static final long serialVersionUID = 1l; 
    private String[][] logs; 
    public ServiceStatusChanges() {} 

    public ServiceStatusChanges(String[][] logs) { 
     this.logs=logs; 
    } 

    public String[][] getLogs() { 
     return logs; 
    } 

    public void setLogs(String[][] logs) { 
     this.logs=logs; 
    } 
} 

enunciate.xml :

<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:noNamespaceSchemaLocation=" 
      http://enunciate.codehaus.org/schemas/enunciate-1.26.xsd"> 

    <modules> 
     <disable-rule id="csharp.warnings"/> 
     <disable-rule id="c.warnings"/> 
     <disable-rule id="obj-c.warnings"/> 
      <docs docsDir="api" title="REST API" includeDefaultDownloads="false" disableRestMountpoint="true"> 

    </docs> 
    <!-- Disable all the client generation tools --> 
    <basic-app disabled="true" /> 
    <c disabled="true" /> 
    <csharp disabled="true" /> 
    <java-client disabled="true" /> 
    <jaxws-client disabled="true" /> 
    <jaxws-ri disabled="false" /> 
    <jaxws-support disabled="false" /> 
    <jersey disabled="true" /> 
    <obj-c disabled="true" /> 
    <xml forceExampleJson="true"/> 
    <jaxws disabled="false"/> 
    <amf disabled="true"/> 
    </modules> 

</enunciate> 
+0

프로젝트 세부 정보가 없으면 세부 사항을 추측하기가 어렵습니다. – khmarbaise

+0

그래, 내가 우회하려고하는 알려진 동작을 보여주는 간단한 샘플 프로젝트를 추가했습니다. –

+0

왜 Maven 프로젝트 외부에 구성 파일이 있습니까? 이상하게 보입니다. – khmarbaise

답변

0

해당 메소드에서 XML 지원이 필요하지 않은 경우 @Consumes 및 @Produces에서 MediaType.APPLICATION_XML을 제거한 후 JSON을 수행하고 @XmlRootElement 주석을 제거 할 수 있습니다.

XML을 계속 지원하려는 경우 logs 속성 XML을 일시적으로 변경하고 배열을 직렬화 시간으로 래핑하는 것과 같은 직렬화 전용 변경을 지원할 수 있습니다. Enunciate가 대역 외 문서 대신 문서화 할 수 있다는 추가적인 이점이 있습니다. 예컨대 :

@XmlRootElement 
public class ServiceStatusChanges implements Serializable { 
    private static final long serialVersionUID = 1l; 
    private String[][] logs; 
    public ServiceStatusChanges() {} 

    public ServiceStatusChanges(String[][] logs) { 
     this.logs=logs; 
    } 

    @XmlTransient 
    public String[][] getLogs() { 
     return logs; 
    } 

    public void setLogs(String[][] logs) { 
     this.logs=logs; 
    } 

    @XmlElement(name = "logs") 
    public Log[] getLogsWrapped() { 
     Log[] logs = new Log[this.logs.length]; 
     //iterate through the logs and wrap it... 
     return logs; 
    } 
} 

그리고처럼 Log 클래스를 볼 수 있습니다 내가 String[][] 대신 List<String[]> 유형을 사용하는 경우

@XmlRootElement 
public class Log implements Serializable { 
    @XmlValue 
    public String value; 
} 
0

하게 발음의 문서 생성이 살아 남았다. 늘어나는만큼 JSON/XML 예제가 생성 된 것을 기억하고 xsd는 문제가있는 것으로 보입니다.