stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v3.1, v3.0, and v2.0 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.35k stars 226 forks source link

Wrongly declared array not caught as error #2595

Closed benjamin-mogensen closed 1 month ago

benjamin-mogensen commented 4 months ago

Describe the bug The OAS file below has a wrongly declared array in the response. It states type: array and last line, and is missing an items key. Spectral does not catch this as an error. However, deploying such OAS in Apigee will not work as Apigeee uses Swagger parser which catches this error.

openapi: 3.0.3
info:
  title: Wrong array
  description: Wrong array
  version: 1.0.0
  contact:
    name: IDA Support Team
    email: ida_team@maersk.com
    url: https://www.maersk.com/contactus
  license:
    url: https://terms.maersk.com/api-license-terms
    name: Maersk 1.0
servers:
  - url: https://api-stage.net
paths:
  /translatetoen:
    post:
      operationId: post-translation-request
      description: Sent a text for translation
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                inputText:
                  type: string
              required:
                - inputText
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  highestPrecendenceLanguage:
                    type: string
                  translatedText:
                    type: string
                  allIdentifiedLanguages:
                    type: array
                    items:
                      type: array

To Reproduce

  1. Use above OAS, create file oas-array-wrong.yaml
  2. Run CLI spectral lint oas-array-wrong.yaml
  3. Output is No results with a severity of 'error' found!

Expected behavior The wrongly declared array should be treated as an error as you cannot have an array declared without stating what type the items are.

Screenshots NA

Environment (remove any that are not applicable):

mnaumanali94 commented 1 month ago

Also reported by Medline.

github-actions[bot] commented 1 month ago

This ticket has been labeled jira. A tracking ticket in Stoplight's Jira (STOP-557) has been created.

stoplight-bot commented 1 month ago

:tada: This issue has been resolved in version 1.19.0 :tada:

The release is available on @stoplight/spectral-rulesets-1.19.0

Your semantic-release bot :package::rocket: