openservicebrokerapi / servicebroker

Open Service Broker API Specification
https://openservicebrokerapi.org/
Apache License 2.0
1.19k stars 436 forks source link

Java code generated from swagger.yaml using swagger-codegen-cli causes NPE #693

Closed MosheElisha closed 2 years ago

MosheElisha commented 5 years ago

Hi,

  1. Generate Java code from the swagger.yaml using swagger-codegen-cli with this command:

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i "/tmp/swagger.yaml" -l jaxrs-cxf -o /tmp/project

  1. Use the generated classes in a spring boot application and enable the Swagger2Feature:

endpoint.setFeatures(Collections.singletonList(new Swagger2Feature()));

You get a java.lang.NullPointerException: null at io.swagger.models.refs.GenericRef.<init>(GenericRef.java:44) attached npe.log

The cause is probably the generated model class Object.java.txt which is generated without properties according to the definition in https://github.com/openservicebrokerapi/servicebroker/blob/e953ad2b478264900f6376ec886bb5921073aac2/swagger.yaml#L799

The workaround is to delete the generated Object.java file and let all the classes that uses it (for example, ServiceBindingVolumeMountDevice.mountConfig) to use java.lang.Object instead.

mattmcneeney commented 4 years ago

Thanks for raising this @MosheElisha - we will see if we can find someone to look into this next week.

jberkhahn commented 4 years ago

/dibs

jberkhahn commented 4 years ago

see PR #696

MosheElisha commented 4 years ago

Thanks!

pivotal-marcela-campo commented 2 years ago

Closing as this was fixed with PR already merged