docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

Render callback examples

Open omonk opened this issue 1 month ago • 0 comments

Is your feature request related to a problem?

Request examples are rendered for schemas in the code explorer which is great. Callbacks do not render example | examples when references schemas contain them

Describe the solution you'd like

Schemas which have example or examples defined render the example similar to SwaggerUI. Screenshot contains an update petstore schema (diff listed below)

Image

Describe alternatives you've considered

There are no alternatives

Additional context

diff --git a/demo/examples/petstore.yaml b/demo/examples/petstore.yaml
index 1de97c5..fd99cb3 100644
--- a/demo/examples/petstore.yaml
+++ b/demo/examples/petstore.yaml
@@ -92,23 +92,22 @@ x-tagGroups:
       - store_model
 paths:
   /pet:
-    parameters:
-      - name: Accept-Language
-        in: header
-        description: "The language you prefer for messages. Supported values are en-AU, en-CA, en-GB, en-US"
-        example: en-US
-        required: false
-        schema:
-          type: string
-          default: en-AU
-      - name: cookieParam
-        in: cookie
-        description: Some cookie
-        required: true
-        schema:
-          type: integer
-          format: int64
     post:
+      callbacks: 
+        petCreated:
+          https://example.com/petCreated:
+            post:
+              summary: New pet created callback
+              security: 
+                - api_key: []
+              requestBody:
+                content:
+                  application/json:
+                    schema:
+                      $ref: "#/components/schemas/Pet"
+              responses:
+                "200":
+                  description: Callback successfully processed
       tags:
         - pet
       summary: Add a new pet to the store
@@ -1116,6 +1115,16 @@ components:
       xml:
         name: Order
     Pet:
+      example:
+        name: Fluffy
+        photoUrls:
+          - https://example.com/photos/fluffy1.jpg
+          - https://example.com/photos/fluffy2.jpg
+        tags:
+          - name: cute
+        status: available
+        petType:
+          huntingSkill: adventurous
       type: object
       description: A pet
       required:

You should be able to apply this to main branch by copying the code block and running pbpaste | git apply - against main 2e2631695ab73ea4b

omonk avatar Nov 21 '25 13:11 omonk