Redocly/redocly-cli

Schema usage not checked inside patternProperties

samuel-deal-tisseo opened this issue · 1 comments

What happened?

Within an OpenAPI definition file, the extension falsely reports a component schema to not be used

Minimal reproducible OpenAPI snippet

openapi: 3.1.0
tags:
- name: minimal
  description: Minimal endpoint
servers:
- url: https://redocly.com/api
  description: fake
info:
  description: "Example for bug"
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0.html
  title: "Redocly bug example"
  version: 2.0.0
paths:
  /ping:
    get:
      description: "Some endpoint"
      summary: "some_endpoint"
      operationId: ping
      security:
      - OpenIdConnectSecurityScheme:
        - account:view_profile
      tags:
      - "minimal"
      parameters: []
      responses:
        '200':
          description: result
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MainSchema'
              example:
                data:
                  "abc:123":
                    - label: "some game"
        '400':
          description: result
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    minLength: 1
                    description: "Error description label"
                    example: "Invalid request"
                required:
                - error
components:
  schemas:
    ChildSchema:
      type: object
      properties:
        label:
          type: string
          minLength: 1
          description: "Some label"
          example: "hello world"
      required:
      - label
    MainSchema:
      type: object
      properties:
        data:
          type: object
          description: ""
          patternProperties:
            "^[a-z]+:[0-9]+$":
              description: ""
              type: array
              items:
                $ref: '#/components/schemas/ChildSchema'
          additionalProperties: false
      required:
      - data
  securitySchemes:
    OpenIdConnectSecurityScheme:
      type: openIdConnect
      openIdConnectUrl: https://redocly.com/.well-known/openid-configuration
      description: 'OIDC token'

Screenshots

redoclky_ext_bug

Additional context

  • VSCode Version: 1.86.2 (user setup)
  • VSCode Commit: 903b1e9d8990623e3d7da1df3d33db3e42d80eda
  • OS: Windows_NT x64 10.0.19045
  • Redocly v0.4.2

@samuel-deal-tisseo thank you for reporting this!
As a workaround, you can suppress that issue explicitly by using ignore file.

I'm transferring the issue to the Redocly CLI repo as this is related to the linter and not to the extension itself.