diff --git a/src/core/components/array-model.jsx b/src/core/components/array-model.jsx
index a9c36a2c900603ae6864e684381b2f30092c6aa9..e4cde55c9846f78ba7929b1cda9e83d12266f47c 100644
--- a/src/core/components/array-model.jsx
+++ b/src/core/components/array-model.jsx
@@ -41,7 +41,7 @@ export default class ArrayModel extends Component {
{
properties.size ?
{ properties.entrySeq().map( ( [ key, v ] ) =>
-
{ `${key}:`}{ String(v) })
+
{ key }: { String(v) })
}
: null
}
diff --git a/src/core/components/primitive-model.jsx b/src/core/components/primitive-model.jsx
index 8177352326a2cb7011f6eb4323ea9f0e63bdb962..f1fba8a537af2df8ea5b789d615d71842ee77034 100644
--- a/src/core/components/primitive-model.jsx
+++ b/src/core/components/primitive-model.jsx
@@ -23,6 +23,7 @@ export default class Primitive extends Component {
let format = schema.get("format")
let xml = schema.get("xml")
let enumArray = schema.get("enum")
+ let title = schema.get("title") || name
let description = schema.get("description")
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
const Markdown = getComponent("Markdown")
@@ -30,7 +31,7 @@ export default class Primitive extends Component {
return
- { name && { name } }
+ { name && { title } }
{ type }
{ format && (${format})}
{
diff --git a/src/style/_models.scss b/src/style/_models.scss
index dd043f7ff8a8b09bb7635b478b0d893d65a04494..c3a901d9e43962183d5cf45c8e89a8487b10b071 100644
--- a/src/style/_models.scss
+++ b/src/style/_models.scss
@@ -237,7 +237,8 @@ span
.prop-name
{
display: inline-block;
- width: 100px;
+ margin-right: 1em;
+ width: 8em;
}
.prop-type
diff --git a/test/components/primitive-model.js b/test/components/primitive-model.js
new file mode 100644
index 0000000000000000000000000000000000000000..9394bb8c2cd6e1dfdfd213b3f6561a08ca1493e4
--- /dev/null
+++ b/test/components/primitive-model.js
@@ -0,0 +1,49 @@
+/* eslint-env mocha */
+import React from "react"
+import expect from "expect"
+import { shallow } from "enzyme"
+import { fromJS } from "immutable"
+import PrimitiveModel from "components/primitive-model"
+
+describe("", function() {
+ describe("Model name", function() {
+ const dummyComponent = () => null
+ const components = {
+ Markdown: dummyComponent,
+ EnumModel: dummyComponent
+ }
+ const props = {
+ getComponent: c => components[c],
+ name: "Name from props",
+ depth: 1,
+ schema: fromJS({
+ type: "string",
+ title: "Custom model title"
+ })
+ }
+
+ it("renders the schema's title", function() {
+ // When
+ const wrapper = shallow()
+ const modelTitleEl = wrapper.find("span.model-title")
+ expect(modelTitleEl.length).toEqual(1)
+
+ // Then
+ expect( modelTitleEl.text() ).toEqual( "Custom model title" )
+ })
+
+ it("falls back to the passed-in `name` prop for the title", function() {
+ // When
+ props.schema = fromJS({
+ type: "string"
+ })
+ const wrapper = shallow()
+ const modelTitleEl = wrapper.find("span.model-title")
+ expect(modelTitleEl.length).toEqual(1)
+
+ // Then
+ expect( modelTitleEl.text() ).toEqual( "Name from props" )
+ })
+
+ })
+} )
\ No newline at end of file
diff --git a/test/core/utils.js b/test/core/utils.js
index b4be6c1b30d900c08b78efceb39b8093479e17f2..42103cc103502119d1e673204e0b4b532dbe8a4b 100644
--- a/test/core/utils.js
+++ b/test/core/utils.js
@@ -583,7 +583,7 @@ describe("utils", function() {
})
})
- describe.only("getAcceptControllingResponse", () => {
+ describe("getAcceptControllingResponse", () => {
it("should return the first 2xx response with a media type", () => {
const responses = fromJSOrdered({
"200": {