[英]Java Inheritance using YAML
我想使用YAML配置在生成的类文件中实现Java继承。 如我所希望的那样,一个特定的Custom类可以从同一YAML文件中定义的其他其他Custom类继承/扩展。
我尝试了以下更改:在这里期望的是生成的UpdateDTO类应该从CreationDTO类继承
UpdateDTO:
type: CreationDTO
properties:
id:
type: integer
format: int64
description: the annotation ID
category:
type: string
description: The annotation or adjustment category
我尝试过的第二种方法如下:
UpdateDTO:
type:
$ref: '#/definitions/CreationDTO'
properties:
id:
type: integer
format: int64
description: the annotation ID
category:
type: string
description: The annotation or adjustment category
两种方法都不适合我。 UpdateDTO不会扩展CreationDTO
我们正在使用以下maven配置生成源文件:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<id>source</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${basedir}/src/main/resources/swagger/daa.yaml</inputSpec>
<language>xx.xxx.xxx.swagger.codegen.languages.JavaResteasyServerApisCodegen</language>
<output>${project.build.directory}/generated-sources/swagger</output>
<addCompileSourceRoot>false</addCompileSourceRoot>
<apiPackage>xx.xxx.xxx.daa.rest</apiPackage>
<modelPackage>xx.xxx.xxx.daa.rest.model</modelPackage>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>xx.xxx.xxx</groupId>
<artifactId>abs-swagger-codegen</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</plugin>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.