[英]Swagger: maven plugin does not generate Api Model
I am trying to generate a YAML and a JSON file with the code-first approach with only the ApiModel.我正在尝试使用仅 ApiModel 的代码优先方法生成 YAML 和 JSON 文件。 I want for the swagger-maven-plugin to generate only this.
我希望 swagger-maven-plugin 只生成这个。 I don't have any web services on it.
我没有任何 web 服务。 But it does not produce anything as an output.
但它不会像 output 那样产生任何东西。 When I add a web service, it produces the files properly.
当我添加 web 服务时,它会正确生成文件。
@ApiModel(value="BatchModel", description="Batch model for the documentation")
public class BatchD {
private Long batchId;
private String reference;
private List<BatchStateD> batchStateList;
public BatchD() {
batchStateList = new ArrayList<>();
}
@ApiModelProperty(required = true, value = "The identification number of the batch.")
@JsonProperty("id")
@NotNull
public Long getBatchId() {
return batchId;
}
public void setBatchId(Long batchId) {
this.batchId = batchId;
}
@ApiModelProperty(required = true, value = "The reference number of batch")
@JsonProperty("reference")
@NotNull
public String getReference() {
return reference;
}
<build>
<plugins>
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<configuration>
<outputFileName>openapi</outputFileName>
<outputPath>${project.build.directory}/generatedtest</outputPath>
<outputFormat>JSONANDYAML</outputFormat>
<prettyPrint>TRUE</prettyPrint>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Swagger - it is an API specification that describes your Web service. Swagger - 它是一个 API 规范,描述了您的 Web 服务。 You cannot have a specification of Web service without having at least one Web service.
如果没有至少一个 Web 服务,就不能拥有 Web 服务规范。
@ApiModel
annotation just describes the structure of the model which is used in your Web service. @ApiModel
注释仅描述了 Web 服务中使用的 model 的结构。 Without using this model in the Web service, this annotation is useless.在Web服务中不使用这个model,这个注解是没有用的。
Thereby, you are getting an expected result - there are no Swagger specification if you don't have at least one Web service.因此,您将获得预期的结果 - 如果您没有至少一个 Web 服务,则没有 Swagger 规范。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.