繁体   English   中英

Swagger 2.0 - 定义中的结构错误。testPOST 不应具有其他属性

[英]Swagger 2.0 - Structural error at definitions.testPOST should NOT have additional properties

我正在尝试在我的 swagger 2.0 中添加一个数组,但我不断收到以下错误:

Structural error at definitions.testPOST
should NOT have additional properties
additionalProperty: testRequests

我已经检查了招摇文档,但我不知道我做错了什么。 我可以删除“testRequests”,但我需要它。

代码如下:

swagger: '2.0'
info:
  version: v1
  title: testAPI
security:
  - default: []
paths:
  /testPOST:
    post:
      summary: test
      description: test
      parameters:
        - in: body
          name: Payload
          description: test
          required: true
          schema:
            $ref: '#/definitions/testPOST'
      responses:
        '201':
          description: Success
          schema:
            type: object
            properties:
              status:
                type: string
                description: HTTP statuscode
              title:
                type: string
                description: Success
              detail:
                type: string
                description: Empty
        '401':
          description: No access
          schema:
            type: object
            properties:
              status:
                type: string
                description: HTTP statuscode
              title:
                type: string
                description: Message invalid
              detail:
                type: string
                description: Error message
        '500':
          description: Server error
      security:
        - default:
            - testRequest
      x-auth-type: Application & Application User
      x-throttling-tier: Unlimited
      x-wso2-application-security:
        security-types:
          - oauth2
        optional: false
    x-auth-type: Application & Application User
    x-throttling-tier: Unlimited
securityDefinitions:
  default:
    type: oauth2
    authorizationUrl: 'https://test.com'
    flow: implicit
    scopes:
      testRequest: Scope
    x-scopes-bindings:
      testRequest: 'testRequest,admin'
definitions:
  testPOST:
    testRequests:
      type: array
      items:
        type: object
        properties:
          sourceUrl:
            type: string
            example: 'http://example.com/test/1202112'
            description: The reference url.
            default: 'null'
          inboundReferenceNumber:
            type: string
            example: '1234567890'
            description: The request identifier.
            default: 'null'

有人可以指出我做错了什么吗? 提前致谢!

如果请求正文应该只是一个对象数组

[
  {"sourceUrl": ...},
  {"sourceUrl": ...},
  ...
]

那么定义应该是:

definitions:
  testPOST:     # Remove the "testRequests:" line from here
    type: array
    items:
      ..

如果请求正文应该是具有testRequests属性的对象,其值为数组

{
  "testRequests": [
    {"sourceUrl": ...},
    {"sourceUrl": ...},
    ...
  ]
}

那么定义应该是:

definitions:
  testPOST:
    type: object
    properties:
      testRequests:
        type: array
        items:
          type: object
          properties:
            sourceUrl:
              ...
            inboundReferenceNumber:
              ...

暂无
暂无

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

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