Empty Schema Object in content response not detected
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
It resumes the ticket: https://github.com/Redocly/redoc/issues/2046
Describe the bug
Here it is an example:
post:
responses:
'422':
description: Unprocessable Entity.
content:
'application/json':
schema:
Expected behavior
It should return an error.
Swagger proposes should be object and stoplight studio proposes "schema" property type must be object.
Additional context
The correct empty fix for that should be:
post:
responses:
'422':
description: Unprocessable Entity.
content:
'application/json': {}
It comes from: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object-example
Ok visibly it is already implemented but I think there is some "miss".
With that example:
post:
operationId: foobar
tags:
- Foo
summary: Create a foo bar.
description: Create a foo bar.
responses:
'201':
description: Foo bar successful.
content:
'application/json': {}
'403':
description: Access Denied.
content:
'application/json':
schema:
'404':
description: Not found
content:
'application/json':
schema:
I've got only one error:
doc/api/foo/bar.yaml:
16:11 error spec Expected type `Schema` (object) but got `null`
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 reproducing the YAML example with the Redocly CLI and trace the OpenAPI response-content validation path; no source file or test is named in the issue. Done means a null schema value produces an error while an empty application/json object remains valid, with a regression test covering both cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100