spectral icon indicating copy to clipboard operation
spectral copied to clipboard

Wrongly declared array not caught as error

Open benjamin-mogensen opened this issue 1 year ago • 0 comments

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: [email protected]
    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):

  • Library version: 6.11.0
  • OS: MacOS
  • Browser: NA

benjamin-mogensen avatar Mar 08 '24 07:03 benjamin-mogensen