Skip to content

Commit b118d19

Browse files
authored
feat(api-docs): the hand-written endpoint descriptions point to the API documentation (#2113)
GET /api/views/docs and GET /api/aangeboden-gebruik/docs keep their bodies and carry a documentation entry with the API documentation page and the OpenAPI document. The API reference opens with the same pointer, and a feature page explains the API documentation page. Task 4 of sharing-generated-api-docs, without the screenshot. Assisted-by: ClaudeCode:claude-opus-5-5
1 parent cd807b0 commit b118d19

12 files changed

Lines changed: 148 additions & 0 deletions

File tree

‎docs/API_REFERENCE.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# API Reference
22

3+
> **The generated documents are the reference.** Open **API documentation** in stackiq's footer (`/apps/stackiq/api-docs`) to read both OpenAPI documents in the app: OpenRegister's document of the catalogue objects (`GET /apps/openregister/api/registers/{id}/oas`) and stackiq's own endpoints (`GET /apps/stackiq/api/openapi.json`). This page is a hand-written overview and can lag behind them. See [API documentation](features/api-documentation.md).
4+
35
## Overview
46

57
The Software Catalog app provides a REST API for configuration management and programmatic access to user and group management functionality.

‎docs/features/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ All data is stored as OpenRegister objects (no own database tables). OpenRegiste
3434
| [Technology Components](technology-components.md) | Record the servers, databases and devices an organisation runs, what runs on them and when their support ends |
3535
| [CMDB Import](#cmdb-import) | Import a municipality's TOPdesk CMDB export (xlsx) as applications, suppliers, usages and owners |
3636
| [Data quality](./data-quality.md) | A data quality score on every application and usage, a confirm-current action and a Data quality page per organisation |
37+
| [API documentation](api-documentation.md) | Read OpenRegister's document of the catalogue objects and stackiq's own endpoints in the app, and download either as JSON |
3738
| [Open Data Publishing](#open-data-publishing) | Expose the catalogue as a public open-data API |
3839
| [GEMMA Compliance](#gemma-compliance) | Built around VNG GEMMA Softwarecatalogus reference |
3940
| [Reference Component Coverage](reference-component-coverage.md) | Which GEMMA reference components an organisation covers, where it has gaps and where applications overlap |

‎docs/features/api-documentation.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
3+
- SPDX-License-Identifier: EUPL-1.2
4+
-->
5+
6+
# API documentation
7+
8+
Read the two documents that describe the catalogue's API, inside stackiq.
9+
10+
Specification: [`openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md`](https://github.com/ConductionNL/stackiq/blob/development/openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md).
11+
12+
## Where
13+
14+
**API documentation** in the footer of the navigation, beside Documentation. The page is at `/apps/stackiq/api-docs`.
15+
16+
## Two documents
17+
18+
The catalogue is served by two APIs, and the page has a tab for each:
19+
20+
| Tab | What it describes | Where the document comes from |
21+
|-----|-------------------|-------------------------------|
22+
| Catalogue objects | Reading and writing applications, services, usages, connections, contracts and the other catalogue objects | OpenRegister's OpenAPI document of the `stackiq` register, `GET /apps/openregister/api/registers/{id}/oas` |
23+
| Stackiq endpoints | The endpoints stackiq adds on top: offers, offered usage, views, reports, the CMDB import, settings | stackiq's own OpenAPI document, `GET /apps/stackiq/api/openapi.json` |
24+
25+
Each tab loads its document when you first open it, and shows:
26+
27+
- the title, version and servers of the API;
28+
- the calls grouped by tag, each with its method, path, parameters, request body and responses;
29+
- the models (schemas) with their properties;
30+
- a filter to narrow the calls;
31+
- **Download OpenAPI file**, which saves the document as JSON.
32+
33+
The documents are fetched from your own instance with your session and shown by stackiq itself. No outside viewer is loaded and the document address is not sent anywhere.
34+
35+
## When a tab says the document is not available
36+
37+
- **Catalogue objects** needs the catalogue register to be configured. Until it is, the tab says the document is not available on this instance.
38+
- A document you may not read says so; a document that does not load says it could not be loaded.
39+
40+
## The hand-written endpoint descriptions
41+
42+
`GET /apps/stackiq/api/views/docs` and `GET /apps/stackiq/api/aangeboden-gebruik/docs` still answer with their hand-written description, for the integrations that read them. Both now carry a `documentation` entry with the page (`/apps/stackiq/api-docs`) and the OpenAPI document (`/apps/stackiq/api/openapi.json`). New integrations use the OpenAPI document.
43+
44+
## Screenshot
45+
46+
A screenshot of the page follows once it can be taken against a running instance.

‎lib/Controller/AangebodenGebruikApiDocumentation.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ final class AangebodenGebruikApiDocumentation {
8585
'api_version' => '2.0.0',
8686
'description' => 'Stackiq AangebodenGebruik API',
8787
'base_url' => '/api/aangeboden-gebruik',
88+
'documentation' => ApiDocumentationLink::LINK,
8889
'endpoints' => [
8990
[
9091
'method' => 'GET',

‎lib/Controller/AangebodenGebruikController.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,12 +695,17 @@ private function objectAction(string $id, string $name): ObjectAction {
695695
*
696696
* API Endpoint: GET /api/aangeboden-gebruik/docs
697697
*
698+
* Deprecated for new integrations: the body keeps its hand-written
699+
* description and carries a `documentation` entry that points to the API
700+
* documentation page and the OpenAPI document.
701+
*
698702
* @return JSONResponse JSON response with API documentation
699703
*
700704
* @NoCSRFRequired
701705
* @PublicPage
702706
*
703707
* @spec openspec/specs/aangeboden-gebruik-api/spec.md
708+
* @spec openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md#requirement-req-gad-003-the-hand-written-documentation-points-to-the-generated-documents
704709
*/
705710
#[AnonRateLimit(limit: 120, period: 60)]
706711
public function getApiDocumentation(): JSONResponse {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/**
4+
* Where the generated API documentation lives.
5+
*
6+
* @category Controller
7+
* @package OCA\Stackiq\Controller
8+
* @author Conduction Development Team <info@conduction.nl>
9+
* @copyright 2026 Conduction B.V.
10+
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
11+
* @link https://github.com/ConductionNL/stackiq
12+
*
13+
* @spec openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md#requirement-req-gad-003-the-hand-written-documentation-points-to-the-generated-documents
14+
*
15+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
16+
* SPDX-License-Identifier: EUPL-1.2
17+
*/
18+
19+
declare(strict_types=1);
20+
21+
namespace OCA\Stackiq\Controller;
22+
23+
/**
24+
* The `documentation` entry the hand-written documentation bodies carry.
25+
*
26+
* `GET /api/views/docs` and `GET /api/aangeboden-gebruik/docs` keep their
27+
* bodies for the integrations that read them, and point to the API
28+
* documentation page and the OpenAPI document that describe every endpoint.
29+
*
30+
* @category Controller
31+
* @package OCA\Stackiq\Controller
32+
* @author Conduction Development Team <info@conduction.nl>
33+
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
34+
* @link https://github.com/ConductionNL/stackiq
35+
*
36+
* @spec openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md#requirement-req-gad-003-the-hand-written-documentation-points-to-the-generated-documents
37+
*/
38+
final class ApiDocumentationLink {
39+
/**
40+
* The documentation entry: the page, the OpenAPI document and why to use them.
41+
*
42+
* @var array{page: string, openapi: string, note: string}
43+
*/
44+
public const LINK = [
45+
'page' => '/apps/stackiq/api-docs',
46+
'openapi' => '/apps/stackiq/api/openapi.json',
47+
'note' => 'This hand-written description is deprecated. The API documentation page and the OpenAPI document describe every endpoint.',
48+
];
49+
}//end class

‎lib/Controller/ViewApiDocumentation.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ final class ViewApiDocumentation {
7373
'api_version' => '1.0.0',
7474
'description' => 'Stackiq View API - Query and enrich ArchiMate views',
7575
'base_url' => '/api/views',
76+
'documentation' => ApiDocumentationLink::LINK,
7677
'endpoints' => [
7778
[
7879
'method' => 'GET',

‎lib/Controller/ViewController.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,17 @@ private function parseBooleanParam($value): bool {
526526
*
527527
* API Endpoint: GET /api/views/docs
528528
*
529+
* Deprecated for new integrations: the body keeps its hand-written
530+
* description and carries a `documentation` entry that points to the API
531+
* documentation page and the OpenAPI document.
532+
*
529533
* @NoAdminRequired
530534
* @NoCSRFRequired
531535
*
532536
* @return JSONResponse JSON response with API documentation
533537
*
534538
* @spec openspec/specs/dashboard-views-api/spec.md
539+
* @spec openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md#requirement-req-gad-003-the-hand-written-documentation-points-to-the-generated-documents
535540
*/
536541
public function getApiDocumentation(): JSONResponse {
537542
if ($this->userSession->getUser() === null) {

‎openspec/changes/sharing-generated-api-docs/tasks.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- GIVEN GET /api/aangeboden-gebruik/docs WHEN it answers THEN the body carries a documentation link to the API documentation page
3636
- [ ] Implement
3737
- [ ] Test (PHPUnit `tests/Unit/Controller/AangebodenGebruikControllerTest.php` docs case; docs build with a screenshot)
38+
- Progress 21 Nov: both hand-written bodies keep their content and carry `documentation` (`ApiDocumentationLink::LINK`: the page `/apps/stackiq/api-docs`, the document `/apps/stackiq/api/openapi.json` and a deprecation note); their docblocks say new integrations use the OpenAPI document. `docs/API_REFERENCE.md` opens with a pointer to the page and both documents, and `docs/features/api-documentation.md` (linked from the features index) explains the page. Tests: `AangebodenGebruikControllerTest::testDocsCarryALinkToTheApiDocumentationPage`, the views docs case in `ViewControllerContractTest` and the updated golden `tests/fixtures/api-documentation/documentation.json`. Left: the screenshot `docs/images/api-documentation.png`, which needs a live instance, so Implement and Test stay open.
3839

3940
## Verification
4041

‎tests/Unit/Controller/AangebodenGebruikControllerTest.php‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,29 @@ public function testAuthenticatedCallerReachesService(): void {
132132

133133
}//end testAuthenticatedCallerReachesService()
134134

135+
/**
136+
* GET /api/aangeboden-gebruik/docs keeps its body and points an old
137+
* integration to the API documentation page and the OpenAPI document.
138+
*
139+
* @spec openspec/changes/sharing-generated-api-docs/specs/generated-api-docs/spec.md#requirement-req-gad-003-the-hand-written-documentation-points-to-the-generated-documents
140+
*
141+
* @return void
142+
*/
143+
public function testDocsCarryALinkToTheApiDocumentationPage(): void {
144+
$controller = $this->makeController();
145+
$this->userSession->method('getUser')->willReturn(null);
146+
$this->gebruikSvc->expects($this->never())->method($this->anything());
147+
148+
$response = $controller->getApiDocumentation();
149+
$data = $response->getData();
150+
151+
$this->assertSame(expected: 200, actual: $response->getStatus());
152+
$this->assertSame(expected: '/api/aangeboden-gebruik', actual: $data['base_url']);
153+
$this->assertNotEmpty(actual: $data['endpoints']);
154+
$this->assertSame(expected: '/apps/stackiq/api-docs', actual: $data['documentation']['page']);
155+
$this->assertSame(expected: '/apps/stackiq/api/openapi.json', actual: $data['documentation']['openapi']);
156+
$this->assertStringContainsString(needle: 'deprecated', haystack: $data['documentation']['note']);
157+
158+
}//end testDocsCarryALinkToTheApiDocumentationPage()
159+
135160
}//end class

0 commit comments

Comments
 (0)