Generate ascii documentation from openapi 3.0 with samples

Viewed 586

I'm using quarkus and openapi-generator-maven-plugin to generate ascii documentation from openapi 3.0 yaml file, but I'm not being able to add the example sample code to request/response. I have the mustache template but I'm not being able to generate or understand how to automatically create the http-request.adoc/http-response.adoc for all api request.

My directory hierarchy

scr  
 └── asciidoc
         └── templates  
               └── index.mustache

In my pom I have

<plugin>
    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>5.2.1</version>
    <executions>
        <execution>
            <id>generate-ascii-docs</id>
            <phase>prepare-package</phase>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <globalProperties>
                    <apiDocs>true</apiDocs>
                    <apiModels>true</apiModels>
                    <apiTests>false</apiTests>
                    <modelTests>false</modelTests>
                    <verbose>false</verbose>
                </globalProperties>
                <inputSpec>${project.basedir}/target/openapi/openapi.yaml</inputSpec>
                <output>${project.basedir}/target/ascii/</output>
                <generatorName>asciidoc</generatorName>
                <generateApiDocumentation>true</generateApiDocumentation>
                <generateModelDocumentation>true</generateModelDocumentation>
                <generateSupportingFiles>true</generateSupportingFiles>
                <groupId>${project.groupId}</groupId>
                <artifactId>${project.artifactId}</artifactId>
                <templateDirectory>${project.basedir}/src/asciidoc/templates</templateDirectory>
                <configOptions>                     
                    <useIntroduction>true</useIntroduction>
                    <delegatePattern>false</delegatePattern>
                    <useMethodAndPath>false</useMethodAndPath>
                    <prependFormOrBodyParameters>false</prependFormOrBodyParameters>                    
                </configOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

In the index.mustache I have (copied from openapi-generator index.mustache)

...

===== Responses

.http response codes
[cols="1,3,2"]
|===
| Code | Message | Datatype

{{#responses}}

| {{code}}
| {{message}}
| {{^simpleType}}{{dataType}}[<<{{baseType}}>>]{{/simpleType}} {{#simpleType}}<<{{dataType}}>>{{/simpleType}}

{{/responses}}
|===

{{^skipExamples}}
===== Samples

{{#snippetinclude}}{{path}}/{{httpMethod}}/http-request.adoc{{/snippetinclude}}
{{#snippetinclude}}{{path}}/{{httpMethod}}/http-response.adoc{{/snippetinclude}}

{{#snippetlink}}* wiremock data, {{path}}/{{httpMethod}}/{{httpMethod}}.json{{/snippetlink}}

{{/skipExamples}}
...
0 Answers
Related