vacuum icon indicating copy to clipboard operation
vacuum copied to clipboard

no proper validation of XML exemple

Open LasneF opened this issue 2 years ago • 0 comments

given an API Spec with a return content type set to application/xml it raise an error stating that example must be an object

Example for application/xml is not valid: expected object, but got string

i tried also the sample provided there https://swagger.io/docs/specification/data-models/representing-xml/ with no success as well

more details about how XML works here https://spec.openapis.org/oas/latest.html#xml-modeling https://spec.openapis.org/oas/latest.html#xml-object

NB : that the file looks correct according to editor.swagger.io NB2 : reproducible if droping the xml part NB3 : can be tricky or a mistake from myself not 100 % sure, as redocly linter fails as well.

sample to reproduce

{
    "openapi": "3.0.0",
    "info": {
        "title": "Kitten",
        "version": "1.0.0"
    },
    "paths": {
        "/pet": {
            "get": {
                "responses": {
                    "200": {
                        "description": "cat",
                        "content": {
                            "application/xml": {
                                "schema": {
                                    "$ref": "#/components/schemas/niceCatResult"
                                },
                                "example": "<Cat><nice>true</nice></Cat>"
                            }
                        }
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "niceCatResult": {
                "type": "object",
                "properties": {
                    "nice" : {
                        "type": "string"
                    }
                },
                "xml": {
                    "name": "Cat"
                }
            }
        }
    }
}

LasneF avatar Sep 20 '23 11:09 LasneF