Skip to content

Access parent vars #1568

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

Closed
yonaskolb opened this issue Nov 13, 2015 · 2 comments
Closed

Access parent vars #1568

yonaskolb opened this issue Nov 13, 2015 · 2 comments

Comments

@yonaskolb
Copy link
Contributor

It would be useful to have access to a parent's vars.
This is for when supportsInheritance is set to true in DefaultCodegen

This would allow subclasses to references a super classes properties for doing stuff like the following

class Parent{
    var parentVar:String
    var parentVar2:Bool

    init(parentVar:String, parentVar2:Bool){
        self.parentVar = parentVar
        self.parentVar2 = parentVar2
    }
}

class Child:Parent {
    var childVar:String

    //is accessing the parents properties
    init(childVar:String, parentVar:String, parentVar:Bool) {
        self.childVar = childVar
        super.init(parentVar: parentVar, parentVar: parentVar2)
    }
}

A parents variables could perhaps be references like this {{#parent}}{{#vars}} ... {{/vars}}{{/parent}}

Without this it's not possible to build the example above which is what I'm trying to achieve in a Swift target

@wing328
Copy link
Contributor

wing328 commented Nov 13, 2015

@yonaskolb thanks for offering help to contribute to the Swift API client. For model inheritance, you may want to join the discussion at OAI/OpenAPI-Specification#403.

For your request to access the parent's properties using {{#parent}}{{#vars}} ... {{/vars}}{{/parent}} that you proposed, I think I understand what you meant as I've run into similar issue before when trying to add better support of model inheritance. Last time I checked, it's not easy. I'll take another look later to see if it can now be done without too much effort/time.

@cbornet
Copy link
Contributor

cbornet commented Aug 24, 2016

I think it's now possible with {{#parentModel}}{{#allVars}}

@wing328 wing328 closed this as completed Feb 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants