swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

help getting started with jackson generation

Open npomfret opened this issue 9 years ago • 4 comments

I'm trying to generate a java jackson api (with @JsonProperty annotation etc) from https://github.com/npomfret/coinsbank-php-sdk/blob/master/reference/coinsbank-sapi.json.

So i run:

swagger-codegen generate -i https://raw.githubusercontent.com/npomfret/coinsbank-php-sdk/master/reference/coinsbank-sapi.json -l java -o temp

How do I get it to generate the jackson annotations?

Also, it crashes after generating some classes at Resource: put /card/name/_{cardUniqueId} with:

Caused by: java.lang.NullPointerException
        at io.swagger.codegen.DefaultCodegen.isDataTypeBinary(DefaultCodegen.java:2590)

This isn't my json, so I'm not too familiar with it. Maybe it's not well formed swagger?

npomfret avatar Jun 06 '17 10:06 npomfret

I used spring language and it generated all Jackson annotations in models, if that is what you looking for then you run following command: swagger-codegen generate -i https://raw.githubusercontent.com/npomfret/coinsbank-php-sdk/master/reference/coinsbank-sapi.json -l spring -o temp

ravinikam avatar Jun 06 '17 14:06 ravinikam

Thanks, that's exactly the command I'm using. Some objects get generated - but then it crashes.

npomfret avatar Jun 06 '17 15:06 npomfret

In your question you said you are using "java", so suggested to use "spring" language instead to get Jackson annotation in your models.

About your second question: You have huge specification file, I would recommend to split it. Thats aside I tried to import your specification to swagger editor and saw there are errors, so I would recommend to fix those errors before trying anything.

ravinikam avatar Jun 06 '17 18:06 ravinikam

Thanks for the reply.

It's not my file unfortunately. Using the spring flag worked. Well, it at least generated some useful classes.

npomfret avatar Jun 06 '17 18:06 npomfret