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

Fixing ts syntax compile errors and added fix for resolving external … #1

Merged
merged 1 commit into from
Feb 20, 2019

Conversation

Hless
Copy link

@Hless Hless commented Feb 20, 2019

The TS compiler threw errors on compilation, so I fixed those.

When you have Furthermore I also added support for circular depencies with external models using a callback. This ensure that the model is available when the decorator resolves the metadata.

// user.entity.ts
@import { AccessToken } from "./acces-token.enitity'; // AccessToken will be 'undefined' in runtime because User and AccessToken depend on each other
class User {
    ...
    
    @ApiModelProperty({ 
        type: type => User ,  // Using function instead of object resolves the cyclic depency issues, since the AccesToken class will be resolved when the decorator runs
        isArray: true 
     })
    @OneToMany(type => AccessToken, accessTokens => accessTokens.user)
    accessTokens:AccessToken[]
}

---
// access-token.entity.ts

@import { User } from "./user.entity";
class AccessToken {
    ...
    @ApiModelProperty({
        type: type => AccessToken,
     }) 
     @ManyToOne(type => User, user => user.accesTokens)
     user:User
}

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

Successfully merging this pull request may close these issues.

2 participants