我在一个maven项目中使用Enunciate来生成REST API文档。
工件安全性生成Web API文档,但是它忽略了Spring注解,比如:@Secured (来自maven-enunciate-plugin -security)
我尝试使用具有spring支持maven-enunciate-spring-plugin的maven工件生成文档,但它甚至不生成Web API文档。
有没有办法配置、表述或使用另一个表述式的maven插件,以便在表述式生成的文档中识别和提及来自Spring的注释?
发布于 2013-07-17 16:22:48
没关系,我设法通过“在Enunctiate的文档中应用自定义皮肤”(http://docs.codehaus.org/display/ENUNCIATE/Applying+a+Custom+Skin+to+Enunciate%27s+Documentation)解决了这个问题。
我修改了docs.xml.fmt和enunciate-docs的docs.fmt,这样'@Secured‘注释就可以识别了。
不幸的是,对于docs.xml.fmt来说,没有像我们在docs.fmt中那样的干净的定制方法。所以,我不得不用这些修改过的文件打包自己。
我提到了@Deprecated (java.lang.Deprecated)是如何处理的,并遵循了类似的方法。
在docs.fmt文件中,将此块添加到isDeprecated的类似功能块下面
[#function isSecured element]
[#return (getTagValues(element, "secured")?size > 0)/]
[/#function]现在,
就在这个区块的下面:
[#if isDeprecated(resource)]
<p class="alert">This resource has been deprecated.</p>
[/#if]添加另一个if块
[#if isSecured(resource)]
<p class="note">This resource is available only to these roles:
[#assign securedTags = getTagValues(resource, "secured") /]
[#if securedTags?size > 0]
${securedTags[0]}
[/#if]
[#list resource.parent.annotations as tag]
${tag}
[/#list]
</p>
[/#if]现在,在docs.xml.fmt文件中,如下所示:
[#if resource.parent.annotations["java.lang.Deprecated"]??]
<tag name="deprecated"/>
[/#if]添加以下块
[#if resource.parent.annotations["org.springframework.security.access.annotation.Secured"]??]
<tag name="secured">
[#list resource.parent.annotations["org.springframework.security.access.annotation.Secured"]["value"] as roles]
<![CDATA[${roles}]]>
[/#list]
</tag>
[/#if]发布于 2013-07-07 04:12:34
恐怕不行。虽然可以添加该功能,但Enunciate不能识别这些Spring注释。欢迎您访问open up a request。
( maven-enunciate-spring-plugin只是用来阐明Spring到后端运行时的连接,它不包括您所询问的特性。)
https://stackoverflow.com/questions/17448136
复制相似问题