Skip to content

Editor validating invalid definition #756

@Growiel

Description

@Growiel

Hello,

Disclaimer: I first opened this in Swagger-UI (swagger-api/swagger-ui#1838) but as it turns out, the UI was correct for not validating my definition and the Editor was wrong to validate it, as the definition is incorrect.

Here's the file (slimed down to the minimums):

swagger: '2.0'
info:
  title: Example
  description: Example
  version: 1.0.0
host: 'example.com'
basePath: /
schemes:
  - http
produces:
  - application/json
paths:
  /rest_auth:
    $ref: '#/x-paths-definitions/auth_index'
  /rest_auth/login:
    post:
      $ref: '#/x-paths-definitions/auth_index/post'
x-paths-definitions:
  auth_index:
    post:
      tags:
        - Auth
      summary: Logs the user in
      description: |
        Tests a pair of user_id and password to log the user in.
        <br /><br />
        Aliases: /rest_auth/login, /rest_auth
      parameters:
        - name: body
          in: body
          description: The user_id and password of the user trying to login.
          required: true
          schema:
            required:
              - user_id
              - password
            properties:
              user_id:
                type: string
              password:
                type: string
            type: object
      responses:
        '200':
          description: User object of the newly logged-in user + user_cd + blog_cd
          schema:
            properties:
              user:
                type: object
              user_cd:
                type: integer
              blog_cd:
                type: integer
            type: object

This issue is that I'm using $ref inside an HTTP Verb (/rest_auth/login/post) and that's not correct according to the specifications (a specific HTTP verb must be an Operation Object and operation objects cannot be references).

Here's an image of what is rendering in the Editor:
Editor rendering
No errors, it's rendering as if the specification was correct.

Here's what Swagger-UI is doing:
UIrendering
The endpoint using the $ref is empty, as it should.

It's very disturbing when you get a perfectly fine display in the editor, export it to show your colleagues and then it's just not working in the UI.
My first instinct (and hope) was that the UI was wrong, but as it turns out it's the editor.

The editor should tell me that $ref is not usable here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions