-
Notifications
You must be signed in to change notification settings - Fork 191
Description
Describe the bug
given an API specification mixing required keyword and readOnly , writeOnly redocly generate a warning wheras it should not
To Reproduce
given the minimal files attached small.json
redocly lint generate 2 warnings
Expected behavior
it should not,
the object contains Id , name , password , both are required ... in differents scenario
- id is set to ReadOnly
- password as WriteOnly
i would expect to do a single representation of my object, for input / output and exemple matching
this is a quite common use case (especially for id that is generated by server so mandatory in return only ... so readOnly)
i extended the use case to writeOnly and password just for the record.
The Json Schema specification is not 100 % clear if there is a precedence between required statement and the readOnly and writeOnly context .
=> discussing with JsonSchema team , it is up to the upper layer aka OAS / and so redocly to "customize" the validation as it is the only pieces that has the information
Logs
Example value must conform to the schema: must have required property 'id'.
80 | "inputExample" : {
81 | "description" : "sampleOfInput",
82 | "value" : {
83 | "name" : "Doe",
84 | "password" : "securityFirst"
85 | }
86 | },
87 | "outputExample" : {
referenced from small.json:23:45 at #/paths/~1test/post/requestBody/content/application~1json
Warning was generated by the no-invalid-media-type-examples rule.
[2] small.json:89:27 at #/components/examples/outputExample/value
Example value must conform to the schema: must have required property 'password'.
87 | "outputExample" : {
88 | "description" : "sampleOfOutPut",
89 | "value" : {
90 | "id" : "goodId",
91 | "name" : "Doe"
92 | }
93 | }
94 | }
referenced from small.json:39:49 at #/paths/~1test/post/responses/200/content/application~1json
Warning was generated by the no-invalid-media-type-examples rule.
Redocly Version(s)
redocly 1.8.1
Additional context
thx for your attention , do not hesitate to close it if you consider it as too corner case