简体   繁体   English

Swagger注释-没有参数时不包括参数吗?

[英]Swagger Annotation - not to include parameter when there is no parameter?

I have swagger-jersey2-jaxrs 1.5.1-M2 integrated with Drop-wizard. 我有与Drop-wizard集成的swagger-jersey2-jaxrs 1.5.1-M2。 I have generated the following yaml with the swagger annotations I have included on my resource and models: 我使用资源和模型中包含的大头贴注释生成了以下yaml:

    ---
swagger: "2.0"
info:
  version: "1.0.0"
  title: "test Application"
tags:
- name: "test"
paths:
  /v1/test/version:
    get:
      tags:
      - "v1test"
      summary: "version number of test"
      description: "Returns version number of test"
      operationId: "getVersionAndBuildInfo"
      produces:
      - "application/json"
      parameters: 
      responses:
        404:
          description: "build number not found."
        200:
          description: "successful operation"
          schema:
            type: "array"
            items:
              $ref: "#/definitions/testInformation"
definitions:
  testInformation:
    properties:
      build:
        type: "string"
        description: "test build number"
      version:
        type: "string"
        description: "test version number"
      buildTimestamp:
        type: "string"
        description: "test build timestamp"
    description: "model for test version information"

notice that parameters: is include in the generated yaml from swagger. 注意, 参数:是包含在从摇号生成的yaml中的。 when I paste this in the swagger editor 2.0 it is throwing an error saying "Array is too short (0), minimum 1". 当我将其粘贴到swagger编辑器2.0中时,它抛出一个错误,提示“数组太短(0),最小值为1”。

Is there a way not to generate the parameters: in yaml when the URL does not require any parameters? 有没有一种方法可以不生成参数:在yaml中,如果URL不需要任何参数? I didn't include any parameter annotation and it still shows up on the generated yaml. 我没有包含任何参数注释,它仍然显示在生成的Yaml中。

We had a bug in the JSON Schema for Swagger definitions that didn't allow for an empty parameters. Swagger定义的JSON模式中存在一个错误,该错误不允许使用空参数。 This was fixed, and is going to be available in swagger-editor as well soon. 此问题已修复,很快将在swagger-editor中可用。

Please follow https://github.com/swagger-api/swagger-editor/issues/395 to see when it is updated. 请遵循https://github.com/swagger-api/swagger-editor/issues/395查看更新时间。

There's no point trying to 'solve' this issue in the generation process because the output is not wrong. 没有必要尝试在生成过程中“解决”此问题,因为输出没有错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM