Swagger:maven 插件不生成 Api 模型
Swagger: maven plugin does not generate Api Model
我正在尝试使用仅使用 ApiModel 的代码优先方法生成 YAML 和 JSON 文件。
我想让 swagger-maven-plugin 只生成这个。我没有任何网络服务。
但它不会产生任何输出。
当我添加 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 - 它是描述 Web 服务的 API 规范。
如果没有至少一项 Web 服务,则无法获得 Web 服务规范。
@ApiModel
注释只是描述了您的 Web 服务中使用的模型的结构。不在Web服务中使用这个模型,这个注解是没有用的。
因此,您将获得预期的结果 - 如果您没有至少一项 Web 服务,则没有 Swagger 规范。
我正在尝试使用仅使用 ApiModel 的代码优先方法生成 YAML 和 JSON 文件。 我想让 swagger-maven-plugin 只生成这个。我没有任何网络服务。 但它不会产生任何输出。 当我添加 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 - 它是描述 Web 服务的 API 规范。 如果没有至少一项 Web 服务,则无法获得 Web 服务规范。
@ApiModel
注释只是描述了您的 Web 服务中使用的模型的结构。不在Web服务中使用这个模型,这个注解是没有用的。
因此,您将获得预期的结果 - 如果您没有至少一项 Web 服务,则没有 Swagger 规范。