stoplightio / vscode-spectral

VS Code extension bringing the awesome Spectral JSON/YAML linter with OpenAPI/AsyncAPI support
https://marketplace.visualstudio.com/items?itemName=stoplight.spectral
Apache License 2.0
72 stars 23 forks source link

Brackets not parsed correctly in JSON pointers #238

Open EthanHonzikSPS opened 3 months ago

EthanHonzikSPS commented 3 months ago

Describe the bug JSON pointers must use %7B and %7D to represent brackets for correct functionality in the Spectral CLI and SDK. However, the VSCode extension does not handle this encoding properly. Instead, it only recognizes literal bracket characters, which is incorrect.

To Reproduce

  1. Given this example OpenAPI document:

    openapi: 3.0.3
    info:
    title: Swagger Petstore - OpenAPI 3.0
    description: test
    contact:
    email: test@test.com
    version: 1.0.11
    servers:
    - url: https://petstore3.swagger.io/api/v3
    paths:
    /pet/{petId}/test:
    get:
      summary: Find pet by ID
      description: Returns a single pet
      operationId: getPetById
      parameters:
        - name: petId
          in: path
          description: ID of pet to return
          required: true
          schema:
            type: integer
      responses:
        '200':
          description: test
  2. Run the document through both the CLI and the VSCode extension. You will see an operation-tags warning.

  3. Use this .spectral file:

    extends: spectral:oas
    overrides:
    - files:
    - "**#/paths/~1pet~1%7BpetId%7D~1test"
    rules:
      operation-tags: off
    • Notice the warning will not appear within the CLI, but will be present within the VSCode extension.
  4. Use this .spectral file:

    extends: spectral:oas
    overrides:
    - files:
    - "**#/paths/~1pet~1{petId}~1test"
    rules:
      operation-tags: off
    • Notice the warning will not appear in the VSCode extension but will be present within the CLI.

Expected behavior The VSCode extension should correctly parse %7B and %7D representations of brackets, ensuring no warnings appear when using the first .spectral file. Screenshots No Errors with literal bracket characters: image Errors with %7B and %7D encoding of bracket characters: image

Environment: