Skip to content

Conversation

iain-smartretail
Copy link
Contributor

Description

When providing examples of application/json request body content, docusaurus-theme-openapi-docs will double escape the content for display and for use in code samples.

Motivation and Context

This pull request introduces changes to correctly render request body examples. This brings request body examples inline with response body examples which are already rendered correctly.

How Has This Been Tested?

Minimal example

openapi: 3.0.3
info:
  title: Minimal Example
  version: 1.0.0
servers:
  - url: http://example.com
paths:
  /demo:
    post:
      summary: Demo Endpoint
      description: Demo incorrect request body rendering
      requestBody:  
        content:
          application/json:
            schema: 
              type: object
              properties:
                test:
                  type: string
                  example: alpha
            examples:
              bravo:
                summary: Bravo
                value: |
                  {
                    "test": "bravo"
                  }
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema: 
                type: object
                properties: 
                  success:
                    type: boolean
              examples:
                ok:
                  summary: OK
                  value: |
                    {
                      "success": true
                    }

Screenshots (if appropriate)

Before pull request:
image

After pull request:
image

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes if appropriate.
  • All new and existing tests passed.

Copy link

github-actions bot commented Mar 7, 2025

Visit the preview URL for this PR (updated for commit c4e9551):

https://docusaurus-openapi-36b86--pr1100-agjufohh.web.app

(expires Sun, 06 Apr 2025 21:11:27 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@blindaa121 blindaa121 merged commit d7c18c9 into PaloAltoNetworks:main Mar 7, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants