liveBook · Manning

JSON Pointer

As explained in Automating API Delivery

JSON Pointer is a string syntax for identifying a specific value within a JSON document.

JSON Pointer is a string syntax for identifying a specific value within a JSON document. In Spectral, it targets the OpenAPI object whose linting-rule severity or activation an override changes. section 3.9

Use JSON Pointers to scope linting policy to individual OpenAPI operations:

  • Reference an operation with a file path followed by its JSON Pointer, such as openapi.yaml#/paths/~1users~1%7Bid%7D/put. section 3.9
  • Disable a rule for one operation or downgrade another operation to a warning while retaining the default error severity elsewhere. section 3.9
overrides:
  - files:
      - openapi.yaml#/paths/~1users~1%7Bid%7D/put       #1
    rules:
      operation-must-have-operationId: off
  - files:
      - openapi.yaml#/paths/~1users~1%7Bid%7D/delete
    rules:
      operation-must-have-operationId: warn       #2
rules:
  operation-must-have-operationId:
    message: 'Each operation must have an operationId'
    severity: error
    given: '$.paths[*][get,put,post,delete,options,head,patch,trace]'
    then:
      field: operationId
      function: truthy

Inspect the complete Spectral override configuration and the resulting warning for the DELETE operation. section 3.9

How Automating API Delivery covers it

How deep it goes
Defines document-value identification and demonstrates percent-encoded operation paths, but defers general syntax details to an appendix.
Examples
Uses PUT and DELETE operations under /users/{id} to demonstrate disabling and warning-level operationId rules.
What it assumes
Assumes familiarity with JSON documents, OpenAPI paths, and Spectral rules; teaches the pointer's role in selecting objects.
What you can do after
Operate Spectral with overrides that selectively disable or downgrade rules for named OpenAPI operations.
How it connects
Connects JSON documents with OpenAPI, Spectral, API linting, and rule severity overrides.

Also explained in

Compare how 2 books explain JSON Pointer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Automating API Delivery. The section links point to the parts of the book it draws on.