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

RAML1.0: Generated POJOs including array type miss List/Set import statement #128

Closed
jenssaade opened this issue Mar 10, 2017 · 2 comments
Closed

Comments

@jenssaade
Copy link

It seems the generation of POJOs using the array type is broken.
POJOs get properly generated, but the collection container class (Set/List) is not imported.

RAML file:

#%RAML 1.0
title: test API
version: v1
baseUri: http://somwhere.io/rest/{version}


types:

  KeyValue:
    type: object
    properties:
      key: string
      value: string

  MyPojo:
    type: object
    displayName: myPojo
    description: a simple object
    properties:
      aKeyValueArray: KeyValue[]

/mypojos:
  get:
    responses:
      200:
        body:
          application/json:
            type: MyPojo

Compiling this with rule Spring4ControllerDecoratorRule results in

Compilation failure:
[ERROR] /.../target/generated-raml-mvc/io/ramltest/rest/model/MyPojo.java:[13,13] cannot find symbol
[ERROR] symbol:   class List
[ERROR] location: class io.ramltest.rest.model.MyPojo
[ERROR] .../target/generated-raml-mvc/io/ramltest/rest/model/MyPojo.java:[27,19] cannot find symbol
[ERROR] symbol:   class List
[ERROR] location: class io.ramltest.rest.model.MyPojo
[ERROR] /.../target/generated-raml-mvc/io/ramltest/rest/model/MyPojo.java:[57,12] cannot find symbol
[ERROR] symbol:   class List
[ERROR] location: class io.ramltest.rest.model.MyPojo
[ERROR] /.../target/generated-raml-mvc/io/ramltest/rest/model/MyPojo.java:[67,35] cannot find symbol
[ERROR] symbol:   class List
[ERROR] location: class io.ramltest.rest.model.MyPojo

The generated POJO:

package io.ramltest.rest.model;

import java.io.Serializable;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

public class MyPojo implements Serializable
{

    final static Long serialVersionUID = -8105318197825619638L;
    private List<KeyValue> aKeyValueArray;

    /**
     * Creates a new MyPojo.
     * 
     */
    public MyPojo() {
        super();
    }

    /**
     * Creates a new MyPojo.
     * 
     */
    public MyPojo(List<KeyValue> aKeyValueArray) {
        super();
        this.aKeyValueArray = aKeyValueArray;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    public boolean equals(Object other) {
        if (other == this) {
            return true;
        }
        if ((other instanceof MyPojo) == false) {
            return false;
        }
        MyPojo otherObject = ((MyPojo) other);
        return new EqualsBuilder().isEquals();
    }

    public int hashCode() {
        return new HashCodeBuilder().toHashCode();
    }

    /**
     * Returns the aKeyValueArray.
     * 
     * @return
     *     aKeyValueArray
     */
    public List<KeyValue> getAKeyValueArray() {
        return aKeyValueArray;
    }

    /**
     * Set the aKeyValueArray.
     * 
     * @param aKeyValueArray
     *     the new aKeyValueArray
     */
    public void setAKeyValueArray(List<KeyValue> aKeyValueArray) {
        this.aKeyValueArray = aKeyValueArray;
    }

}

Using 0.10.0 on branch master.

@kurtparis
Copy link

I think i know why this is happening. Thanks will fix this asap!

@kurtparis
Copy link

Commit 9b80e5f should fix this issue. Will be released with 0.10.1

@kurtpa kurtpa closed this as completed Mar 13, 2017
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