diff --git a/packages/elements-core/src/components/TryIt/TryIt.spec.tsx b/packages/elements-core/src/components/TryIt/TryIt.spec.tsx
index b1faf49d0..841478cec 100644
--- a/packages/elements-core/src/components/TryIt/TryIt.spec.tsx
+++ b/packages/elements-core/src/components/TryIt/TryIt.spec.tsx
@@ -1,7 +1,7 @@
import '@testing-library/jest-dom';
import { Provider as MosaicProvider } from '@stoplight/mosaic';
-import { HttpParamStyles, IHttpOperation } from '@stoplight/types';
+import { HttpParamStyles, IHttpOperation, IMediaTypeContent } from '@stoplight/types';
import { cleanup, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'jest-fetch-mock';
@@ -609,6 +609,60 @@ describe('TryIt', () => {
expect(bodyHeader).not.toBeInTheDocument();
});
+ it('does not hide panel when request body has no schema but has content', async () => {
+ render(
+ ,
+ );
+
+ let bodyHeader = screen.queryByText('Body');
+ expect(bodyHeader).toBeInTheDocument();
+ });
+
+ it('send content-type header when request body has no schema but has content', async () => {
+ render(
+ ,
+ );
+
+ clickSend();
+ await waitFor(() => expect(fetchMock).toHaveBeenCalled());
+ const requestInit = fetchMock.mock.calls[0][1]!;
+ expect(requestInit.method).toMatch(/^post$/i);
+ const headers = new Headers(requestInit.headers);
+ expect(headers.get('Content-Type')).toBe('application/json');
+ });
+
it('statically generates request body basing on request body schema', () => {
render();
diff --git a/packages/elements-core/src/utils/exampleGeneration/exampleGeneration.ts b/packages/elements-core/src/utils/exampleGeneration/exampleGeneration.ts
index c8f9783c0..9c7807f0a 100644
--- a/packages/elements-core/src/utils/exampleGeneration/exampleGeneration.ts
+++ b/packages/elements-core/src/utils/exampleGeneration/exampleGeneration.ts
@@ -39,6 +39,7 @@ export const generateExampleFromMediaTypeContent = (
) => {
const textRequestBodySchema = mediaTypeContent?.schema;
const textRequestBodyExamples = mediaTypeContent?.examples;
+ const textRequestBodyMediaType = mediaTypeContent?.mediaType;
try {
if (textRequestBodyExamples?.length) {
@@ -57,6 +58,9 @@ export const generateExampleFromMediaTypeContent = (
console.warn(e);
return `Example cannot be created for this schema\n${e}`;
}
+ if (textRequestBodyMediaType) {
+ return '';
+ }
return undefined;
};