我正在使用swagger-codegen-maven-plugin(2.2.2)从inputSpec生成API和模型类。语言是Spring,库是spring-boot。
swagger生成的API类使用@Controller注释进行注释,是否可以通过configOption对其进行任何更改以改为使用@RestController注释API类?
Tech Stack
Spring Boot-2.2.5Java-JDK 11Maven-3.6.1swagger-codegen-maven-plugin-version-2.2.2
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-maven-plugin-version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${input_spec_file}</inputSpec>
<language>spring</language>
<apiPackage>${api.package}</apiPackage>
<modelPackage>${model.package}</modelPackage>
<templateDirectory>${project.basedir}/src/main/resources/codegen-templates</templateDirectory>
<configOptions>
<skipDefaultInterface>true</skipDefaultInterface>
<skipOverwrite>true</skipOverwrite>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
</configOptions>
<output>.</output>
</configuration>
</execution>
</executions>
</plugin>```
Thanks in advance..!!
您是否尝试过这种方式
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>swagger.yaml</inputSpec>
<language>java</language>
<library>resttemplate</library>
</configuration>
</execution>
</executions>
</plugin>
并且为了依赖添加此内容
<dependency>
<groupId>com.baeldung</groupId>
<artifactId>spring-swagger-codegen-api-client</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>