首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >路径处的架构错误不应具有其他属性additionalProperty: type、items、name、in、description、required

路径处的架构错误不应具有其他属性additionalProperty: type、items、name、in、description、required
EN

Stack Overflow用户
提问于 2018-05-31 13:42:27
回答 1查看 4.6K关注 0票数 0

我在Swaggerhub编辑器上看到以下3个错误

路径‘/addWish.php’.post.parameters6处的

架构错误不应具有其他属性additionalProperty:类型、项目、名称、在、描述、必需的跳转到第74行

路径‘/addWish.php’.post.parameters6.in处的架构错误应等于允许值之一allowedValues: header,formData,query,path跳到第75行

路径‘/addWish.php’.post.parameters6.Items不应具有附加属性additionalProperty:$ref跳至第79行时出现架构错误

我的yaml代码附在下面。我是API文档的新手,所以请帮助我。

代码语言:javascript
复制
   swagger: '2.0'
info:
  description: |
    This is a sample iGaze server.  You can find 
    out more about Swagger
  version: 1.0.0
  title: iGaze Wishlist
  termsOfService: http://swagger.io/terms/
  contact:
    email: apiteam@swagger.io
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
#  host: localhost/iGaze
# basePath: /v2
tags:
- name: wish
  description: Everything about your wishes
  externalDocs:
    description: Find out more
    url: localhost/iGaze
- name: store
  description: Access to Petstore orders
- name: user
  description: Operations about user
  externalDocs:
    description: Find out more about our store
    url: localhost/iGaze
# schemes:
# - http
paths:
  /addWish.php:
    post:
      tags:
      - Wish
      summary: Add a new wish
      operationId: addWish
      consumes:
      - application/json
      parameters:
      - name: wishPrefix
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
      - name: wish
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
      - name: targetDate
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
        format: date
      - name: sharingType
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: integer
      - name: latitude
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: number
        format: double 
      - name: longitude
        in: path
        description: Updated name of the pet
        required: true
        type: number
        format: double
      - name: wishType  <-- Line 74
        in: body  <-- Line 75
        description: Updated name of the pet
        required: true
        type: array
        items:  <-- Line 79
          $ref: '#/definitions/Types'
      - name: userDetailsId
        in: path
        description: ID of pet that needs to be updated
        required: true
        type: string
      responses:
        200:
          description: successful operation
          schema:
            type: integer
        400:
          description: Invalid status value

  /getWishTypes.php:
    get:
      tags:
      - Types
      summary: Get Wish Types
      description:  get all wish types like dream,achievement
      operationId: getWishTypes
      produces:
      - application/json
      responses:
        200:
          description: successful operation
          schema:
            type: array
            items:
              $ref: '#/definitions/Types'
        400:
          description: Invalid status value
definitions:
  Types:
    type: object
    properties:
      wishTypesId:
        type: integer
      wishType:
        type: string
  Wish:
    type: object
    properties:
      wishId:
        type: integer
      wishPrefix:
        type: string
      wish:
        type: string
      targetDate:
        type: string
        format: date
      sharingType:
        type: integer
      latitude:
        type: number
        format: double
      longitude:
        type: number
        format: double
      userDetailsId:
        type: integer
      wishType:
        type: array
        items:
            $ref: '#/definitions/Types'

# Added by API Auto Mocking Plugin
host: virtserver.swaggerhub.com
basePath: /test7115/demo/1.0.0
schemes:
 - https
 - http
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-31 18:50:27

1)需要将in: body参数的类型封装到schema关键字中。这与直接使用type的查询/路径/标题/表单参数不同。

代码语言:javascript
复制
      - name: wishType
        in: body
        description: Updated name of the pet
        required: true
        schema:   # <---------
          type: array
          items:
            $ref: '#/definitions/Types'

2) in: path参数是端点路径的一部分,需要在端点路径中明确提及:

代码语言:javascript
复制
/addWish.php/{wishPrefix}/{wish}:

如果您指的是查询参数,请将参数类型更改为in: query

代码语言:javascript
复制
paths:
  /addWish.php:
    post:
      ...
      parameters:
      - name: wishPrefix
        in: query   # <----------
        required: true
        type: string
      ...
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50617376

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档