Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#47157] Swagger UI is not rendering for API docs

Andreas Pfohle1dd373f5eb4
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index 3534ad61c5f..5cfd357a8f5 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -129,7 +129,6 @@
"@types/mousetrap": "^1.6.3",
"@types/pako": "^1.0.1",
"@types/resize-observer-browser": "^0.1.4",
- "@types/swagger-ui": "^3.47.0",
"@types/urijs": "^1.19.6",
"@types/uuid": "^8.3.4",
"@types/webpack-env": "^1.16.0",
@@ -23659,12 +23658,6 @@
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
"dev": true
},
- "node_modules/@types/swagger-ui": {
- "version": "3.52.0",
- "resolved": "https://registry.npmjs.org/@types/swagger-ui/-/swagger-ui-3.52.0.tgz",
- "integrity": "sha512-SlufixEmh+8CLHNgTfAfCT1icNOF7bXboWabhHr1+hIolqlvfwYJGe7HgRcpI3ChE7HWASmEKLkMu34rxseJjQ==",
- "dev": true
- },
"node_modules/@types/tapable": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.8.tgz",
@@ -67891,12 +67884,6 @@
"integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==",
"dev": true
},
- "@types/swagger-ui": {
- "version": "3.52.0",
- "resolved": "https://registry.npmjs.org/@types/swagger-ui/-/swagger-ui-3.52.0.tgz",
- "integrity": "sha512-SlufixEmh+8CLHNgTfAfCT1icNOF7bXboWabhHr1+hIolqlvfwYJGe7HgRcpI3ChE7HWASmEKLkMu34rxseJjQ==",
- "dev": true
- },
"@types/tapable": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.8.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index c5f58ca6871..f7b36dea97c 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -40,7 +40,6 @@
"@types/mousetrap": "^1.6.3",
"@types/pako": "^1.0.1",
"@types/resize-observer-browser": "^0.1.4",
- "@types/swagger-ui": "^3.47.0",
"@types/urijs": "^1.19.6",
"@types/uuid": "^8.3.4",
"@types/webpack-env": "^1.16.0",
diff --git a/frontend/src/app/features/api-docs/swagger-ui/swagger-ui.component.ts b/frontend/src/app/features/api-docs/swagger-ui/swagger-ui.component.ts
index 2e4ecdf3e0c..ce99e41ef32 100644
--- a/frontend/src/app/features/api-docs/swagger-ui/swagger-ui.component.ts
+++ b/frontend/src/app/features/api-docs/swagger-ui/swagger-ui.component.ts
@@ -26,15 +26,19 @@
// See COPYRIGHT and LICENSE files for more details.
//++
-import { AfterViewInit, Component, ViewEncapsulation } from '@angular/core';
+import {
+ AfterViewInit, ChangeDetectionStrategy, Component, ViewEncapsulation,
+} from '@angular/core';
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
-import * as SwaggerUI from 'swagger-ui';
+// @ts-ignore
+import SwaggerUI from 'swagger-ui';
@Component({
selector: 'op-api-docs',
styleUrls: ['./swagger-ui.component.sass'],
templateUrl: './swagger-ui.component.html',
encapsulation: ViewEncapsulation.None,
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SwaggerUIComponent implements AfterViewInit {
constructor(private pathHelperService:PathHelperService) {
@@ -45,6 +49,7 @@ export class SwaggerUIComponent implements AfterViewInit {
dom_id: '#swagger',
url: this.pathHelperService.api.v3.openApiSpecPath,
filter: true,
+ // @ts-ignore
requestInterceptor: (req) => {
if (!req.loadSpec) {
// required to make session-based authentication work for POST requests with APIv3