2016-12-15 51 views
1

我使用Spring RestDoc和AsciiDoc一起来描述我的rest api。 RestDoc生成不同的文件,这取决于是否有描述的请求参数/响应字段等。我想有一个模板有条件地包括任何文件存在。有条件的包含在asciidoc中

是这样的:

Request: 

include::{reqresPath}/http-request.adoc[] 

Response: 
include::{reqresPath}/http-response.adoc[] 

Parameters: 
ifeval::[{{reqresPath}/request-parameters.adoc}.exists] 
    include::{reqresPath}/request-parameters.adoc[] 
endif::[] 
ifeval::[{{reqresPath}/request-parameters.adoc}.exists] 
    include::{reqresPath}/request-parameters.adoc[] 
endif::[] 

,或者至少排除文件丢失的情况下警告。但我无法弄清楚如何抑制这些。

回答

0

最极端的方法是使被列入其中产生的空段自定义TemplatedSnippet ...

我希望有一个更好的办法来做到这一点。

编辑: 看看的​​