Add special rendering for deprecated operations

This commit is contained in:
Peter Golm 2017-07-01 11:08:38 +02:00
parent 10cdfe59ee
commit 7bb0785841
7 changed files with 18 additions and 2 deletions

View File

@ -336,6 +336,7 @@ paths:
summary: Finds Pets by tags summary: Finds Pets by tags
description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.' description: 'Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.'
operationId: findPetsByTags operationId: findPetsByTags
deprecated: true
produces: produces:
- application/xml - application/xml
- application/json - application/json

View File

@ -5,6 +5,9 @@
</h2> </h2>
<endpoint-link *ngIf="pathInMiddlePanel" <endpoint-link *ngIf="pathInMiddlePanel"
[verb]="operation.verb" [path]="operation.path"> </endpoint-link> [verb]="operation.verb" [path]="operation.path"> </endpoint-link>
<div class="operation-deprecated" *ngIf="operation.deprecated">
Warning: Deprecated
</div>
<div class="operation-tags" *ngIf="operation.info.tags.length"> <div class="operation-tags" *ngIf="operation.info.tags.length">
<a *ngFor="let tag of operation.info.tags" attr.href="#tag/{{tag}}"> {{tag}} </a> <a *ngFor="let tag of operation.info.tags" attr.href="#tag/{{tag}}"> {{tag}} </a>
</div> </div>

View File

@ -18,6 +18,10 @@
margin-bottom: calc(1em - 6px); margin-bottom: calc(1em - 6px);
} }
.operation-deprecated {
font-weight: bold;
}
.operation-tags { .operation-tags {
margin-top: 20px; margin-top: 20px;

View File

@ -7,6 +7,7 @@ import { OptionsService, MenuService } from '../../services/';
import { SwaggerBodyParameter } from '../../utils/swagger-typings'; import { SwaggerBodyParameter } from '../../utils/swagger-typings';
export interface OperationInfo { export interface OperationInfo {
deprecated: boolean;
verb: string; verb: string;
path: string; path: string;
info: { info: {
@ -50,6 +51,7 @@ export class Operation extends BaseComponent implements OnInit {
this.operationId = this.componentSchema.operationId; this.operationId = this.componentSchema.operationId;
this.operation = { this.operation = {
deprecated: this.componentSchema.deprecated,
verb: JsonPointer.baseName(this.pointer), verb: JsonPointer.baseName(this.pointer),
path: JsonPointer.baseName(this.pointer, 2), path: JsonPointer.baseName(this.pointer, 2),
info: { info: {

View File

@ -1,6 +1,6 @@
<li *ngFor="let item of items; let idx = index" class="menu-item" <li *ngFor="let item of items; let idx = index" class="menu-item"
ngClass="menu-item-depth-{{item.depth}} {{item.active ? 'active' : ''}} menu-item-for-{{item.metadata?.type}}"> ngClass="menu-item-depth-{{item.depth}} {{item.active ? 'active' : ''}} menu-item-for-{{item.metadata?.type}}">
<label class="menu-item-header" [ngClass]="{disabled: !item.ready}" (click)="activateItem(item)"> <label class="menu-item-header" [ngClass]="{disabled: !item.ready, deprecated: item?.metadata?.deprecated}" (click)="activateItem(item)">
<span class="operation-type" [ngClass]="item?.metadata?.operation" *ngIf="item?.metadata?.operation"> {{item?.metadata?.operation}} </span><!-- <span class="operation-type" [ngClass]="item?.metadata?.operation" *ngIf="item?.metadata?.operation"> {{item?.metadata?.operation}} </span><!--
--><span class="menu-item-title">{{item.name}}</span> --><span class="menu-item-title">{{item.name}}</span>
<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"> <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">

View File

@ -21,6 +21,11 @@
color: lighten($text-color, 60%); color: lighten($text-color, 60%);
} }
&.deprecated {
text-decoration: line-through;
color: lighten($text-color, 60%);
}
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;

View File

@ -340,7 +340,8 @@ export class MenuService {
type: 'operation', type: 'operation',
pointer: operationInfo._pointer, pointer: operationInfo._pointer,
operationId: operationInfo.operationId, operationId: operationInfo.operationId,
operation: operationInfo.operation operation: operationInfo.operation,
deprecated: !!operationInfo.deprecated
}, },
parent: parent parent: parent
}; };