我尝试将模型类导入到enunciate docs中,但我在Maven日志中得到以下内容:
Class com.mycompany.model.MyClass was explicitly imported, but it was not found on the classpath. We'll try to import it anyway.
我正在尝试在我的enunciate生成的文档中包含Request和Response类。但是我得到的是以下内容:
POST
Request Body
element: (custom)
media types: application/json
(no documentation provided)
Response Body
element: (custom)
media types: application/json
(no documentation provided)
enunciate.xml
<?xml version="1.0"?>
<enunciate xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://enunciate.codehaus.org/schemas/enunciate-1.27.xsd">
<api-import pattern="com.mycompany.model.*" />
<api-import pattern="com.mycompany.model.MyClass" />
<api-classes>
<include pattern="com.mycompany.common.imrest.model.*"/>
<include pattern="com.mycompany.model.MyClass"/>
</api-classes>
</enunciate>
pom.xml
<plugin>
<groupId>org.codehaus.enunciate</groupId>
<artifactId>maven-enunciate-plugin</artifactId>
<version>1.27</version>
<configuration>
<configFile>enunciate.xml</configFile>
</configuration>
<executions>
<execution>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
另外,第二个问题。有没有办法在文档中包含示例JSON请求和响应?
答案 0 :(得分:0)
发出扫描您的类路径,导入您已配置为要导入的任何类。但它在扫描期间没有找到该类。您是否确认您对包含com.mycompany.model.MyClass
类的jar有依赖性?
Re:JSON示例:如果您的类路径中有jackson-xc.jar
,则Enunciate将默认生成示例JSON。否则,您可以强制示例json:
<enunciate ...>
...
<modules>
<docs forceExampleJson="true"/>
</modules>
</enunciate>