Fix code samples are not shown for operations without body param (#93)

This commit is contained in:
Roman Hotsiy 2016-08-31 20:41:13 +03:00
parent 3d3bcbe27f
commit acaf54b28f
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
4 changed files with 9 additions and 7 deletions

View File

@ -22,9 +22,8 @@
--></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>

View File

@ -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 {

View File

@ -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">

View File

@ -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';
@ -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>;
@ -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() {