Squash commit: Links reimplementation; OAS interface improvements

This commit is contained in:
Kyle Shockey
2017-06-16 00:28:09 -07:00
parent e415ec7f8a
commit 9dc9a857b7
8 changed files with 67 additions and 12 deletions

View File

@@ -1,7 +1,9 @@
import Callbacks from "./callbacks"
import RequestBody from "./request-body"
import OperationLink from "./operation-link.jsx"
export default {
Callbacks,
RequestBody
RequestBody,
operationLink: OperationLink
}

View File

@@ -0,0 +1,29 @@
import React, { Component } from "react"
export default class OperationLink extends Component {
render() {
const { link, name } = this.props
let targetOp = link.get("operationId") || link.get("operationRef")
let parameters = link.get("parameters") && link.get("parameters").toJS()
let headers = link.get("headers") && link.get("headers").toJS()
let description = link.get("description")
return <span>
<div style={{ padding: "7px" }}>{name}{description ? `: ${description}` : ""}</div>
<pre>
Parameters {padString(0, JSON.stringify(parameters, null, 2)) || "{}"}<br /><br />
Headers {padString(0, JSON.stringify(headers, null, 2)) || "{}"}<br />
</pre>
</span>
}
}
function padString(n, string) {
if(typeof string !== "string") { return "" }
return string
.split("\n")
.map((line, i) => i > 0 ? Array(n + 1).join(" ") + line : line)
.join("\n")
}