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

Include fields that only have getters #69

Open
pascalgn opened this issue Nov 11, 2018 · 1 comment
Open

Include fields that only have getters #69

pascalgn opened this issue Nov 11, 2018 · 1 comment

Comments

@pascalgn
Copy link
Collaborator

Currently, the main focus for generated fields in types is the Java field. But consider the following Java class:

public class User {
    private String firstName;
    private String lastName;

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public String getName() {
        return firstName + " " + lastName;
    }
}

then usually (at least when using Jackson API), instances of that class will result in JSON like this:

{
  "firstName": "John",
  "lastName": "Smith",
  "name": "John Smith"
}

However, as there is no field name in class User, the resulting type will not include the name field:

export User = {
  firstName: string,
  lastName: string
};
@havardh
Copy link
Owner

havardh commented Nov 11, 2018

For simplicity (and because of the restraint on our Dto models) I implemented this using the fields, as the naming of the flowtype fields would be given without translation. But as you point out we should match Jackson in functionality and use the getters as a basis instead. Lets add a flag for selecting which you would want to use.

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

2 participants