Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brackets not parsed correctly in JSON pointers #238

Open
EthanHonzikSPS opened this issue Aug 23, 2024 · 0 comments
Open

Brackets not parsed correctly in JSON pointers #238

EthanHonzikSPS opened this issue Aug 23, 2024 · 0 comments

Comments

@EthanHonzikSPS
Copy link

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: [email protected]
  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
@EthanHonzikSPS EthanHonzikSPS changed the title Angle brackets not parsed correctly in JSON pointers Brackets not parsed correctly in JSON pointers Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant