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: strictly check if a given part of spec exists and render single message from oneOf #335

Merged
merged 4 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions library/src/containers/Messages/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const Message: React.FunctionComponent<Props> = ({
index,
showExamples = false,
}) => {
if (!message) {
return null;
}

const title = message.title();
const summary = message.summary();
const payload = message.payload();
Expand Down
4 changes: 4 additions & 0 deletions library/src/containers/Messages/MessageExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ interface Props {
}

export const MessageExample: React.FunctionComponent<Props> = ({ message }) => {
if (!message) {
return null;
}

const payload = message.payload();
const headers = message.headers();

Expand Down
9 changes: 8 additions & 1 deletion library/src/containers/Operations/Operation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export const Operation: React.FunctionComponent<Props> = ({
channelName,
channel,
}) => {
if (!operation) {
return null;
}

const parameters = SchemaHelpers.parametersToSchema(channel.parameters());
const operationSummary = operation.summary();

Expand Down Expand Up @@ -107,7 +111,10 @@ export const Operation: React.FunctionComponent<Props> = ({
<div className="mt-2">
<p className="px-8">Accepts the following message:</p>
<div className="mt-2">
<Message message={operation.message()} showExamples={true} />
<Message
message={(operation.message as any)(0)}
showExamples={true}
/>
</div>
</div>
)}
Expand Down
4 changes: 4 additions & 0 deletions library/src/containers/Servers/Server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export const Server: React.FunctionComponent<Props> = ({
serverName,
server,
}) => {
if (!server) {
return null;
}

const urlVariables = SchemaHelpers.serverVariablesToSchema(
server.variables(),
);
Expand Down
1 change: 0 additions & 1 deletion playground/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ReactDOM from 'react-dom';
import Playground from './Playground';

import '@fortawesome/fontawesome-svg-core/styles.css';
import '@asyncapi/react-component/lib/styles/fiori.css';
import '@asyncapi/react-component/styles/default.min.css';
import './common/icons';

Expand Down