Validation of substituted content (as effect of resolving `$ref`s) leads to confusing error reports
Is your feature request related to a problem? Please describe.
Validation of substituted content (as effect of resolving $refs) leads to confusing error reports.
For example, we have the following spec:
openapi: 3.0.3
servers:
- url: //example.com/api
description: Production
info:
version: '1.0'
title: Sample API spec
paths:
/something:
post:
summary: Post something
operationId: postSomething
requestBody:
$ref: '#/components/schemas/SomethingSpec'
responses:
'204':
description: Response
components:
schemas:
SomethingSpec:
description: Something
properties:
name:
type: string
That spec has invalid syntax of requestBody block (line 14), but otherwise perfectly valid SomethingSpec schema. Instead validator reports that we have problems with SomethingSpec schema (at lines 21 and 23):
λ docker run --rm -it -v v1.yaml:/v1.yaml redocly/openapi-cli:v1.0.0-beta.67 lint /v1.yaml
No configurations were defined in extends -- using built in recommended configuration by default.
validating /v1.yaml...
[1] ../v1.yaml:21:5 at #/components/schemas/SomethingSpec
The field `content` must be present on this level.
19 | components:
20 | schemas:
21 | SomethingSpec:
22 | description: Something
23 | properties:
Error was generated by the spec rule.
[2] ../v1.yaml:23:7 at #/components/schemas/SomethingSpec/properties
Property `properties` is not expected here.
21 | SomethingSpec:
22 | description: Something
23 | properties:
24 | name:
25 | type: string
Error was generated by the spec rule.
I got similar problem with rather big OpenAPI spec and spent much time to figure out why validator says that my schemas is incorrect when it is obvious they are good.
Describe the solution you'd like
I think validator should explicitly point out real context of the specification which have some problems in it. In the demonstrated case it is not the schema object, but requestBody (after substitution of the content of SomethingSpec).