Fix the diff between API docs and routes

Review the AI's codeEasy10 minStripe style

Your task

An AI read your Go service's handlers and wrote its REST API reference. Handlers do not show what middleware adds, so the docs cover the 200 responses and miss many of the 401s and 429s. They also guess at field names. Before the docs go to your public developer portal, your team diffs them against the route table.

An assistant wrote doc_coverage_gaps(documented, actual). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • documented: the response contracts the docs describe, one string each, like "GET /users 401".
  • actual: the response contracts the service really has, from the route table, in the same format.
  • Return the gaps as strings, without repeats, sorted by plain character order:
    • "missing:<entry>" for each entry in actual that is not in documented.
    • "invented:<entry>" for each entry in documented that is not in actual.

Rules the tests check:

  • Compare entries exactly. Case matters and nothing is trimmed. "GET /users 200 userId" and "GET /users 200 userid" are different contracts, and so are "GET /a 200" and "GET /a 200 ".
  • An entry that appears more than once in a list is reported at most once.
  • Each gap uses the entry exactly as it is written in its own list.

Examples

doc_coverage_gaps(documented: list[str], actual: list[str]) -> list[str]
Example 1
Inputdoc_coverage_gaps(["GET /users 200"], ["GET /users 200", "GET /users 401"])
Output["missing:GET /users 401"]
Example 2
Inputdoc_coverage_gaps(["GET /users 200", "POST /users 201"], ["GET /users 200"])
Output["invented:POST /users 201"]
Example 3
Inputdoc_coverage_gaps([], [])
Output[]