Skip to content

Commit

Permalink
added the TRACE operation to the Path form (for 3.0 definitions only).
Browse files Browse the repository at this point in the history
…Fixes #175

Signed-off-by: Eric Wittmann <eric.wittmann@gmail.com>
  • Loading branch information
EricWittmann committed Feb 22, 2018
1 parent e3f4b88 commit c7d3d90
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,24 @@
<button class="btn btn-default" (click)="createOperation('patch')">Create Operation</button>
</div>
</div>

<div class="api-operation" [class.empty]="!hasTrace()" *ngIf="supportsTraceOperation()">
<div class="">
<div class="type"><span class="label label-info" (click)="selectOperation(trace())">TRACE</span></div>
<inline-text-editor [value]="traceSummary()" [enabled]="hasTrace()" [noValueMessage]="'No Summary'"
[labelClass]="'name'"
[formClass]="'api-summary-editor-form'"
[inputClass]="'api-item-editor api-summary-editor name'"
(onChange)="changeSummary($event, trace())"></inline-text-editor>
</div>
<inline-textarea-editor *ngIf="hasTrace()" [value]="traceDescription()" [noValueMessage]="'No description.'"
[labelClass]="'description api-item-description'"
[formClass]="'api-description-editor-form'"
[inputClass]="'api-item-editor api-description-editor description api-item-description'"
(onChange)="changeDescription($event, trace())"></inline-textarea-editor>
<div class="actions" *ngIf="!hasTrace()">
<button class="btn btn-default" (click)="createOperation('trace')">Create Operation</button>
</div>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import {Component, EventEmitter, Input, Output, ViewChild, ViewEncapsulation} from "@angular/core";
import {OasDocument, OasOperation, OasParameterBase, OasPathItem, OasPaths} from "oai-ts-core";
import {Oas30PathItem, OasDocument, OasOperation, OasParameterBase, OasPathItem, OasPaths} from "oai-ts-core";
import {SourceFormComponent} from "./source-form.base";
import {ModelUtils} from "../../_util/model.util";
import {
Expand Down Expand Up @@ -74,6 +74,10 @@ export class PathFormComponent extends SourceFormComponent<OasPathItem> {
return this.path.ownerDocument();
}

public trace(): OasOperation {
return (this.path as Oas30PathItem).trace;
}

public hasGet(): boolean {
return this.path.get !== undefined && this.path.get !== null;
}
Expand All @@ -95,6 +99,9 @@ export class PathFormComponent extends SourceFormComponent<OasPathItem> {
public hasPatch(): boolean {
return this.path.patch !== undefined && this.path.patch !== null;
}
public hasTrace(): boolean {
return this.trace() !== undefined && this.trace() !== null;
}

public getSummary(): string {
return this.summary(this.path.get);
Expand Down Expand Up @@ -124,6 +131,10 @@ export class PathFormComponent extends SourceFormComponent<OasPathItem> {
return this.summary(this.path.head);
}

public traceSummary(): string {
return this.summary(this.trace());
}

private summary(operation: OasOperation): string {
if (operation === null || operation === undefined) {
return "Not Supported";
Expand Down Expand Up @@ -164,6 +175,10 @@ export class PathFormComponent extends SourceFormComponent<OasPathItem> {
return this.description(this.path.head);
}

public traceDescription(): string {
return this.description(this.trace());
}

private description(operation: OasOperation): string {
if (operation === null || operation === undefined) {
return "Not Supported";
Expand Down Expand Up @@ -315,4 +330,7 @@ export class PathFormComponent extends SourceFormComponent<OasPathItem> {
super.enableSourceMode();
}

public supportsTraceOperation(): boolean {
return this.document().is3xDocument();
}
}

0 comments on commit c7d3d90

Please sign in to comment.