jhthorsen / mojolicious-plugin-openapi

OpenAPI / Swagger plugin for Mojolicious
53 stars 41 forks source link

readOnly validation in nested refs is broken in 5.х release #225

Closed xurc closed 2 years ago

xurc commented 2 years ago

It looks as if in the 5.x version (of JSON::Validator?), at least the readOnly validation in nested refs is broken. For example:

       "Id": {
         "type": "integer",
         "title": "Id",
         "description": "Id",
         "format": "int32",
         "readOnly": true
       },

And, in another model:

           "id": {
             "$ref": "#/components/schemas/Id"
           },

When validating, POST gives an error about the absence of id in the body.

If you change the spec version to "openapi": "3.1.0" and add readOnly to reference the model, as version 3.1 allows:

           "id": {
             "$ref": "#/components/schemas/Id",
             "readOnly": true
           },

the error is also present. Presumably also broken validation of writeOnly, nullable etc.

jhthorsen commented 2 years ago

Thanks for reporting in 👍 This should be fixed in the upcoming release of JSON::Validator. (v5.03)