Skip to content

Conversation

dsuket
Copy link
Contributor

@dsuket dsuket commented Jul 7, 2025

Description

Original request : #1165 (comment)
I extracted only the handling of property examples.

Additionally, I fixed an issue where a runtime error would occur if there was no schema definition for a mediaObject.

Motivation and Context

There was an issue with property examples not being displayed. I've made it so they are now visible.

How Has This Been Tested?

  • Pass npm run build
  • Pass npm run test
  • I went through the demo API and tests and confirmed that the examples are being displayed properly.

Screenshots (if appropriate)

Before

[before] examples in request parameters schema
before  examples in request parameters schema

[before] examples of properties in requestBody schema
before  examples of properties in requestBody schema

[before] examples of schema properties in response
before  examples of schema properties in response

After

[after] examples in request parameters schema
after  examples in request parameters schema

[after] examples of properties in requestBody schema
after  examples of properties in requestBody schema

[after] examples of schema properties in response
after  examples of schema properties in response

Types of changes

  • New feature (non-breaking change which adds functionality)

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.

@arloktev
Copy link

arloktev commented Jul 31, 2025

What do you think about adding an auto example to Response Example if examples is 1?

https://github.com/PaloAltoNetworks/docusaurus-openapi-docs/blob/main/packages/docusaurus-plugin-openapi-docs/src/openapi/createSchemaExample.ts#L116

let { type, example, allOf, properties, items, oneOf, anyOf, examples } = schemaCopy;
if ((examples !== undefined && examples.length === 1) || example !== undefined) {
    return examples[0] || example;
}

@sserrata
Copy link
Member

What do you think about adding an auto example to Response Example if examples is 1?

Hi @arloktev, would that be to avoid including the "auto" example if the spec already contains static examples?

Copy link

github-actions bot commented Jul 31, 2025

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

https://docusaurus-openapi-36b86--pr1198-wwaf79ov.web.app

(expires Wed, 24 Sep 2025 14:50:12 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: bf293780ee827f578864d92193b8c2866acd459f

@sserrata
Copy link
Member

I extracted only the handling of property examples.

Hi @dsuket, thanks for that...although I'm not sure we're ready to include the "request schema samples" I think property examples is a good options to have.

Copy link

Visual Diff Summary

View Logs

Total: 77, Matches: 75, Diffs: 2, Skipped: 0

Page Status
/tests/get-entities-by-multiple-status diff
/tests/oneof-variations-api diff

@sserrata
Copy link
Member

sserrata commented Aug 1, 2025

Hi @dsuket, the functionality looks good to me but what are your thoughts on the amount of padding between the example tab and the example itself? I was thinking we should maybe reduce it but I recognize it may be coming from a tab component style.

image

@sserrata sserrata self-assigned this Aug 1, 2025
@sserrata sserrata added the reviewing 👀 Undergoing manual audit to determine if issue should still be active label Aug 1, 2025
@dsuket dsuket deployed to default August 9, 2025 09:48 — with GitHub Actions Active
@dsuket
Copy link
Contributor Author

dsuket commented Aug 9, 2025

@sserrata Sorry for the late response. I've made some adjustments to the design.

  • Removed the extra space at the top of the tab content.
  • Spaced out the request parameters a bit to align them with the Schema.

Request Parameter:
スクリーンショット 2025-08-09 18 47 00

Request Body:
スクリーンショット 2025-08-09 18 50 49

How does it look now?

@sserrata
Copy link
Member

How does it look now?

Hi @dsuket, it looks better in my opinion but I think this also changes the global styles for tabs component:

Before:

Screenshot 2025-08-25 at 10 56 59 AM

As you can see, there is no longer any padding

After:

Screenshot 2025-08-25 at 10 56 08 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reviewing 👀 Undergoing manual audit to determine if issue should still be active
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants