简体   繁体   English

Swagger: maven 插件不生成 Api ZA559B87068921EEC0584086CE54Z5E

[英]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.

相关问题 Open API Maven Plugin - 只生成特定的 API 模型类 - Open API Maven Plugin - Generate only specifc API model classes swagger-maven-plugin不会为各个请求映射生成“路径”元素 - swagger-maven-plugin does not generate “paths” elements for individual request mappings 如何使用 swagger-codegen-maven 插件在 boolean 上生成 getter - how to generate getter on boolean using swagger-codegen-maven plugin 如何使用maven-swagger-codegen-plugin生成文档? - How generate documentation with maven-swagger-codegen-plugin? 如何使用 swagger-codegen-plugin (maven) 生成客户端代码? - How to generate client code using with swagger-codegen-plugin (maven)? 如何使用 springdoc-openapi-maven-plugin 和 swagger-codegen-maven-plugin 生成客户端代码? - How to generate client code using springdoc-openapi-maven-plugin and swagger-codegen-maven-plugin? maven jacoco 插件不生成覆盖率报告 - maven jacoco plugin does not generate coverage report 删除 swagger-codegen-maven-plugin api class 中的 ResponseEntity - Remove ResponseEntity in swagger-codegen-maven-plugin api class maven-jar-plugin 不生成清单 - maven-jar-plugin does not generate MANIFEST OpenAPI Generator 不生成 api 接口 openapi-generator-maven-plugin - OpenAPI Generator does not generate api interfaces openapi-generator-maven-plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM