Skip to content

Brackets not parsed correctly in JSON pointers #238

Description

@EthanHonzikSPS

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
  1. Run the document through both the CLI and the VSCode extension. You will see an operation-tags warning.

  2. 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.
  1. 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:

  • Spectral CLI version: 6.11.1
  • Extension version: 1.1.2
  • VS Code version: 1.92.2
  • Operating System: Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions