Skip to content
This repository was archived by the owner on Mar 18, 2023. It is now read-only.

Commit e66804a

Browse files
BastianGemvolkflo
authored andcommitted
fix(ui): fix swagger ui styling
Added the same swagger css as the apiman manager ui to ensure the same look and feel. Furthermore, changed the background color of the curl response.
1 parent b8b5f9c commit e66804a

File tree

7 files changed

+91
-16
lines changed

7 files changed

+91
-16
lines changed

angular.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@
4343
"src/themes/default.scss",
4444
"node_modules/swagger-ui/dist/swagger-ui.css",
4545
"node_modules/simplebar/dist/simplebar.min.css",
46-
"node_modules/prismjs/themes/prism.css",
4746
"node_modules/material-icons/iconfont/filled.css"
4847
],
4948
"scripts": [
5049
"node_modules/marked/marked.min.js",
51-
"node_modules/simplebar/dist/simplebar.min.js",
52-
"node_modules/prismjs/prism.js"
50+
"node_modules/simplebar/dist/simplebar.min.js"
5351
]
5452
},
5553
"configurations": {

package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@ngx-translate/core": "14.0.0",
2929
"@ngx-translate/http-loader": "7.0.0",
3030
"@swimlane/ngx-charts": "20.1.0",
31+
"@types/prismjs": "^1.26.0",
3132
"json5": "2.2.1",
3233
"keycloak-angular": "9.1.0",
3334
"keycloak-js": "16.1.1",

src/app/components/api-markdown-description/api-markdown-description.component.scss

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/*!
2+
* Copyright 2022 Scheer PAS Schweiz AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* imitations under the License.
15+
*/
16+
17+
@import "~prismjs/themes/prism.css";
18+
119
#markdown-container {
220
max-height: 50vh;
321
padding-left: 1%;

src/app/components/api-markdown-description/api-markdown-description.component.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,41 @@
1-
import { Component, Input, OnInit } from '@angular/core';
1+
/*
2+
* Copyright 2022 Scheer PAS Schweiz AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* imitations under the License.
15+
*/
16+
17+
import {
18+
AfterViewInit,
19+
Component,
20+
Input,
21+
OnInit,
22+
ViewChild,
23+
ViewEncapsulation
24+
} from '@angular/core';
225
import { TranslateService } from '@ngx-translate/core';
26+
import * as Prism from 'prismjs';
27+
import 'prismjs/components';
328

429
@Component({
530
selector: 'app-api-markdown-description',
631
templateUrl: './api-markdown-description.component.html',
7-
styleUrls: ['./api-markdown-description.component.scss']
32+
styleUrls: ['./api-markdown-description.component.scss'],
33+
// Enable a ShadowRoot to apply styles in a isolated manner
34+
// This is necessary to apply prism styling and syntax highlighting.
35+
encapsulation: ViewEncapsulation.ShadowDom
836
})
9-
export class ApiMarkdownDescriptionComponent implements OnInit {
37+
export class ApiMarkdownDescriptionComponent implements OnInit, AfterViewInit {
38+
@ViewChild('markdown-container') markdownContainer!: ParentNode;
1039
@Input() markdownText = '';
1140

1241
constructor(private translator: TranslateService) {}
@@ -18,4 +47,9 @@ export class ApiMarkdownDescriptionComponent implements OnInit {
1847
) as string;
1948
}
2049
}
50+
51+
// Activate syntax highlighting as soon as the page is rendered to avoid initialize errors
52+
ngAfterViewInit(): void {
53+
Prism.highlightAllUnder(this.markdownContainer);
54+
}
2155
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2022 Scheer PAS Schweiz AG
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* imitations under the License.
15+
*/
16+
.swagger-ui .wrapper {
17+
max-width: none !important;
18+
}
19+
20+
.swagger-ui .info {
21+
margin: 0 !important;
22+
}

src/styles.scss

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
@import "@angular/material/theming";
2020
@import "src/themes/default";
2121
@import "src/themes/custom";
22+
@import "assets/swagger-custom-styles.css";
2223
@include mat.core;
2324

2425
/***** THEMING *****/
@@ -317,13 +318,3 @@ a {
317318
width: initial;
318319
overflow: hidden;
319320
}
320-
321-
// Overwrite some swagger css properties
322-
// We have to use the global css file and the !important property, otherwise it won't work
323-
.wrapper {
324-
max-width: none !important;
325-
}
326-
327-
.info {
328-
margin: 0 !important;
329-
}

0 commit comments

Comments
 (0)