diff --git a/src/core/components/response.jsx b/src/core/components/response.jsx
index e5ab42edfc3..f703a9194d5 100644
--- a/src/core/components/response.jsx
+++ b/src/core/components/response.jsx
@@ -134,7 +134,7 @@ export default class Response extends React.Component {
// Goal: find an example value for `sampleResponse`
if(isOAS3) {
sampleSchema = activeMediaType.get("schema")?.toJS()
- if(examplesForMediaType) {
+ if(Map.isMap(examplesForMediaType) && !examplesForMediaType.isEmpty()) {
const targetExamplesKey = this.getTargetExamplesKey()
const targetExample = examplesForMediaType
.get(targetExamplesKey, Map({}))
@@ -208,7 +208,7 @@ export default class Response extends React.Component {
) : null}
- {examplesForMediaType ? (
+ {Map.isMap(examplesForMediaType) && !examplesForMediaType.isEmpty() ? (
Examples
diff --git a/test/e2e-cypress/e2e/features/response-empty-examples-object.cy.js b/test/e2e-cypress/e2e/features/response-empty-examples-object.cy.js
new file mode 100644
index 00000000000..7c000a6e7a1
--- /dev/null
+++ b/test/e2e-cypress/e2e/features/response-empty-examples-object.cy.js
@@ -0,0 +1,16 @@
+/**
+ * @prettier
+ */
+
+describe("Response examples", () => {
+ it("should render a generated example when an empty examples object is provided", () => {
+ cy.visit("/?url=/documents/features/response-empty-examples-object.yaml")
+ .get("#operations-TEST-test")
+ .click()
+ .get(".example.microlight")
+ .should("exist")
+ .contains("{}")
+ .get(".examples-select-element")
+ .should("not.exist")
+ })
+})
diff --git a/test/e2e-cypress/static/documents/features/response-empty-examples-object.yaml b/test/e2e-cypress/static/documents/features/response-empty-examples-object.yaml
new file mode 100644
index 00000000000..daf01826834
--- /dev/null
+++ b/test/e2e-cypress/static/documents/features/response-empty-examples-object.yaml
@@ -0,0 +1,25 @@
+openapi: 3.1.0
+info:
+ title: TEST
+ description: TEST
+ version: '1.0'
+servers:
+- url: localhost:8080
+tags:
+- name: TEST
+paths:
+ /test-endpoint:
+ get:
+ summary: Test
+ operationId: test
+ responses:
+ '200':
+ description: OK
+ content:
+ application/json:
+ schema:
+ type: object
+ examples: {}
+ description: Test
+ tags:
+ - TEST