首页 > 解决方案 > 如何在 swagger ui 中指定参数对象

问题描述

我在 swagger 编辑器中运行了一个 yml 文件,尽管下面发布的代码中设置的参数是正确的,但我输入的浮点经度和纬度值不被 swagger ui 接受

请让我知道如何解决此错误

代码

paths:
  /getDistance/{startAndEndCoords}:
    get:
      tags: 
        - get distance
        - get distance in kilometers
      summary: get the distance between two GPS coordinates in Kilometers.
      description:  > 
        startAndEndCoords represents the start and end GPS coordinates in the following order longitude and latitude respectively. Passing the start and end
        GPS cootdinates in the URL will result in invoking and communicating with OpenRouteService. The latter service will send a response in a form of json
        file.The JSON file will be fetched for the distance. The distance fetched, is the distance between the GPS coordinates entered and it is in meters, however
        they are displayed to the users in Kilometers.
      operationId:  getDistance
      parameters:
        - name: startAndEndCoords
          in: path
          description: Start and end GPS coordinates as comma separated values in terms of longitude and latitude respectively. For example 
            12.497366,41.922782,-3.606997572,40.47416477
          required: true
          schema:
            type: number
            format: float
          allowEmptyValue: false
      responses:
        '200':
          description: Distance fetched successfully.

标签: swaggerswagger-uiopenapiswagger-editor

解决方案


推荐阅读