Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: type safety for operation summary handling #5191

Merged
merged 3 commits into from
Feb 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/core/components/operation-summary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { PureComponent } from "react"
import PropTypes from "prop-types"
import { Iterable, List } from "immutable"
import ImPropTypes from "react-immutable-proptypes"
import toString from "lodash/toString"


export default class OperationSummary extends PureComponent {
Expand Down Expand Up @@ -63,7 +64,7 @@ export default class OperationSummary extends PureComponent {

{!showSummary ? null :
<div className="opblock-summary-description">
{(resolvedSummary || summary).toString()}
{toString(resolvedSummary || summary)}
</div>
}

Expand Down
13 changes: 10 additions & 3 deletions test/e2e-cypress/static/documents/bugs/5188.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,17 @@ paths:
/pet:
get:
tags:
- pet
- default
summary:
$ref:
operationId: addPet
whatever: 123
operationId: objectSummary
responses:
'405':
description: Invalid input
post:
tags:
- default
operationId: noSummary
responses:
'405':
description: Invalid input
12 changes: 10 additions & 2 deletions test/e2e-cypress/tests/bugs/5188.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ describe("#5188: non-string operation summary value", () => {
it("should gracefully handle an object value for an operation summary", () => {
cy
.visit("?url=/documents/bugs/5188.yaml")
.get("#operations-pet-addPet")
.get("#operations-default-objectSummary")
.click()
.get(".opblock-summary-description")
.contains("[object Object]")
})
})
it("should gracefully handle a missing value for an operation summary", () => {
cy
.visit("?url=/documents/bugs/5188.yaml")
.get("#operations-default-noSummary")
.click()
// check for response rendering; makes sure the Operation itself rendered
.contains("Invalid input")
})
})