Git Product home page Git Product logo

Comments (4)

JamesMessinger avatar JamesMessinger commented on June 12, 2024

Hi. Thanks for the bug report, but I'm not able to reproduce it. For example, the following Swagger file validates fine for me:

my-api.yaml

swagger: '2.0'

info:
  version: "0.0.0"
  title: Hello World

paths:
  /hello:
    get:
      responses:
        200:
          description: hello world

bash

> swagger validate my-api.yaml 
> my-api.yaml is valid

from swagger-cli.

JamesMessinger avatar JamesMessinger commented on June 12, 2024

Swagger CLI uses Swagger Parser to do its validation. So any Swagger file that validates successfully here will also pass Swagger CLI

from swagger-cli.

jdevera avatar jdevera commented on June 12, 2024

This one fails, though:

swagger: '2.0'

info:
  version: "0.0.0"
  title: Hello World

paths:
  /hello:
    get:
      parameters:
      responses:
        200:
          description: hello world
$ swagger validate test.yaml

SyntaxError: Swagger schema validation failed.
  Expected type array but found type null at #/paths//hello/get/parameters

JSON_OBJECT_VALIDATION_FAILED
    at Function.ono [as syntax] (/home/jdevera/node_modules/ono/lib/index.js:67:20)
    at validateSchema (/home/jdevera/node_modules/swagger-parser/lib/validate-schema.js:29:15)
    at /home/jdevera/node_modules/swagger-parser/lib/index.js:144:9

z-schema validation error: JSON_OBJECT_VALIDATION_FAILED
    at ZSchema.getLastError (/home/jdevera/node_modules/z-schema/src/ZSchema.js:221:13)
    at validateSchema (/home/jdevera/node_modules/swagger-parser/lib/validate-schema.js:27:23)
    at /home/jdevera/node_modules/swagger-parser/lib/index.js:144:9

from swagger-cli.

JamesMessinger avatar JamesMessinger commented on June 12, 2024

@jdevera - In YAML, a key without a value gets the value null (test it here). null is not a valid value for the parameters key in Swagger, per the Swagger 2.0 schema, hence the error message "Expected type array but found type null".

So you need to either set the parameters key to an empty array (e.g. parameters: []) or just leave the parameters key off altogether.

from swagger-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.