This is a similar question to this one on the same subject.
I have actually managed to generate a YAML file successfully using the solution for the answer above. Suddenly, when I was going to demo to my peers, the generated file was JSON.
The code section is:
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<apiDocsUrl>http://localhost:8080/v3/api-docs.yaml</apiDocsUrl>
<outputFileName>openapi.yaml</outputFileName>
<outputDir>${project.basedir}/api-docs</outputDir>
<apiDocsUrl>http://localhost:8080/v3/api-docs</apiDocsUrl>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
Even though the <apiDocsUrl />
states .yaml
(or .YAML
), still the generated output is a JSON
file.
How can I fix this?
After a good look at the snippet above, the answer was really obvious. The <apiDocsUrl />
line is duplicated. The first instance sets the output file as .yaml
and the second as .json
.