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

Errors caused by empty map in response examples #9499

Closed
onavratil-monetplus opened this issue Jan 17, 2024 · 1 comment
Closed

Errors caused by empty map in response examples #9499

onavratil-monetplus opened this issue Jan 17, 2024 · 1 comment

Comments

@onavratil-monetplus
Copy link

Q&A (please complete the following information)

  • OS: Windows 10 Pro
  • Browser: Chrome
  • Version: 120.0.6099.217
  • Method of installation: unpkg
  • Swagger-UI version: 5.11.0
  • Swagger/OpenAPI version: OpenAPI 3.1.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: TEST
  description: TEST
  contact:
    name: Ondrej Navratil
    email: onavratil@monetplus.cz
  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: MWE
      tags:
      - TEST

Swagger-UI configuration options:

<html>
<body>
<!--StartFragment-->
<script>
  window.onload = function() {
  window.ui = SwaggerUIBundle( {
      url: "./openapi-dc3f5bb2902dbf447297b747be4c6301d6929a9d.yaml",
      dom_id: '#swagger-ui',
      // deepLinking: true,
      presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
      ],
      //plugins: [
      //  SwaggerUIBundle.plugins.DownloadUrl
      //],
      layout: "StandaloneLayout"
  });
  };
</script>
<!--EndFragment-->
</body>
</html>
?yourQueryStringConfig

Describe the bug you're encountering

I get error in the responses tab
😱 Could not render responses_Responses, see the console.

To reproduce...

Steps to reproduce the behavior:

  1. Try to render the sample yaml. Or any yaml with empty map in response examples.

Expected behavior

Responses render, without examples

Additional context or thoughts

I narrowed the problem down to

              examples: {}

Removing the empty examples map fixes the problem, it may be, however, hard to figure this out.
Nevertheless, the empty map is valid with regards to OAS specs, and should not cause these crashes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants