[您好,我使用的是招摇工具3.0.0。oneOf操作在这里也不起作用?错在哪里?

问题描述 投票:0回答:1

这是代码。当我编写allOF而不是oneOF时,那么一切都很好,但是使用oneOf则不会显示任何内容,也没有错误。我写错什么了吗,或者它在swagger 3.0.0中仍然不起作用。同样,任何一个都不是正常的。或者我们有一个像oneOf那样的东西,但是在摇摇欲坠的2.0中]

openapi: 3.0.0
servers:
  - url: 'http://petstore.swagger.io/v2'
x-origin:
  - url: 'http://petstore.swagger.io/v2/swagger.json'
    format: swagger
    version: '2.0'
    converter:
      url: 'https://github.com/mermade/swagger2openapi'
      version: 2.2.0
info:
  description: 'This is a sample.'
  version: 1.0.0
  title: Swagger Petstore
  termsOfService: 'http://swagger.io/terms/'
  contact:
    email: [email protected]
  license:
    name: Apache 2.0
    url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
  - name: pet
    description: Everything about your Pets
    externalDocs:
      description: Find out more
      url: 'http://swagger.io'
  - name: store
    description: Access to Petstore orders
  - name: user
    description: Operations about user
    externalDocs:
      description: Find out more about our store
      url: 'http://swagger.io'
paths:
  /something:
     post:
        requestBody:
         required: true
         content:
           application/json:
             schema:
               oneOf:
                 - $ref: '#/components/schemas/Dog'
                 - $ref: '#/components/schemas/Cat'
        responses:
          '200':
            description: Updated         
components:
  schemas:
    Dog:
      type: object
      properties:
        bark:
          type: boolean
        breed:
          type: string
          enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:
      type: object
      properties:
        hunts:
          type: boolean
        age:
          type: integer

这是代码。当我编写allOF而不是oneOF时,那么一切都很好,但是使用oneOf则不会显示任何内容,也没有错误。我写错了什么,还是仍然无法正常工作...] >

swagger swagger-ui swagger-editor openapi
1个回答
0
投票

swagger-ui-express 4.1.12不支持oneof,anyof版本

openapi: 3.0.1
tags:
  - name: API Specification
    description: All endpoints and payloads about Project
paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
                - $ref: '#/components/schemas/Cat'
                - $ref: '#/components/schemas/Dog'

      responses:
        '200':
          description: Updated
components:
  schemas:
    Dog:
      type: object
      properties:
        bark:
          type: boolean
        breed:
          type: string
          enum: [Dingo, Husky, Retriever, Shepherd]
    Cat:
      type: object
      properties:
        hunts:
          type: boolean
        age:
          type: integer
© www.soinside.com 2019 - 2024. All rights reserved.