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

Type inheritance is broken for array types #285

Open
tburny opened this issue Sep 12, 2018 · 1 comment
Open

Type inheritance is broken for array types #285

tburny opened this issue Sep 12, 2018 · 1 comment
Labels
bug raml-parser-2 Issue related to raml-parser-2 project v2 Feature will be implemented in v2.0 only (master branch)

Comments

@tburny
Copy link

tburny commented Sep 12, 2018

Given the following RAML where Bar extends Foo and an endpoint that returns a Bar array:

#%RAML 1.0
---
title: e-BookMobile API
baseUri: http://example.com/{version}
version: v1

types:
    Foo:
        type: object
    Bar:
        type: Foo

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

Expected result

class Bar extends Foo in the generated Java code:

public class Bar
    extends Foo
    implements Serializable
{ 

Actual result

Bar does not extend Foo, as seen here:

public class Bar implements Serializable
{

(the extends Foo is missing). The cause is probably because the return type is array (so Bar is not referenced directly) and the generic type in items is Bar:
However note that both Foo and Bar are still generated:

tobias@hattutsch gen/wow » ls -R
.:
BarController.java  model

./model:
Bar.java  Foo.java

When changing the endpoint to use square brackets

/bar:
  get:
    responses:
      200:
        body:
          application/json:
            type: Bar[]

the Bar model is generated correctly

public class Bar
    extends Foo
    implements Serializable
{
@tburny tburny changed the title Type inheritance is broken when used as arrays Type inheritance is broken for array types Sep 12, 2018
@stojsavljevic stojsavljevic added bug v2 Feature will be implemented in v2.0 only (master branch) labels Sep 13, 2018
@stojsavljevic
Copy link
Contributor

Hi,

thanks for reporting the issue.
However, it seems that problem is in raml-parser-2.
I reported the issue using your test case: raml-org/raml-java-parser#552

@stojsavljevic stojsavljevic added the raml-parser-2 Issue related to raml-parser-2 project label Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug raml-parser-2 Issue related to raml-parser-2 project v2 Feature will be implemented in v2.0 only (master branch)
Projects
None yet
Development

No branches or pull requests

2 participants