Skip to content

[Angular2-typescript] generating var : "models.Collection..." instead of var : "any" #6495

@Yolepo

Description

@Yolepo

Hello,

The new version of codegen define collection in my object like

  • someVar : models.CollectionSomeObject
    The old one
  • someVar : any

The "CollectionSomeObject" are empty interface in both codegen versions.

The issue is :
-When i use an iterator on new version of "someVar" the compilator say that this is not an array or collection, which is actually true cause CollectionSomeObject is an empty interface.

I think that someVar : models.CollectionSomeObject is a good evolve but not if all the interfaces are still empty object.

The yml is generated from springboot with le latest release

a sample :
Now :
`
import * as models from './models';

export interface EtrTypechamp {
attribut?: string;

concept?: string;

etrSemantiquesByEtrTypechampid?: **models.CollectionEtrSemantique;**

etrSymptomesByEtrTypechampid?: **models.CollectionEtrSymptome;**

etrTypechampid?: number;

format?: string;

typeentite?: string;

}
**Before :**
import * as models from './models';

export interface EtrTypechamp {
attribut?: string;

concept?: string;

etrSemantiquesByEtrTypechampid?: **any;**

etrSymptomesByEtrTypechampid?: **any;**

etrTypechampid?: number;

format?: string;

typeentite?: string;

}
`
the collections in both versions are empty :

`
import * as models from './models';

export interface CollectionEtrSemantique {
}
`

The POJO (Java) :

`
import javax.persistence.*;
import java.util.Collection;

@entity
@table(name = "etr_typechamp", schema = "public", catalog = "etr")
public class EtrTypechamp {
private String concept;
private String format;
private long etrTypechampid;
private String typeentite;
private String attribut;
private Collection etrSemantiquesByEtrTypechampid;
private Collection etrSymptomesByEtrTypechampid;

@Basic
@Column(name = "concept", nullable = false, length = 7)
public String getConcept() {
    return concept;
}

public void setConcept(String concept) {
    this.concept = concept;
}

@Basic
@Column(name = "format", nullable = false, length = 20)
public String getFormat() {
    return format;
}

public void setFormat(String format) {
    this.format = format;
}

@Id
@SequenceGenerator(name = "etr_typechamp_etr_typechampid_seq",
        sequenceName = "etr_typechamp_etr_typechampid_seq",
        allocationSize = 1)
@GeneratedValue(strategy = GenerationType.SEQUENCE,
        generator = "etr_typechamp_etr_typechampid_seq")
@Column(name = "etr_typechampid", nullable = false)
public long getEtrTypechampid() {
    return etrTypechampid;
}

public void setEtrTypechampid(long etrTypechampid) {
    this.etrTypechampid = etrTypechampid;
}

@Basic
@Column(name = "typeentite", nullable = false, length = 20)
public String getTypeentite() {
    return typeentite;
}

public void setTypeentite(String typeentite) {
    this.typeentite = typeentite;
}

@Basic
@Column(name = "attribut", nullable = false, length = 8)
public String getAttribut() {
    return attribut;
}

public void setAttribut(String attribut) {
    this.attribut = attribut;
}

@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    EtrTypechamp that = (EtrTypechamp) o;

    if (etrTypechampid != that.etrTypechampid) return false;
    if (concept != null ? !concept.equals(that.concept) : that.concept != null) return false;
    if (format != null ? !format.equals(that.format) : that.format != null) return false;
    if (typeentite != null ? !typeentite.equals(that.typeentite) : that.typeentite != null) return false;
    return attribut != null ? attribut.equals(that.attribut) : that.attribut == null;
}

@Override
public int hashCode() {
    int result = concept != null ? concept.hashCode() : 0;
    result = 31 * result + (format != null ? format.hashCode() : 0);
    result = 31 * result + (int) (etrTypechampid ^ (etrTypechampid >>> 32));
    result = 31 * result + (typeentite != null ? typeentite.hashCode() : 0);
    result = 31 * result + (attribut != null ? attribut.hashCode() : 0);
    return result;
}

@OneToMany(mappedBy = "etrTypechampByEtrTypechampid")
public Collection<EtrSemantique> getEtrSemantiquesByEtrTypechampid() {
    return etrSemantiquesByEtrTypechampid;
}

public void setEtrSemantiquesByEtrTypechampid(Collection<EtrSemantique> etrSemantiquesByEtrTypechampid) {
    this.etrSemantiquesByEtrTypechampid = etrSemantiquesByEtrTypechampid;
}

@OneToMany(mappedBy = "etrTypechampByEtrTypechampid")
public Collection<EtrSymptome> getEtrSymptomesByEtrTypechampid() {
    return etrSymptomesByEtrTypechampid;
}

public void setEtrSymptomesByEtrTypechampid(Collection<EtrSymptome> etrSymptomesByEtrTypechampid) {
    this.etrSymptomesByEtrTypechampid = etrSymptomesByEtrTypechampid;
}

}
`
The .yml.

swagger.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions