Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Union of DataTypes #532

Open
LuisTCosta opened this issue Aug 6, 2018 · 0 comments
Open

Union of DataTypes #532

LuisTCosta opened this issue Aug 6, 2018 · 0 comments

Comments

@LuisTCosta
Copy link

LuisTCosta commented Aug 6, 2018

Hi, this parser seems incapable of handling the union of user-defined types. I've compiled an example of the problem into this zip.
Inside it, the files are organized as:

- api.raml
- types: 
    |- a.type.raml
    |- b.type.raml
    |- types.lib.raml

The API definition in api.raml uses the types.lib.raml library, which references both type files, a.type.raml and b.type.raml, defining typeA and typeB, respectively. One of the properties of typeA is an array is an array made of strings or typeB's (both may be in the array at the same time).
When validating (passing the directory as the argument) with the latest version, 1.0.26-SNAPSHOT, I get the following output:

$ java -jar raml-java-parser/raml-parser-2/target/raml-parser-2-1.0.26-SNAPSHOT-full.jar sample_api
========================================================================================================================
sample_api\api.raml
========================================================================================================================
1 error found:

        - Invalid type expression syntax: "string | !include b.type.raml". Caused by : Library references cannot be chained: !includeb.type.raml at character : 126 [line=0, col=0]

========================================================================================================================
sample_api\types\a.type.raml
========================================================================================================================
1 error found:

        - Invalid type expression syntax: "string | !include b.type.raml". Caused by : Library references cannot be chained: !includeb.type.raml at character : 126 [line=0, col=0]

========================================================================================================================
sample_api\types\b.type.raml
========================================================================================================================
No errors found.
========================================================================================================================
sample_api\types\types.lib.raml
========================================================================================================================
1 error found:

        - Invalid type expression syntax: "string | !include b.type.raml". Caused by : Library references cannot be chained: !includeb.type.raml at character : 126 [line=0, col=0]

==================================================
Parsed 4 raml files. 1 OK, 3 with Errors.
==================================================

Since the error description mentions libraries, I tried removing them altogether and !include'ing the types manually. This was the result:

========================================================================================================================
sample_api\api.raml
========================================================================================================================
1 error found:

        - Invalid type expression syntax: "string | !include b.type.raml". Caused by : Library references cannot be chained: !includeb.type.raml at character : 126 [line=0, col=0]

========================================================================================================================
sample_api\types\a.type.raml
========================================================================================================================
1 error found:

        - Invalid type expression syntax: "string | !include b.type.raml". Caused by : Library references cannot be chained: !includeb.type.raml at character : 126 [line=0, col=0]

========================================================================================================================
sample_api\types\b.type.raml
========================================================================================================================
No errors found.
==================================================
Parsed 3 raml files. 1 OK, 2 with Errors.
==================================================

I've looked into the Union Type section of the specification and couldn't find anything preventing the union of user defined DataTypes. Is this a limitation of the parser, or just something I'm not seeing in the spec?

Thanks in advance.

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant