0

Q&A (please complete the following information)

Content & configuration

I am migrating from swagger 1.2 to swagger 2.0 spec. My APIs are configured in this way

@ApiOperation(value = "Get user", notes = "get user", response = User.class) @ApiResponses(value = { @ApiResponse(code = RestConstant.STATUS_CODE_400, message = "Invalid User Input"), @ApiResponse(code = RestConstant.STATUS_CODE_500, message = "Internal Server Error") }) @Override @GZIP @Path("/{number}") @PUT public Response getUser( @ApiParam(value = "Profile object with hostname", required = true) User user, @PathParam("accountNumber") String number) { 

Swagger/OpenAPI definition: My schema for request and response is coming as null

"User": { "type": "object", "properties": { }, "xml": { "name": "user" } } 

Swagger-UI configuration options:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="description" content="SwaggerUI" /> <title>SwaggerUI</title> <link rel="stylesheet" href="https://unpkg.com/[email protected]/swagger-ui.css" /> </head> <body> <div id="swagger-ui"></div> <script src="https://unpkg.com/[email protected]/swagger-ui-bundle.js" crossorigin></script> <script src="https://unpkg.com/[email protected]/swagger-ui-standalone-preset.js" crossorigin></script> <script> window.onload = () => { window.ui = SwaggerUIBundle({ url: 'restservices/swagger.json', dom_id: '#swagger-ui', presets: [ SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset ], layout: "StandaloneLayout", }); }; </script> </body> </html> 

How can we help?

I didn't use @ApiModel and @ApiModelProperty with swagger 1.2 and swagger was able to generate schema, but now it is broken. So is it compulsory now? Also I am generating model classes from xsd files, please provide a doc on how to annotate that?

1 Answer 1

0

There was addition of a new method in SwaggerSpecFilter interface - isPropertyAllowed. I was returning by default false which was not loading properties in swagger.json. Changed it to true and its working fine!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.