[英]Open API Maven Plugin - Generate only specifc API model classes
[英]Swagger: maven plugin does not generate Api Model
我正在嘗試使用僅 ApiModel 的代碼優先方法生成 YAML 和 JSON 文件。 我希望 swagger-maven-plugin 只生成這個。 我沒有任何 web 服務。 但它不會像 output 那樣產生任何東西。 當我添加 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 - 它是一個 API 規范,描述了您的 Web 服務。 如果沒有至少一個 Web 服務,就不能擁有 Web 服務規范。
@ApiModel
注釋僅描述了 Web 服務中使用的 model 的結構。 在Web服務中不使用這個model,這個注解是沒有用的。
因此,您將獲得預期的結果 - 如果您沒有至少一個 Web 服務,則沒有 Swagger 規范。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.