Forum Discussion

praveenswager10's avatar
praveenswager10
Occasional Visitor
5 months ago

Swagger JSON Output

With respect to the Swagger plugin currently I am using the version like below

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>3.0.0</version>
</dependency>
in Maven project
where as my Docket Configuration is as below
@Bean
public Docket postsApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.javainuse.swaggertest"))
.paths(PathSelectors.any())
.build()
.pathMapping("/")
.enable(true);
}


private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("JavaInUse API")
.description("JavaInUse API reference for developers")
.termsOfServiceUrl("http://javainuse.com").license("JavaInUse License")
.licenseUrl("javainuse@gmail.com").version("1.0").build();
}


and my rest API configuration is like below
@ApiImplicitParam(
name = "invoicedata",
value = "InvoiceData data",
paramType = "body",
dataType = "com.javainuse.swaggertest.InvoiceData",
dataTypeClass = InvoiceData.class
)
@PostMapping(value = "/setSwaggerParameter")
public ResponseEntity<String> setWarrantsForPendingPB(@ApiIgnore @SessionAttribute InvoiceData invoicedata) {
return new ResponseEntity<String>("Ok", HttpStatus.OK);
}
 
but getting the below out in swagger like
{
"in": "body",
"name": "invoicedata",
"description": "InvoiceData data",
"required": false,
"schema": {
"$ref": "#/definitions/ERROR - ModelName{namespace='com.javainuse.swaggertest', name='InvoiceData'}"
}
}
 
Where as expecting 
{
"in": "body",
"name": "invoicedata",
"description": "InvoiceData data",
"required": false,
"schema": {
"$ref": "#/definitions/InvoiceData "
}
}



 
No RepliesBe the first to reply