Hello,I am using swagger 3.0.0.The operation oneOf is not working here too?Where is the mistaken?

2k Views Asked by At

here is the code.When I write allOF instead oneOF then everything is ok,but with oneOf it doesn't show anything and there is no error.Did I write something wrong or it is still not working in swagger 3.0.0.Also any of is not woking.Or do we have something like oneOf but in swagger 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
1

There are 1 best solutions below

0
On

swagger-ui-express 4.1.12 not supporting oneof,anyof version

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