openapi-to-postman icon indicating copy to clipboard operation
openapi-to-postman copied to clipboard

Collection agaist schema doesn't support validation correctly for allOf keyword for provided schema.

Open VShingala opened this issue 3 years ago • 0 comments

In this case (API schema below), the user expects that the test data they pass should be invalid because specificType property value does not contain a grandParentTypeData property. However, Postman reports the data as valid.

Reproduction steps (In app):

  • Import the schemas inside Postman
  • Generate a collection for them
  • Create a mock server for each collection
  • Send a request from the generated collections
  • See that NO validation issues are shown, even though there should be issues

Reproduction steps (In module):

  • Use validateTransaction() API to generate result from API and generated collection from it.

API schema:

{
    "info": {
        "title": "Inheritance test API",
        "version": "v1.0"
    },
    "openapi": "3.0.1",
    "paths": {
        "/api/inheritancetest": {
            "get": {
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/Page"
                                }
                            }
                        },
                        "description": "The page data including metadata and content"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "SpecificType": {
                "allOf": [{
                        "$ref": "#/components/schemas/ParentType"
                    }, {
                        "properties": {
                            "specificTypeData": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "specificTypeData"
                        ]
                    }
                ]
            },
            "ParentType": {
                "allOf": [{
                        "$ref": "#/components/schemas/GrandParentType"
                    }, {
                        "properties": {
                            "parentTypeData": {
                                "type": "string"
                            }
                        },
                        "required": [
                            "parentTypeData"
                        ]
                    }
                ]
            },
            "GrandParentType": {
                "properties": {
                    "grandParentTypeData": {
                        "type": "string"
                    }
                },
                "required": [
                    "grandParentTypeData"
                ]
            },
            "Page": {
                "allOf": [{
                        "$ref": "#/components/schemas/GrandParentType"
                    }, {
                        "properties": {
                            "specificType": {
                                "$ref": "#/components/schemas/SpecificType"
                            }
                        },
                        "required": [
                            "specificType"
                        ]
                    }
                ]
            }
        },
        "securitySchemes": {
            "basic": {
                "description": "Basic HTTP Authentication",
                "scheme": "basic",
                "type": "http"
            }
        }
    }
}

VShingala avatar Jul 11 '22 12:07 VShingala