raml-java-parser icon indicating copy to clipboard operation
raml-java-parser copied to clipboard

Discriminator seems to be global in validation

Open jenschude opened this issue 8 years ago • 0 comments

When using this RAML

#%RAML 1.0
---
title: Test
types:
    FooAction:
        type: object
        discriminator: action
        properties:
            action: string
    FooTestAction:
        type: FooAction
        discriminatorValue: test
        properties:
            name: object

    BarAction:
        type: object
        discriminator: action
        properties:
            action: string
    BarTestAction:
        type: FooAction
        discriminatorValue: test
        properties:
            name: string
/bar:
    post:
        body:
            application/json:
                type: BarAction
                example: |
                    {
                        "action": "test",
                        "name": "Test"
                    }
/foo:
    post:
        body:
            application/json:
                type: FooAction
                example: |
                    {
                        "action": "test",
                        "name": {
                            "en": "Test"
                        }
                    }

I get this error "Error validating JSON. Error: - Invalid type String, expected Object -- test.raml [line=42, col=26]"

The parser seems not to take into account that a discriminator may only be valid for a specific type.

Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-98

jenschude avatar Mar 24 '17 09:03 jenschude