我在 yaml 文件中添加了新的“Scheme”枚举:
SchemeEnum:
type: string
enum:
- SCHEME_I
- SCHEME_II
在生成的公共枚举SchemeEnum中完成生成后,我有如下枚举:
I("SCHEME_I"),
II("SCHEME_II");
我想留下来
SCHEME_I("SCHEME_I"),
SCHEME_II("SCHEME_II");
我不知道 SpringCodegen 为什么这样做。当我再添加一个值时,例如:
SchemeEnum:
type: string
enum:
- SCHEME
- SCHEME_I
- SCHEME_II
一切都是正确的,我明白了
public enum SchemeEnum{
SCHEME("SCHEME"),
SCHEME_I("SCHEME_I"),
SCHEME_II("SCHEME_II");
在我生成的课程中。有什么办法可以解决吗?我应该更改配置吗?
我期待得到这样的生成类:
public enum SchemeEnum{
SCHEME_I("SCHEME_I"),
SCHEME_II("SCHEME_II");
下面的 yml 正在生成正确的类结构
SchemeEnum:
type: string
enum:
- SCHEME_I
- SCHEME_II
- SCHEME_III
x-enum-varnames:
- SCHEME_I
- SCHEME_II
- SCHEME_III
具有以下依赖项和插件
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>2.2.19</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
<artifactId>jackson-databind-nullable</artifactId>
<version>0.2.6</version>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>7.4.0</version>
<executions>
<execution>
<id>order-inbound</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>
${project.basedir}/src/main/resources/swagger/grocery-app-v1.json
</inputSpec>
<generatorName>spring</generatorName>
<generateApis>false</generateApis>
<generateModels>true</generateModels>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>false</generateSupportingFiles>
<modelPackage>com.dev.model.generated</modelPackage>
<configOptions>
<dateLibrary>java8</dateLibrary>
<Library>spring-boot</Library>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>