Mermade / openapi-lint-vscode

OpenAPI 2.0/3.0.x intellisense, validator, linter, converter and resolver extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=mermade.openapi-lint
BSD 3-Clause "New" or "Revised" License
51 stars 9 forks source link

OpenApi 3.x validation error when "servers" object is present #9

Closed hecsalazar closed 5 years ago

hecsalazar commented 5 years ago

When adding the servers section with a basic object with only the url mandatory property the validation fails stating that the url property is expected. This can be reproduced with the OpenApi 3.x Jamal samples

hecsalazar commented 5 years ago

Sample file to reproduce, if the "servers" section is commented validation passes

openapi: 3.0.0
info:
  title: Sample API
  description: Optional multiline or single-line description in [CommonMark](http://commonmark.org/help/) or HTML.
  version: 0.1.9
servers:
  - url: http://api.example.com/v1
    description: Optional server description, e.g. Main (production) server

paths:
  /users:
    get:
      summary: Returns a list of users.
      description: Optional extended description in CommonMark or HTML.
      responses:
        '200':    # status code
          description: A JSON array of user names
          content:
            application/json:
              schema: 
                type: array
                items: 
                  type: string
MikeRalphson commented 5 years ago

Hmm, I can't see any errors with your example file either with the intellisense or the OpenAPI Validate command. If you use the OpenAPI Lint command it complains about the servers.url property containing example.com, but that is expected.

Please can you let me know the filename you are using and the version of the extension you have installed?

hecsalazar commented 5 years ago

filename: vscode_lint_sample.yaml extension version: openapi-lint 1.0.2

Here's a sample capture of failure of "OpenApi Validate" with the above example

vscode_openapi_error

MikeRalphson commented 5 years ago

Sorry, I still can't reproduce this, so I can only assume there's an interaction with another vscode extension.

hecsalazar commented 5 years ago

Tried disabling other extensions related to open api and swagger, I get the same result:

image image image

hecsalazar commented 5 years ago

Here's my full list of extensions:

code --list-extensions

adashen.vscode-tomcat
AlanWalk.markdown-toc
Arjun.swagger-viewer
bat67.markdown-extension-pack
bierner.markdown-emoji
bierner.markdown-preview-github-styles
bungcip.better-toml
cstuder.gitlab-ci-validator
darkriszty.markdown-table-prettify
DavidAnson.vscode-markdownlint
eriklynd.json-tools
fatihacet.gitlab-workflow
faustinoaq.javac-linter
foxundermoon.shell-format
fwcd.kotlin
goessner.mdmath
ipedrazas.kubernetes-snippets
mathiasfrohlich.Kotlin
mauve.terraform
mermade.openapi-lint
momoto.binary-viewer
ms-azuretools.vscode-docker
ms-kubernetes-tools.vscode-kubernetes-tools
ms-python.python
ms-vscode-remote.remote-wsl
ms-vscode.cpptools
ms-vscode.Go
ms-vscode.powershell
ms-vsliveshare.vsliveshare
philosowaffle.openapi-designer
Pivotal.vscode-spring-boot
redhat.java
redhat.vscode-yaml
shd101wyy.markdown-preview-enhanced
shengchen.vscode-checkstyle
sidneys1.gitconfig
slevesque.vscode-hexdump
VisualStudioExptTeam.vscodeintellicode
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
vscjava.vscode-spring-initializr
yzane.markdown-pdf
yzhang.markdown-all-in-one
zoellner.openapi-preview
zxh404.vscode-proto3
MikeRalphson commented 5 years ago

@dariusj18 you reacted with a :+1: to the original issue, are you also running any of @hecsalazar 's extensions?

dariusj18 commented 5 years ago

Here's my extension list

adisreyaj.swagger-snippets
alefragnani.Bookmarks
alefragnani.project-manager
Arjun.swagger-viewer
bbenoist.vagrant
bmarkovic.haproxy
bmewburn.vscode-intelephense-client
christian-kohler.npm-intellisense
CoenraadS.bracket-pair-colorizer
crasnam.elasticdeveloper
cssho.vscode-svgviewer
dakara.dakara-foldplus
donjayamanne.githistory
DotJoshJohnson.xml
dssiqueira.drupal-8-snippets
eamodio.gitlens
EditorConfig.EditorConfig
eg2.vscode-npm-script
esbenp.prettier-vscode
felixfbecker.php-debug
fknop.vscode-npm
formulahendry.auto-close-tag
formulahendry.auto-rename-tag
hdg.live-html-previewer
ikappas.composer
ikappas.phpcs
jakelucas.code-select-until
jmlv.MeteorSnippets
johnpapa.vscode-peacock
KamasamaK.vscode-cfml
karigari.chat
lindraupe.aw-watcher-vscode
marcostazi.VS-code-drupal
marcostazi.VS-code-vagrantfile
mechatroner.rainbow-csv
mermade.openapi-lint
mikestead.dotenv
mkloubert.vscode-deploy-reloaded
mrmlnc.vscode-apache
mrmlnc.vscode-autoprefixer
ms-azuretools.vscode-docker
ms-kubernetes-tools.vscode-kubernetes-tools
ms-mssql.mssql
ms-python.python
ms-vscode-remote.remote-wsl
ms-vscode.powershell
ms-vsliveshare.vsliveshare
ms-vsliveshare.vsliveshare-audio
ms-vsliveshare.vsliveshare-pack
msjsdiag.debugger-for-chrome
mtxr.sqltools
neilbrayfield.php-docblocker
oderwat.indent-rainbow
onecentlin.laravel-blade
philosowaffle.openapi-designer
ramonitor.meteorhelper
RandomChance.logstash
redhat.java
redhat.vscode-yaml
ria.elastic
ritwickdey.LiveServer
ryannaddy.laravel-artisan
santigarcor.phpunit-extended
slevesque.vscode-autohotkey
spywhere.guides
streetsidesoftware.code-spell-checker
thomas-baumgaertner.vcl
tomoki1207.vscode-input-sequence
Tyriar.lorem-ipsum
vscode-icons-team.vscode-icons
vuhrmeister.vscode-meteor
whatwedo.twig
MikeRalphson commented 5 years ago

Common extensions are:

ms-azuretools.vscode-docker
ms-kubernetes-tools.vscode-kubernetes-tools
ms-python.python
ms-vscode.powershell
ms-vscode-remote.remote-wsl
ms-vsliveshare.vsliveshare
redhat.java

Arjun.swagger-viewer philosowaffle.openapi-designer

Ignoring redhat.vscode-yaml and mermade.openapi-lint, I don't have any of those extensions installed. I've also struck-through the ones already disabled by @hecsalazar

I tried installing redhat.java as it looks to be the only non-MS one there, but it failed as I jave no JDK (and no desire to install one).

MikeRalphson commented 5 years ago

Something (presumably an extension) definitely appears to be polluting the Array prototype.

dariusj18 commented 5 years ago

Seems to be ms-kubernetes-tools.vscode-kubernetes-tools

hecsalazar commented 5 years ago

Seems to be ms-kubernetes-tools.vscode-kubernetes-tools

I confirm, when disabling that extension It the validation works, I reenabled and the error appears.

@MikeRalphson I suggest to debug to confirm if it's an issue in Microsoft extension and report to them or mermade itself to move forward on a fix

MikeRalphson commented 5 years ago

Please refer / subscribe to https://github.com/Azure/vscode-kubernetes-tools/issues/613

MikeRalphson commented 5 years ago

Added some forced pollution cleanup code in mermade.openapi-lint@1.0.4

It would be great to get confirmation that this resolves the issue.

hecsalazar commented 5 years ago

I confirmed it works with microsoft kubernetes extension enabled.

Important tip: you need to update and restart vscode, in my first try I just updated just the extension and didn't work.

On Mon, Sep 9, 2019 at 1:44 PM Mike Ralphson notifications@github.com wrote:

Added some forced pollution cleanup code in mermade.openapi-lint@1.0.4

It would be great to get confirmation that this resolves the issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Mermade/openapi-lint-vscode/issues/9?email_source=notifications&email_token=ACSBHDL6AU2UCAR3ZBZSHELQI2DRDA5CNFSM4HBDNCW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6IORXQ#issuecomment-529590494, or mute the thread https://github.com/notifications/unsubscribe-auth/ACSBHDKMLNGAIVW6O6EMSJDQI2DRDANCNFSM4HBDNCWQ .

MikeRalphson commented 5 years ago

Thanks for everyone's help in tracking down the cause of this behaviour.