swaggerize-routes icon indicating copy to clipboard operation
swaggerize-routes copied to clipboard

discriminator support

Open toboid opened this issue 9 years ago • 1 comments

The swagger spec allows polymorphism using a discriminator field. I don't think swaggerize-routes has support for this at the moment, can you confirm this is the case?

For example, say I have an api parameter specified as:

    {
        "name": "params",
        "in": "body",
        "required": true,
        "schema": {
            "type": "object",
            "properties": {
                "things": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/BaseThing"
                    }
                }
            }
        }
    }

and definitions specified as:

    {
        "definitions": {
            "BaseThing": {
                "type": "object",
                "required": ["name", "type"],
                "discriminator": "type",
                "properties": {
                    "name": {
                        "type": "string",
                    },
                    "type": {
                        "type": "string",
                    }
                }
            },
            "ChildThing": {
                "type": "object",
                "required": ["extra"],
                "allOf": [
                    {
                        "$ref": "#/definitions/BaseThing"
                    },
                    {
                        "properties": {
                            "extra": {
                                "type": "string",
                            }
                        }
                    }
                ]
            }
        }
    }

Child thing is ignored and so it's fields are disallowed by validation

toboid avatar Sep 15 '15 09:09 toboid

Since this is once again an example of Swagger not using standard json-schema, default validation will not support it. This is one of the ongoing problems with Swagger in general.

tlivings avatar Sep 16 '15 16:09 tlivings