Add special representation for enum with one value (fixes #70)

This commit is contained in:
Roman Hotsiy 2016-08-12 20:41:58 +03:00
parent 0b46186585
commit cde5eb534a
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
5 changed files with 20 additions and 4 deletions

View File

@ -54,7 +54,10 @@
}">
<td class="param-name">
<span class="param-name-wrap" (click)="subSchema.toggle()">
<span class="param-name-content" >{{prop._name}}</span>
<span class="param-name-content">
{{prop._name}}
<span class="param-enum-value" [hidden]="!prop._enumItem"> {{prop._enumItem?.val | json}} </span>
</span>
<svg *ngIf="prop._pointer" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0" y="0" viewBox="0 0 24 24" xml:space="preserve">
<polygon points="17.3 8.3 12 13.6 6.7 8.3 5.3 9.7 12 16.4 18.7 9.7 "/>
</svg>

View File

@ -223,3 +223,12 @@ li:before {
}
}
}
.param-enum-value {
padding: 2px;
background-color: #e6ebf6;
&:before {
content: " = ";
}
}

View File

@ -44,13 +44,13 @@ describe('Redoc components', () => {
component.schema.isTrivial.should.be.true();
});
it('should use < * > notation for prop without type', () => {
it('should use < anything > notation for prop without type', () => {
component.pointer = '#';
(<any>specMgr)._schema = {type: 'object', properties: {
test: {}
}};
fixture.detectChanges();
component.schema._properties[0]._displayType.should.be.equal('< * >');
component.schema._properties[0]._displayType.should.be.equal('< anything >');
});
});
});

View File

@ -49,6 +49,10 @@ const injectors = {
injectTo.enum = propertySchema.enum.map((value) => {
return {val: value, type: typeof value};
});
if (propertySchema.enum && propertySchema.enum.length === 1) {
injectTo._enumItem = propertySchema.enum[0];
injectTo.enum = null;
}
}
}
},

View File

@ -1,7 +1,7 @@
{
"name": "redoc",
"description": "Swagger-generated API Reference Documentation",
"version": "1.0.1",
"version": "1.1.0",
"repository": {
"type": "git",
"url": "git://github.com/Rebilly/ReDoc"