0
votes

I'm moving from swagger (Open API 2) to springdoc (Open API 3), but today in some cases I use swagger-codegen-maven-plugin to generate code (for client and provider)from yaml, following the Contract First strategy. Bellow the configuration example:

<plugin>
    <groupId>io.swagger</groupId>
    <artifactId>swagger-codegen-maven-plugin</artifactId>
    <version>2.4.9</version>
    <executions>
        <execution>
            <id>generate-provider-v1</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <inputSpec>${project.basedir}/src/main/resources/swagger/my-api.yaml</inputSpec>
        <output>${project.build.directory}/generated-sources/swagger</output>
        <language>spring</language>
        <library>spring-boot</library>
        <modelPackage>br.com.sample.representation</modelPackage>
        <apiPackage>br.com.sample.adapter.controller.v1</apiPackage>
        <generateSupportingFiles>true</generateSupportingFiles>
        <configOptions>
            <interfaceOnly>true</interfaceOnly>
            <delegatePattern>true</delegatePattern>
            <dateLibrary>java8</dateLibrary>
        </configOptions>
        <modelNameSuffix>Representation</modelNameSuffix>
        <generateSupportingFiles>false</generateSupportingFiles>
    </configuration>
</plugin>

There are any equivalent option to generate code with springdoc-openapi-maven-plugin?

1

1 Answers

1
votes

As described in the documentation:

The aim of springdoc-openapi-maven-plugin is to generate json and yaml OpenAPI description during build time. The plugin works during integration-tests phase, and generate the OpenAPI description.

You can have a look at the openapi-generator-maven-plugin for code generation from the spec: