Skip to content

Commit 2748aac

Browse files
pgolmRomanHotsiy
authored andcommitted
feat: Add special rendering for deprecated operations (#290)
* Add special rendering for deprecated operations * Change styling of deprecated operation header
1 parent 87d9abd commit 2748aac

File tree

7 files changed

+24
-3
lines changed

7 files changed

+24
-3
lines changed

demo/swagger.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ paths:
336336
summary: Finds Pets by tags
337337
description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.'
338338
operationId: findPetsByTags
339+
deprecated: true
339340
produces:
340341
- application/xml
341342
- application/json

lib/components/Operation/operation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="operation" *ngIf="operation">
22
<div class="operation-content">
3-
<h2 class="operation-header sharable-header">
3+
<h2 class="operation-header sharable-header" [ngClass]="{deprecated: operation.deprecated}">
44
<a class="share-link" href="#{{operation.anchor}}"></a>{{operation.summary}}
55
</h2>
66
<endpoint-link *ngIf="pathInMiddlePanel"

lib/components/Operation/operation.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@
1616

1717
.operation-header {
1818
margin-bottom: calc(1em - 6px);
19+
20+
&.deprecated {
21+
&:after {
22+
content: 'Deprecated';
23+
color: $black;
24+
background: $yellow;
25+
padding: 3px 10px;
26+
text-transform: uppercase;
27+
display: inline-block;
28+
margin: 0;
29+
}
30+
}
1931
}
2032

2133
.operation-tags {

lib/components/Operation/operation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { OptionsService, MenuService } from '../../services/';
77
import { SwaggerBodyParameter } from '../../utils/swagger-typings';
88

99
export interface OperationInfo {
10+
deprecated: boolean;
1011
verb: string;
1112
path: string;
1213
info: {
@@ -50,6 +51,7 @@ export class Operation extends BaseComponent implements OnInit {
5051
this.operationId = this.componentSchema.operationId;
5152

5253
this.operation = {
54+
deprecated: this.componentSchema.deprecated,
5355
verb: JsonPointer.baseName(this.pointer),
5456
path: JsonPointer.baseName(this.pointer, 2),
5557
info: {

lib/components/SideMenu/side-menu-items.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<li *ngFor="let item of items; let idx = index" class="menu-item"
22
ngClass="menu-item-depth-{{item.depth}} {{item.active ? 'active' : ''}} menu-item-for-{{item.metadata?.type}}">
3-
<label class="menu-item-header" [ngClass]="{disabled: !item.ready}" (click)="activateItem(item)">
3+
<label class="menu-item-header" [ngClass]="{disabled: !item.ready, deprecated: item?.metadata?.deprecated}" (click)="activateItem(item)">
44
<span class="operation-type" [ngClass]="item?.metadata?.operation" *ngIf="item?.metadata?.operation"> {{item?.metadata?.operation}} </span><!--
55
--><span class="menu-item-title">{{item.name}}</span>
66
<svg *ngIf="item.items?.length" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 24 24" xml:space="preserve">

lib/components/SideMenu/side-menu-items.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
color: lighten($text-color, 60%);
2222
}
2323

24+
&.deprecated {
25+
text-decoration: line-through;
26+
color: lighten($text-color, 60%);
27+
}
28+
2429
display: flex;
2530
justify-content: space-between;
2631

lib/services/menu.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ export class MenuService {
340340
type: 'operation',
341341
pointer: operationInfo._pointer,
342342
operationId: operationInfo.operationId,
343-
operation: operationInfo.operation
343+
operation: operationInfo.operation,
344+
deprecated: !!operationInfo.deprecated
344345
},
345346
parent: parent
346347
};

0 commit comments

Comments
 (0)