Skip to content

Commit

Permalink
Fix code samples are not shown for operations without body param (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Aug 31, 2016
1 parent 3d3bcbe commit acaf54b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions lib/components/Method/method.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ <h5 class="http-method" [ngClass]="method.httpMethod">{{method.httpMethod}}</h5>
--></span>
</div>

<div *ngIf="method.bodyParam">
<br>
<request-samples [pointer]="pointer" [schemaPointer]="method.bodyParam._pointer">
<div>
<request-samples [pointer]="pointer" [schemaPointer]="method.bodyParam?._pointer">
</request-samples>
</div>
<div>
Expand Down
1 change: 1 addition & 0 deletions lib/components/Method/method.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
padding-bottom: 100px;
display: block;
border-bottom: 1px solid rgba(127, 127, 127, 0.25);
margin-top: 1em;
}

:host:last-of-type {
Expand Down
4 changes: 2 additions & 2 deletions lib/components/RequestSamples/request-samples.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<header *ngIf="schemaPointer || samples.length"> Request samples </header>
<schema-sample *ngIf="!samples.length" [skipReadOnly]="true" [pointer]="schemaPointer"> </schema-sample>
<schema-sample *ngIf="schemaPointer && !samples.length" [skipReadOnly]="true" [pointer]="schemaPointer"> </schema-sample>
<tabs *ngIf="samples.length" [selected] = "selectedLang" (change)=changeLangNotify($event)>
<tab tabTitle="JSON">
<tab *ngIf="schemaPointer" tabTitle="JSON">
<schema-sample [pointer]="schemaPointer" [skipReadOnly]="true"> </schema-sample>
</tab>
<tab *ngFor="let sample of samples" [tabTitle]="sample.lang">
Expand Down
6 changes: 4 additions & 2 deletions lib/components/RequestSamples/request-samples.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import { Component, ViewChildren, QueryList, EventEmitter, Input,
ChangeDetectionStrategy, OnInit } from '@angular/core';
ChangeDetectionStrategy, OnInit, HostBinding } from '@angular/core';

import { BaseComponent, SpecManager } from '../base';
import JsonPointer from '../../utils/JsonPointer';
Expand All @@ -18,6 +18,7 @@ export class RequestSamples extends BaseComponent implements OnInit {
@Input() pointer:string;
@Input() schemaPointer:string;
@ViewChildren(Tabs) childQuery:QueryList<Tabs>;
@HostBinding('attr.hidden') hidden;

childTabs: Tabs;
selectedLang: EventEmitter<any>;
Expand All @@ -35,8 +36,9 @@ export class RequestSamples extends BaseComponent implements OnInit {
}

init() {
this.schemaPointer = JsonPointer.join(this.schemaPointer, 'schema');;
this.schemaPointer = this.schemaPointer ? JsonPointer.join(this.schemaPointer, 'schema') : null;
this.samples = this.componentSchema['x-code-samples'] || [];
if (!this.schemaPointer && !this.samples.length) this.hidden = true;
}

ngOnInit() {
Expand Down

0 comments on commit acaf54b

Please sign in to comment.