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

Display requestBody description #833 #838

Merged
merged 1 commit into from
Mar 15, 2019
Merged
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
22 changes: 15 additions & 7 deletions src/components/Parameters/Parameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { ParametersGroup } from './ParametersGroup';

import { UnderlinedHeader } from '../../common-elements';

import { MediaContentModel } from '../../services';
import { FieldModel, RequestBodyModel } from '../../services/models';
import { MediaTypesSwitch } from '../MediaTypeSwitch/MediaTypesSwitch';
import { Schema } from '../Schema';

import { MediaContentModel } from '../../services';
import { Markdown } from '../Markdown/Markdown';

function safePush(obj, prop, item) {
if (!obj[prop]) {
Expand Down Expand Up @@ -45,13 +46,15 @@ export class Parameters extends React.PureComponent<ParametersProps> {

const bodyContent = body && body.content;

const bodyDescription = body && body.description;

return (
<div>
<>
{paramsPlaces.map(place => (
<ParametersGroup key={place} place={place} parameters={paramsMap[place]} />
))}
{bodyContent && <BodyContent content={bodyContent} />}
</div>
{bodyContent && <BodyContent content={bodyContent} description={bodyDescription} />}
</>
);
}
}
Expand All @@ -64,12 +67,17 @@ function DropdownWithinHeader(props) {
);
}

function BodyContent(props: { content: MediaContentModel }): JSX.Element {
const { content } = props;
function BodyContent(props: { content: MediaContentModel; description?: string }): JSX.Element {
const { content, description } = props;
return (
<MediaTypesSwitch content={content} renderDropdown={DropdownWithinHeader}>
{({ schema }) => {
return <Schema skipReadOnly={true} key="schema" schema={schema} />;
return (
<>
{description !== undefined && <Markdown source={description} />}
<Schema skipReadOnly={true} key="schema" schema={schema} />
</>
);
}}
</MediaTypesSwitch>
);
Expand Down