Skip to content

[Schema Inaccuracy] Equivalent templated paths under /orgs/{org}/attestations/ and /users/{username}/attestations/ #7367

Open

Description

@cjyhjy

Schema Inaccuracy

The description defines two pairs of templated paths that differ only in the name of the last template expression:

Path Operation
/orgs/{org}/attestations/{attestation_id} DELETE orgs/delete-attestations-by-id
/orgs/{org}/attestations/{subject_digest} GET orgs/list-attestations
/users/{username}/attestations/{attestation_id} DELETE users/delete-attestations-by-id
/users/{username}/attestations/{subject_digest} GET users/list-attestations

The OpenAPI Specification (3.0.3, Paths Object) says: "Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical." Each pair above has the same hierarchy, so a router or generator that matches requests by path template sees one path with two definitions. (/repos/{owner}/{repo}/attestations/{subject_digest} has no such counterpart.)

Checked at commit 755ee33, descriptions/api.github.com/api.github.com.json.

Expected

Each hierarchy appears once in paths. For example, one path item per pair with a single template expression name, holding both the GET and the DELETE operation and declaring the parameter at the operation level.

Reproduction Steps

curl -sL https://raw.githubusercontent.com/github/rest-api-description/755ee33b4a81d51f6f07a902cce26cbec3b822f2/descriptions/api.github.com/api.github.com.json -o api.github.com.json
node -e '
const paths = Object.keys(JSON.parse(require("fs").readFileSync("api.github.com.json","utf8")).paths);
const seen = new Map();
for (const p of paths) { const k = p.replace(/\{[^}]+\}/g, "{}"); if (seen.has(k)) console.log(seen.get(k), "<->", p); else seen.set(k, p); }'

Output:

/orgs/{org}/attestations/{attestation_id} <-> /orgs/{org}/attestations/{subject_digest}
/users/{username}/attestations/{attestation_id} <-> /users/{username}/attestations/{subject_digest}

Found with the OpenAPI path check in moonbit-uri-template (uri-template openapi).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions