4

I am using Spring RestDoc together with AsciiDoc to describe my rest api. RestDoc generates different files depending if there are request parameters described / response fields etc. I would like to have one template conditionally including whatever file exists.

something like this:

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::[]

or at least exclude warnings in case of a missing file. But I could not figure out how to suppress these.

wrm
  • 1,898
  • 13
  • 24

2 Answers2

1

As of today, where is no operator for ifeval available, which can be used to check the existence of a file.

The way I would go is to write an extension for Asciidoctor, which can also be done by using Java. If your projects is big enough, I would suggest to go for this solution.

Oliver
  • 3,815
  • 8
  • 35
  • 63
0

The most extreme way is to make a custom TemplatedSnippet which is generating an empty snippet to be included...

I hope there is a better way to do this.

Edit: Take a look of http://asciidoctor.org/docs/user-manual/#by-tagged-regions

Harry
  • 175
  • 1
  • 12