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

Type inheritance is broken for array types #552

Open
stojsavljevic opened this issue Sep 13, 2018 · 0 comments
Open

Type inheritance is broken for array types #552

stojsavljevic opened this issue Sep 13, 2018 · 0 comments

Comments

@stojsavljevic
Copy link

stojsavljevic commented Sep 13, 2018

Hi,

I have a problem getting type of object for item in response array.
Consider this raml:

#%RAML 1.0
title: Type inheritance is broken for array types

types:
    Foo:
        type: object
    Bar:
        type: Foo
        
        
/bar:
  get:
    responses:
      200:
        body:
          application/json:
            type: array
            items: Bar

and my test case:

RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new File("api.raml"));
Api api = ramlModelResult.getApiV10();
for (Resource res : api.resources()) {
	for (Method method : res.methods()) {
		for (Response response : method.responses()) {
			for (TypeDeclaration type : response.body()) {
				ArrayTypeDeclaration array = (ArrayTypeDeclaration) type;
				TypeDeclaration items = array.items();
				System.out.println(items.type());
			}
		}
	}
}

will print out: Bar

But if I define response in raml like this:

application/json:
   type: Bar[]

test case will print out: Foo as expected.

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

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