APIDevTools / swagger-parser

Swagger 2.0 and OpenAPI 3.0 parser/validator
https://apitools.dev/swagger-parser
MIT License
1.09k stars 154 forks source link

Required readonly properties should fail with Swagger 2 #111

Open jfrconley opened 5 years ago

jfrconley commented 5 years ago

EDIT: Upon closer inspection, the spec says "SHOULD NOT" not "MUST NOT". Meaning this is merely bad practice, not an error

According to the Swagger 2 spec, readOnly properties are not allowed to be required. The following schema should fail, but does not.

{
    "swagger": "2.0",
    "info": {
        "title": "Parser Bug",
        "version": "3.5.1"
    },
    "paths": {},
    "definitions": {
        "Burn": {
            "properties": {
                "id": {
                    "type": "string",
                    "readOnly": true
                }
            },
            "required": [
                "id"
            ],
            "type": "object"
        }
    }
}

This does not apply to OA3

source

Gi60s commented 4 years ago

The openapi-enforcer handles this correctly.