Is there a way to specify which columns appear in the Parameters section? For example I would like to use Schema/type instead of Pattern.
My configuration:
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.3.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/target/openapi.json</inputSpec>
<generatorName>asciidoc</generatorName>
<configOptions>
<useIntroduction>true</useIntroduction>
</configOptions>
<skipValidateSpec>true</skipValidateSpec>
</configuration>
</execution>
</executions>
</plugin>
Here's the relevant source snippet:
/myapi/{resourceId}:
get:
tags:
- Api Operations
summary: Get a widget
description: Get a widget by its resource id
operationId: findOne
parameters:
- name: resourceId
in: path
required: true
schema:
type: string
- name: affiliateId
in: header
required: false
schema:
type: integer
format: int64
default: 256
And the relevant output snippet:
====== Header Parameters
[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Pattern
| affiliateId
|
| -
| 256
|
|===
Instead of the "Pattern" column I would like it show something like Schema along with the value of integer and/or int64.
I resolved the issue by editing the mustache templates:
After cloning the openapi-generator project, I found and copied the following two files from src/main/resources/asciidoc-documentation
under modules (link): params.mustache
and param.mustache
, to my own project under /src/main/resources/openapi
.
Then I opened params.mustache
and did a find-and-replace from "Pattern" to "Data Type".
Similarly in param.mustache
I replaced "{{{pattern}}}" with "{{dataType}}"
Then in the maven pom file plugin config for openapi-generator-maven-plugin
I added the following element under the configuration
element:
<templateDirectory>${project.basedir}/src/main/resources/openapi</templateDirectory>
Running mvn clean compile resulted in the desired output:
[cols="2,3,1,1,1"]
|===
|Name| Description| Required| Default| Data Type
| affiliateId
|
| -
| 256
| Long
Note: To arrive at the right model field name, I enabled debug under the configuration element: <verbose>true</verbose>
then issued the command (something like): mvn org.openapitools:openapi-generator-maven-plugin:5.3.0:generate@my-execution-id -pl mysubmodule -X -l out.txt
; open out.txt and search for "headerParams" or "affiliateId" and find the field name corresponding to data type, in my case there were "dataType" and "dataFormat" of which I chose the former.
Also note that I did not need to copy index.mustache
or model.mustache
etc. to my project, only the two template files mentioned above.