Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

discriminator support #46

Open
toboid opened this issue Sep 15, 2015 · 1 comment
Open

discriminator support #46

toboid opened this issue Sep 15, 2015 · 1 comment
Milestone

Comments

@toboid
Copy link

toboid commented Sep 15, 2015

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

@tlivings
Copy link
Contributor

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.

@subeeshcbabu-zz subeeshcbabu-zz added this to the v2.0.0 milestone Jul 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants