swagger-api / swagger-api/swagger-codegen
[Angular2-typescript] generating var : "models.Collection..." instead of var : "any"
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied .yml in swagger.zip and the Angular2 TypeScript generator output, comparing the generated model files for CollectionEtrSemantique and CollectionEtrSymptome with the Java Collection fields. Trace how these collection properties are represented and verify that the generated types support iteration without empty interfaces; done means the generated models have usable collection types and match the intended behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, spring-boot, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100