Highlighting for request/response sample/example strings ignores content media type (always JSON highlighting)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
Describe the bug
Highlighting for request/response sample/example strings highlights as JSON(ish?) regardless of content type.
Expected behavior
Request/response media type objects allow an example which may be a string or an object. The media-type should determine which (Prism?) highlighting is used. An example for application/x-yaml should be highlighted as YAML, etc.
Minimal reproducible OpenAPI snippet(if possible)
Should hightlight as YAML because content: application/x-yaml has string example. application/x-yaml should govern the highlighting language choice.
openapi: 3.0.3
info: {}
paths:
/something:
post:
operationId: something
requestBody:
content:
application/x-yaml:
example: |
---
some: # comment
- 1 value
- 123 true false null should be a string
- [1,2,3]
---
dates_look_bad:
- 2024-03-22T23:04:35.013+00:00 # should be highlighted as a string
- "2024-03-22T23:04:35.013+00:00" # quoted so is a string
Screenshots
Redoc renders thusly:
Expected
Should look something like this:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use the minimal OpenAPI 3.0.3 snippet in this issue as the first reproduction, checking request-body content example rendering and its syntax-highlighting selection. Done means a string example under application/x-yaml is highlighted as YAML rather than JSON-like, while existing JSON and object-example behavior remains correct; add or update coverage for this behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100