mirror of
https://github.com/Redocly/redoc.git
synced 2025-02-17 02:10:39 +03:00
Add special representation for enum with one value (fixes #70)
This commit is contained in:
parent
0b46186585
commit
cde5eb534a
|
@ -54,7 +54,10 @@
|
||||||
}">
|
}">
|
||||||
<td class="param-name">
|
<td class="param-name">
|
||||||
<span class="param-name-wrap" (click)="subSchema.toggle()">
|
<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">
|
<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 "/>
|
<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>
|
</svg>
|
||||||
|
|
|
@ -223,3 +223,12 @@ li:before {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.param-enum-value {
|
||||||
|
padding: 2px;
|
||||||
|
background-color: #e6ebf6;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
content: " = ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -44,13 +44,13 @@ describe('Redoc components', () => {
|
||||||
component.schema.isTrivial.should.be.true();
|
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 = '#';
|
component.pointer = '#';
|
||||||
(<any>specMgr)._schema = {type: 'object', properties: {
|
(<any>specMgr)._schema = {type: 'object', properties: {
|
||||||
test: {}
|
test: {}
|
||||||
}};
|
}};
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
component.schema._properties[0]._displayType.should.be.equal('< * >');
|
component.schema._properties[0]._displayType.should.be.equal('< anything >');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -49,6 +49,10 @@ const injectors = {
|
||||||
injectTo.enum = propertySchema.enum.map((value) => {
|
injectTo.enum = propertySchema.enum.map((value) => {
|
||||||
return {val: value, type: typeof value};
|
return {val: value, type: typeof value};
|
||||||
});
|
});
|
||||||
|
if (propertySchema.enum && propertySchema.enum.length === 1) {
|
||||||
|
injectTo._enumItem = propertySchema.enum[0];
|
||||||
|
injectTo.enum = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "redoc",
|
"name": "redoc",
|
||||||
"description": "Swagger-generated API Reference Documentation",
|
"description": "Swagger-generated API Reference Documentation",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/Rebilly/ReDoc"
|
"url": "git://github.com/Rebilly/ReDoc"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user