Merge branch 'master' into master
This commit is contained in:
@@ -10,10 +10,10 @@
|
|||||||
|
|
||||||
As a brand new version, written from the ground up, there are some known issues and unimplemented features. Check out the [Known Issues](#known-issues) section for more details.
|
As a brand new version, written from the ground up, there are some known issues and unimplemented features. Check out the [Known Issues](#known-issues) section for more details.
|
||||||
|
|
||||||
This repo publishes to two different NPM packages:
|
This repository publishes to two different NPM modules:
|
||||||
|
|
||||||
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is intended for use as a node module.
|
* [swagger-ui](https://www.npmjs.com/package/swagger-ui) is a traditional npm module intended for use in JavaScript web application projects that are capable of resolving dependencies (via Webpack, Browserify, etc).
|
||||||
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) comes pre-bundled with all dependencies and can be incorporated directly in a webapp.
|
* [swagger-ui-dist](https://www.npmjs.com/package/swagger-ui-dist) is a dependency-free module that includes everything you need to serve Swagger-UI in a server-side project, or a web project that can't resolve npm module dependencies.
|
||||||
|
|
||||||
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
|
For the older version of swagger-ui, refer to the [*2.x branch*](https://github.com/swagger-api/swagger-ui/tree/2.x).
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export default class ArrayModel extends Component {
|
|||||||
{
|
{
|
||||||
properties.size ? <span>
|
properties.size ? <span>
|
||||||
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
|
{ properties.entrySeq().map( ( [ key, v ] ) => <span key={`${key}-${v}`} style={propStyle}>
|
||||||
<br />{ `${key}:`}{ String(v) }</span>)
|
<br />{ key }: { String(v) }</span>)
|
||||||
}<br /></span>
|
}<br /></span>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export default class Primitive extends Component {
|
|||||||
let format = schema.get("format")
|
let format = schema.get("format")
|
||||||
let xml = schema.get("xml")
|
let xml = schema.get("xml")
|
||||||
let enumArray = schema.get("enum")
|
let enumArray = schema.get("enum")
|
||||||
|
let title = schema.get("title") || name
|
||||||
let description = schema.get("description")
|
let description = schema.get("description")
|
||||||
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
|
let properties = schema.filter( ( v, key) => ["enum", "type", "format", "description", "$$ref"].indexOf(key) === -1 )
|
||||||
const Markdown = getComponent("Markdown")
|
const Markdown = getComponent("Markdown")
|
||||||
@@ -30,7 +31,7 @@ export default class Primitive extends Component {
|
|||||||
|
|
||||||
return <span className="model">
|
return <span className="model">
|
||||||
<span className="prop">
|
<span className="prop">
|
||||||
{ name && <span className={`${depth === 1 && "model-title"} prop-name`}>{ name }</span> }
|
{ name && <span className={`${depth === 1 && "model-title"} prop-name`}>{ title }</span> }
|
||||||
<span className="prop-type">{ type }</span>
|
<span className="prop-type">{ type }</span>
|
||||||
{ format && <span className="prop-format">(${format})</span>}
|
{ format && <span className="prop-format">(${format})</span>}
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -237,7 +237,8 @@ span
|
|||||||
.prop-name
|
.prop-name
|
||||||
{
|
{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
width: 100px;
|
margin-right: 1em;
|
||||||
|
width: 8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prop-type
|
.prop-type
|
||||||
|
|||||||
49
test/components/primitive-model.js
Normal file
49
test/components/primitive-model.js
Normal file
@@ -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("<PrimitiveModel/>", 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(<PrimitiveModel {...props}/>)
|
||||||
|
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(<PrimitiveModel {...props}/>)
|
||||||
|
const modelTitleEl = wrapper.find("span.model-title")
|
||||||
|
expect(modelTitleEl.length).toEqual(1)
|
||||||
|
|
||||||
|
// Then
|
||||||
|
expect( modelTitleEl.text() ).toEqual( "Name from props" )
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
} )
|
||||||
@@ -583,7 +583,7 @@ describe("utils", function() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.only("getAcceptControllingResponse", () => {
|
describe("getAcceptControllingResponse", () => {
|
||||||
it("should return the first 2xx response with a media type", () => {
|
it("should return the first 2xx response with a media type", () => {
|
||||||
const responses = fromJSOrdered({
|
const responses = fromJSOrdered({
|
||||||
"200": {
|
"200": {
|
||||||
|
|||||||
Reference in New Issue
Block a user