swagger-editor icon indicating copy to clipboard operation
swagger-editor copied to clipboard

Comment for a $ref in definition fires a semantic error.

Open Cooker-Monster opened this issue 9 years ago โ€ข 13 comments

New editor defines "Sibling values are not allowed alongside a $ref." as a Semantic Error as the previous one defined it as a Warning.

I think that put a comment for a $ref is not a semantic error. Rolling back as warning could be nice (in fact, allowing comment on $ref without warning won't offend me).

Cooker-Monster avatar Apr 27 '17 23:04 Cooker-Monster

Can't reproduce this.

I tried this, and only got a resolver error for the non-existent path:

swagger: "2.0"
info:
  description: "This is a sample server Petstore server.  You can find out more about     Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For this sample, you can use the api key `special-key` to test the authorization     filters."
  version: "1.0.0"
  title: "Swagger Petstore"
host: "petstore.swagger.io"
basePath: "/v2"
schemes:
- "http"
paths:
  /:
    # hello, this is a comment
    $ref: "#/some/path"

@Cooker-Monster, can you provide a test spec for this?

shockey avatar Apr 28 '17 01:04 shockey

@shockey

swagger: "2.0"
info:
  description: "This is a sample server Petstore server.  You can find out more about     Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).      For this sample, you can use the api key `special-key` to test the authorization     filters."
  version: "1.0.0"
  title: "Swagger Petstore"
host: "petstore.swagger.io"
basePath: "/v2"
schemes:
- "http"
paths:
  /:
    get:
      responses:
        200:
          $ref: '#/responses/test'
          schema:
            type: string
          
responses:
  test:
    description: hello

webron avatar Apr 28 '17 01:04 webron

Alright, I read this wrong ๐Ÿ˜„

Fixing.

shockey avatar Apr 28 '17 05:04 shockey

Fast & efficient => congrats !!!

Cooker-Monster avatar Apr 28 '17 09:04 Cooker-Monster

It seems that current online swagger editor is not up to date ?

image

matthieugeerebaert avatar Jan 11 '18 16:01 matthieugeerebaert

@matthieugeerebaert, itโ€™s up to date ๐Ÿ˜„ that error looks valid, you canโ€™t have any other values alongside a $ref, because $ref works by replacing itself and everything on its level with the data it is pointing at.

see https://github.com/swagger-api/swagger-editor/issues/1184 for more context on this.

shockey avatar Jan 11 '18 17:01 shockey

Oups sorry ! I read this issue too quickly, it's only about comment, thought it was a general issue that semantic "Sibling values are not allowed alongside a $ref" should only be warning. And yes #1184 is my current problem. We have hundred of swaggers with attribute description and definition description :( Having now those "Error" is a major problem, I was trying to find honorable workaround :) Sorry for my bad interpretation Shockey ;)

matthieugeerebaert avatar Jan 11 '18 18:01 matthieugeerebaert

Hey so using comment instead of description might be a good workaround, thank you !

matthieugeerebaert avatar Jan 11 '18 18:01 matthieugeerebaert

@matthieugeerebaert no problem!

I just realized that our new validation system is actually reporting this as an error again, so there was something to fix here after all ๐Ÿ˜„

shockey avatar Jan 11 '18 18:01 shockey

Thank you Shockey, perfect !

matthieugeerebaert avatar Jan 29 '18 16:01 matthieugeerebaert

Hi @shockey, is there any progress here?

TIA, Matteo

scara avatar Feb 21 '18 14:02 scara

hi @scara, this is fixed!

shockey avatar Mar 07 '18 03:03 shockey

TNX @shockey for the follow up! Didn't try by myself before your last comment.

Everything looks OK now: a gently warning is fired in the editor while nothing appears in the viewer pane.

scara avatar Mar 07 '18 07:03 scara