Advisory: JSON Pointer Errors in OpenAPI Spec Files

Summary

When migrating API documentation from the deprecated .. swaggerv2doc:: directive to the .. openapi:: directive, some Swagger 2.0 JSON spec files cause Sphinx builds to fail with an error like:

jsonschema.exceptions._RefResolutionError: Unresolvable JSON pointer:
    'definitions/ASDC-API/artifacts(config)artifact'

This error occurs when definition key names contain forward slash (/) characters. The / character is the path separator in JSON Pointer (RFC 6901), so the JSON schema resolver misinterprets the key name as a nested path rather than a single key at the definitions level.

Background

Several ONAP projects use auto-generated Swagger 2.0 JSON specs originally produced by OpenDaylight YANG tooling. These specs contain definition names that embed hierarchical paths using / as a separator, for example:

  • ASDC-API/artifacts(config)artifact

  • ASDC-API/vf-license-model-versions(config)vf-license-model-version

  • LCM/common-header(config)flags

These names appear both as keys under definitions and inside $ref pointer values:

{
  "definitions": {
    "ASDC-API/artifacts(config)artifact": {
      "properties": { }
    }
  },
  "paths": {
    "/config/ASDC-API:artifacts": {
      "post": {
        "parameters": [{
          "schema": {
            "$ref": "#/definitions/ASDC-API/artifacts(config)artifact"
          }
        }]
      }
    }
  }
}

While having / in a JSON object key is valid JSON, it creates an unresolvable $ref when parsed as a JSON Pointer. The pointer #/definitions/ASDC-API/artifacts(config)artifact is interpreted as:

  1. Navigate into definitions

  2. Navigate into ASDC-API ✗ — no such nested key exists

The actual definition lives at definitions["ASDC-API/artifacts(config)artifact"] as a single flat key, but the JSON Pointer specification has no way to distinguish a / that is part of a key name from a / that is a path separator — unless the reference is properly escaped.

Affected Projects

This issue was originally identified on Gerrit change 143029 (ccsdk/distribution, topic: remove-swaggerdoc), where the GitHub documentation workflow failed during sphinx-build for both the docs and docs-linkcheck tox environments.

Any project with auto-generated Swagger specs from OpenDaylight YANG tooling may be affected. The issue only manifests when using sphinxcontrib-openapi (the .. openapi:: directive); the older sphinxcontrib-swaggerdoc extension did not perform strict JSON Pointer resolution on $ref values.

Alternative: JSON Pointer Tilde Escaping (Option B)

RFC 6901 defines ~1 as the escape sequence for a literal / inside a JSON Pointer token. Under this approach, definition key names are left unchanged, but all $ref values are updated to use the escaped form:

Before:

"$ref": "#/definitions/ASDC-API/artifacts(config)artifact"

After:

"$ref": "#/definitions/ASDC-API~1artifacts(config)artifact"

This is technically correct per the RFC, but has drawbacks:

  • Less readable and harder to maintain.

  • Requires that all consumers (including sphinxcontrib-openapi and any other tooling) correctly implement ~1 decoding, which is not always guaranteed in practice.

  • The definition keys still contain /, which may cause issues with other tools in the future.

Option A (renaming keys) is preferred for clarity and portability.

Verification

After applying the fix, verify the documentation builds cleanly:

cd docs
tox -e docs,docs-linkcheck

Both environments should complete without _RefResolutionError exceptions.

References