Swagger-Springmvc: Getting unknownFields in JSON

516 Views Asked by At

I have a REST API which I have configured as follows

@Api(value="rest", description="Sweet blah!!!")
@Controller
public class abc{...}

A method in abc is annotated as follows

@ApiOperation(value="Create Account", 
    notes="Sweet Blah",
    response=Account.class,
    nickname="AccountCreation2",
    produces=   "application/json,application/xml",
    consumes="application/json, application/xml")

@ApiImplicitParams(value= 
{ @ApiImplicitParam(name="body",value="Sweet Blah.", 
       required=true, paramType="body", dataType="com.trrr.Account"),
  @ApiImplicitParam(name="accountId", value="provides account Id for the new
       account",required=true, paramType="path", dataType="Integer")
 })

@RequestMapping(value = "/accounts/{accountId}", method = RequestMethod.PUT)

public ResponseEntity<?> createAccount(@PathVariable("accountId") Integer accountId,
     @RequestBody Account acct){ ... }

My generated documentation using Swagger UI shows everything find however is unable to generated Model json for Account which is my model class. Account is composed of few variables, in addition to an array of User Defined class 'Sharing'. It is composed of another User defined class User.

Account class is annotated as follows:

@XStreamAlias("Account")
@XmlRootElement(name = "Account")
public class Account {... }

The generated documentation displays for Model Response and Request

**{
    "unknownFields": {}
}**

Kindly guide as to what may be going wrong here. How to have a json version of Account object displayed. Thank you.

1

There are 1 best solutions below

0
On BEST ANSWER

Well, the same thing worked on a next day. Not sure why it was not working on day one. Its appears idiotic but only purpose of me writing this is to ensure that nobody else doing the right way and gets confused with my post.