swagger-api / swagger-api/swagger-ui
Error with comments when using $ref: ExampleElement value and externalValue fields are mutually exclusive.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Q&A (please complete the following information)
- OS: Debian 12
- Browser: Chrome
- Version: 133
- Method of installation: dist folder
- Swagger-UI version: 5.20.8
- Swagger/OpenAPI version: OpenAPI 3.1.0
Content & configuration
index.yaml
openapi: 3.1.0
info:
title: 'Bug test'
version: 1.0.0
servers:
- url: /bug
paths:
/test:
$ref: test.yaml
test.yaml:
post:
responses:
'200':
content:
application/json:
examples:
testExample:
summary: Test example
externalValue: test.json
test.json:
{}
Describe the bug you're encountering
This configuration with $ref used in path is throwing Error:
Resolver error at post.responses.200.content.application/json.examples.testExample.externalValue
Could not resolve reference: ExampleElement value and externalValue fields are mutually exclusive.
When there is no $ref used and the content of test.yaml is directly included in the main index.yaml, no error occurs.
To reproduce...
Just open this definition in UI.
Expected behavior
This error should not occur as the definition is exactly the same. The difference is just the $ref. The $ref is supported under particular paths in OpenAPI 3.
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
Start by opening the supplied index.yaml in Swagger UI with test.yaml and test.json available, then compare it with the inline definition described in the report. Trace the $ref path to the externalValue example and verify that the referenced configuration no longer raises the mutually exclusive fields error while preserving the expected example behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100