Skip to content

Online editor reports several nonsensical errors #1519

@ztrange

Description

@ztrange

Bug

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 3.0.0
Which Swagger-Editor version? 3.1.9
How did you install Swagger-Editor? npm i -S swagger-editor-dist
Which broswer & version? chrome 62
Which operating system? ubuntu 17.04

Demonstration API definition

openapi: 3.0.0
info:
  title: Example API
  description: Service API.
  version: 1.0.0
servers:
  - url: 'http://api.example.com'
paths:
  /login/local:
    post:
      tags:
        - login
      summary: Login using email or nickname
      description: Returns customer info and jwt access and refresh tokens
      security:
        - apiKey: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                emailOrNickname:
                  type: string
                  required: true
                password:
                  type: string
                  required: true
      responses:
        '200':
          description: Login successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  customer:
                    $ref: "#/components/schemas/Admin"
                  refreshToken:
                    type: string
        "401":
          description: "Unauthorized"
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: x-application-key
  schemas:
    Admin:
      type: object
      properties:
        _id:
          type: string
        name:
          type: object
          properties:
            first:
              type: string
            last:
              type: string
        email:
          type: object
          properties:
            address:
              type: string
            verified:
              type: boolean
            token:
              type: string
        password:
          type: string
        recoveryToken:
          type: string
        lastLogin:
          type: string
          format: date-time

Configuration (browser query string, constructor, config.yaml)

I'm using the default config

const editor = SwaggerEditorBundle({
      dom_id: '#swagger-editor',
      layout: 'StandaloneLayout',
      presets: [
        SwaggerEditorStandalonePreset
      ]
    })

Expected Behavior

I think my path definition is correct. I've read and re-read the 3.0 spec several times, I based my code on the examples on spec but I still get several weird errors: Mainly I don't want to use a component $ref on the requestBody. I've seen example code on the spec documentation and it looks like I should have that option

Current Behavior

Errors
Hide
Schema error at paths['/login/local'].post.requestBody
should have required property '$ref'
missingProperty: $ref
Jump to line 17
Schema error at paths['/login/local'].post.requestBody
should match exactly one schema in oneOf
Jump to line 17
Schema error at paths['/login/local'].post.requestBody.content['application/json']
should have required property 'examples'
missingProperty: examples
Jump to line 19
Schema error at paths['/login/local'].post.requestBody.content['application/json']
should match exactly one schema in oneOf
Jump to line 19
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema
should have required property '$ref'
missingProperty: $ref
Jump to line 20
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema
should match exactly one schema in oneOf
Jump to line 20
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema.properties['emailOrNickname']
should have required property '$ref'
missingProperty: $ref
Jump to line 23
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema.properties['emailOrNickname']
should match exactly one schema in oneOf
Jump to line 23
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema.properties['emailOrNickname'].required
should be array
Jump to line 25
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema.properties['password']
should have required property '$ref'
missingProperty: $ref
Jump to line 26
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema.properties['password']
should match exactly one schema in oneOf
Jump to line 26
Schema error at paths['/login/local'].post.requestBody.content['application/json'].schema.properties['password'].required
should be array
Jump to line 28

Context

I'm trying to migrate some bad documentation to something better using swagger 3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions