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

Ignore static fields in SpringObjectBuilder #207

Closed
stagr opened this issue Aug 31, 2016 · 2 comments
Closed

Ignore static fields in SpringObjectBuilder #207

stagr opened this issue Aug 31, 2016 · 2 comments
Milestone

Comments

@stagr
Copy link

stagr commented Aug 31, 2016

When using JSONDoc with Spring MVC it automatically generates documentation also for "static" fields causing the UI to show them in the list of fields and in the prefilled JSON in the playground.

Example:

public class Pojo {
  ...
  private static final long serialVersionUID = 1234;
  ...
}

generates the following in the list of fields of Pojo class:

serialVersionUID Type: long

and the following in the prefilled JSON in the playground:

{
  ...
  "serialVersionUID": 0,
  ...
}

A solution is simply to ignore all static fields when iterating over all fields in the SpringObjectBuilder:

for (Field field : clazz.getDeclaredFields()) {

  // Only add fields that are not static
  if (!Modifier.isStatic(field.getModifiers())) {
    ApiObjectFieldDoc fieldDoc = new ApiObjectFieldDoc();
   ...
  }
  ...
}
@MonkeyTonk
Copy link

I think PR #217 of issue #215 by @osigge should solve this problem. Maybe issues #207 and #215 should be merged.

@fabiomaffioletti
Copy link
Owner

Solved with #217

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

3 participants