swagger-editor: SwaggerEditor@next: false positive in linting JSON Schema

Q&A (please complete the following information)

  • OS: macOS
  • Browser: Chrome
  • Version: 111.0.5563.110
  • Method of installation: None. This is at https://editor-next.swagger.io/
  • Swagger-UI version: Unknown
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.0.3
info:
  title: Test
  version: 1.0.0
components:
  schemas:
    ObjectOne:
      type: object
      properties:
        propertyOne:
          type: string
    ObjectTwo:
      type: object
      properties:
        propertyTwo:
          type: string
paths:
  /test:
    post:
      requestBody: 
        content:
          application/json:
            schema: 
              oneOf:
                - $ref: '#/components/schemas/ObjectOne'
                - $ref: '#/components/schemas/ObjectTwo'
        required: true
      responses:
        '204':
          description: Successful operation

Swagger-UI configuration options: None

Describe the bug you’re encountering

The editor shows an error on line 23 saying, “oneOf must be a non-empty array of schemas” but it is an array of schemas.

To reproduce…

Steps to reproduce the behavior:

  1. Go to https://editor-next.swagger.io/.
  2. Enter the YAML above.
  3. See error.

Expected behavior

No errors or warnings.

Screenshots

OAS

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 8
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

It looks like the main issue is with allOf, oneOf and anyOf keywords. I’ll try to see if I can provide a quick bug fix for those (without doing all the lengthy consolidation effort).

Yes, its working perfect now! Thanks @char0n.

Is this really fixed? I’ve tested on https://editor-next.swagger.io/ the example usage of the oneOf presented in the docs:

openapi: "3.0.0"
info:
  title: Simple API overview
  version: 2.0.0
paths:
  /pets:
    patch:
      requestBody:
        content:
          application/json:
            schema:
              oneOf:
                - $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

Still giving the same error: image

I have the same issue too. It also happens with allOf.