-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
External Documentation rendered for groups, operations and schemata. #595
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e5ed542
External Documentation rendered for groups, operations and schemata.
m-mohr 964d523
Merge branch 'master' into external-docs
m-mohr 72d120f
Merge branch 'master' into external-docs
m-mohr 0dee3a8
Fixed issues that arose from latest changes / merge
m-mohr b90a5a0
chore: clean up
RomanHotsiy cd5d213
chore: add externalDocs in the field in the demo spec
RomanHotsiy c5540a9
chore: rename dense to compact
RomanHotsiy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/components/ExternalDocumentation/ExternalDocumentation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { observer } from 'mobx-react'; | ||
import * as React from 'react'; | ||
import styled from '../../styled-components'; | ||
import { OpenAPIExternalDocumentation } from '../../types'; | ||
import { linksCss } from '../Markdown/styled.elements'; | ||
|
||
const Link = styled.span` | ||
${linksCss}; | ||
`; | ||
|
||
@observer | ||
export class ExternalDocumentation extends React.Component<{ | ||
externalDocs: OpenAPIExternalDocumentation; | ||
}> { | ||
render() { | ||
const { externalDocs } = this.props; | ||
if (!externalDocs || !externalDocs.url) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Link> | ||
<a href={externalDocs.url}>{externalDocs.description || externalDocs.url}</a> | ||
</Link> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import { OptionsContext } from '../OptionsProvider'; | |
|
||
import { ShareLink } from '../../common-elements/linkify'; | ||
import { Endpoint } from '../Endpoint/Endpoint'; | ||
import { ExternalDocumentation } from '../ExternalDocumentation/ExternalDocumentation'; | ||
import { Markdown } from '../Markdown/Markdown'; | ||
import { Parameters } from '../Parameters/Parameters'; | ||
import { RequestSamples } from '../RequestSamples/RequestSamples'; | ||
|
@@ -38,7 +39,7 @@ export class Operation extends React.Component<OperationProps> { | |
render() { | ||
const { operation } = this.props; | ||
|
||
const { name: summary, description, deprecated } = operation; | ||
const { name: summary, description, deprecated, externalDocs } = operation; | ||
return ( | ||
<OptionsContext.Consumer> | ||
{options => ( | ||
|
@@ -50,6 +51,11 @@ export class Operation extends React.Component<OperationProps> { | |
</H2> | ||
{options.pathInMiddlePanel && <Endpoint operation={operation} inverted={true} />} | ||
{description !== undefined && <Description source={description} />} | ||
{externalDocs && ( | ||
<p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above. |
||
<ExternalDocumentation externalDocs={externalDocs} /> | ||
</p> | ||
)} | ||
<SecurityRequirements securities={operation.security} /> | ||
<Parameters parameters={operation.parameters} body={operation.requestBody} /> | ||
<ResponsesList responses={operation.responses} /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a
<p>
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's on purpose. The p adds a margin between the External Documentation link and the description. Without the margin in looks odd. The div is chosen in the schema as it seems to be designed to be very small and therefore without margin, like most other elements in there, too. So I think your suggestion makes things look worse without introducing additional styling per place that it's added to.