Add project_id to the Note API response

What does this MR do and why?

Adds project_id to API::Entities::Note so that the note's project is known in the API response.

This will be the response for the following APIs: search, notes, discussions all of which can benefit from having project_id included. Epic Notes don't have a project so project_id will be null.

Also updates the documentation.

Screenshots or screen recordings

Example response

{
  "id": 48122,
  "type": null,
  "body": "...",
  "attachment": null,
  "author": {
      "id": 1,
      "username": "root",
      "name": "admin",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://127.0.0.1:3000/root"
  },
  "created_at": "2011-12-22T23:09:14.000Z",
  "updated_at": "2011-12-22T23:09:14.000Z",
  "system": false,
  "noteable_id": 7359,
  "noteable_type": "Issue",
  "project_id": 22,
  "resolvable": false,
  "confidential": false,
  "internal": false,
  "noteable_iid": 227,
  "commands_changes": {}
}

How to set up and validate locally

  1. Do an API search for notes. E.g. /api/v4/projects/22/search?scope=notes&search=something.
  2. Note that the project_id is in the response.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #382183 (closed)

Edited by Madelein van Niekerk

Merge request reports

Loading