Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing semantic error for parameter schema of type "array" #164

Closed
schloerke opened this issue Apr 21, 2021 · 2 comments
Closed

Missing semantic error for parameter schema of type "array" #164

schloerke opened this issue Apr 21, 2021 · 2 comments

Comments

@schloerke
Copy link

schloerke commented Apr 21, 2021

When validating an API on https://editor.swagger.io/, the editor presents a valid error.

Semantic error at paths./test/{values}.get.parameters.0.schema
Schemas with 'type: array', require a sibling 'items: ' field

Screen Shot 2021-04-21 at 10 50 10 AM


When running the same code through swagger-parser, there is no error.

Reprex:

const fs = require("fs");
const SwaggerParser = require("@apidevtools/swagger-parser");

fs.writeFileSync("openapi.yaml", 
`
servers:
  - url: ''
openapi: 3.0.0
info:
  version: 0.1.0
  title: Test
paths:
  '/test/{values}':
    get:
      parameters:
        - in: path
          required: true
          name: values
          schema:
            type: array
      responses:
        '200':
          description: OK
`)


SwaggerParser.validate("openapi.yaml", (err, api) => {
  if (err) {
    console.error(err);
  }
  else {
    console.log("API name: %s, Version: %s", api.info.title, api.info.version);
  }
});

//> Promise { <pending> }
//> API name: Test, Version: 0.1.0

(No error given, api is presented as valid.)


(I hope I am not missing something obvious...)

Related: rstudio/plumber#796
cc @karawoo

@jaishirole
Copy link
Contributor

@schloerke This is so due to no validations applied for OpenAPI v3.

if (api.openapi) {

@schloerke
Copy link
Author

Thank you @jaishirole . This is too bad. Closing the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants