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

json.canParse = false, but is validating.

Open brunopenso opened this issue 5 years ago • 0 comments

Hi Guys,

I'm using the validator but I would like to avoid json validation, so I set my validator to this:

  const obj = await SwaggerParser.validate(filePath, {
    parse: {
      json: {
        canParse: false,
        order: 1000,
        allowEmpty: false
      },
      yaml: {
        allowEmpty: false, // Don't allow empty YAML files
        canParse: true,
        order: 0
      },
      text: {
        canParse: false
      }
    },
    resolve: {
      external: true
    },
    validate: {
      schema: true,
      spec: false
    }
  })

When I execute this code with a JSON file the file got validated. Reading the documentation I understood that I can disable JSON validation, so I would expect and error.

Am I right? Maybe, Am I doing something wrong?

Versions: "@apidevtools/swagger-parser": "^10.0.1" Node: v12.18.3

brunopenso avatar Sep 25 '20 21:09 brunopenso