Petersoj / alpaca-java

A Java API for Alpaca, the commission free, algo friendly, stock trading broker. https://alpaca.markets
https://petersoj.github.io/alpaca-java/
MIT License
203 stars 83 forks source link

@Nullable annotations on the generated client API's #114

Closed Kurru closed 2 years ago

Kurru commented 2 years ago

Is it possible to annotate the generated json apis with Nullable for the fields which may not always be set.

In my opinion, this could help improve the quality of my code by avoiding accidental NullPointerExceptions, though perhaps it would have too many false positives...

Petersoj commented 2 years ago

Hey @Kurru, thanks for the suggestion. Unfortunately, the jsonschema2Pojo reference does not provide a way to attach annotations to the generated fields inside the model class files. Additionally, as you mentioned, adding @Nullable to the fields may produce "false positives" because whether or not a field is always null or sometimes null depends on the request/response. Additionally, Alpaca does not provide a list of what fields are "nullable" in their documentation.