i have a springboot project working with 2.5.14 version. I migrate my Swagger 2 to Swagger Open Api but i got some errors.
While upgrading instead of using springfox, i removed them and started to use springdoc-openapi-ui
Here is before and after pom changes
Before:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox.version}</version>
</dependency>
After:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.7.0</version>
</dependency>
I first used 1.3.4 version but it generates InlineObject for some controllers' path variables. Then i started to use 1.7.0 because version 1.6.3 and upper ones not have this problem.
In generated api-doc some objects not contains all of their variables. As an example:
@Data
public class BaseRequest implements Serializable {
private static final long serialVersionUID = 1L;
private UserDto userDto;
private Long logId;
}
@Data
@EqualsAndHashCode(callSuper = false)
public class ServiceBasedProcessRequest extends BaseRequest {
private static final long serialVersionUID = 1L;
private String name;
private ProcessCode processCode;
private String drgCode;
private DoctorInfo doctorInfo;
private BigDecimal amountRequest;
private Date processDateTime;
private DetailDto detail;
private String orderNo;
private BigDecimal rateVat;
private String rightLeft;
private Note explanation;
private Integer count;
private String swiftCode;
private DoctorDto enrichedDoctorDto;
private CurrencyType currencyType;
private Boolean isNew;
private List<ParameterTypeDto> parameterList;
}
In the Open api generated document ServiceBasedProcessRequest Object Json doesn't contains userDto, logId, swiftCode, enrichedDoctorDto, currencyType, isNew, parameterList
Swagger 2 - /v2/api-docs:
"ServiceBasedProcessRequest":{
"type":"object",
"properties":{
"amountRequest":{
"type":"number"
},
"count":{
"type":"integer",
"format":"int64"
},
"detail":{
"$ref":"#/definitions/DetailDto"
},
"doctorInfo":{
"$ref":"#/definitions/DoctorInfo"
},
"drgCode":{
"type":"string"
},
"enrichedDoctorDto":{
"$ref":"#/definitions/DoctorDto"
},
"explanation":{
"$ref":"#/definitions/Note"
},
"isNew":{
"type":"boolean"
},
"logId":{
"type":"integer",
"format":"int64"
},
"currencyType":{
"type":"string",
"enum":[
"USD",
"EUR",
"TL"
]
},
"name":{
"type":"string"
},
"orderNo":{
"type":"string"
},
"parameterList":{
"type":"array",
"items":{
"$ref":"#/definitions/ParameterTypeDto"
}
},
"processCode":{
"$ref":"#/definitions/ProcessCode"
},
"processDateTime":{
"type":"string",
"format":"date-time"
},
"rateVat":{
"type":"number"
},
"rightLeft":{
"type":"string"
},
"swiftCode":{
"type":"string"
},
"userDto":{
"$ref":"#/definitions/UserDto"
}
},
"title":"ServiceBasedProcessRequest"
}
Open Api - /v3/api-docs::
"ServiceBasedProcessRequest":{
"type":"object",
"properties":{
"amountRequest":{
"type":"number"
},
"count":{
"type":"integer",
"format":"int64"
},
"detail":{
"$ref":"#/components/schemas/DetailDto"
},
"doctorInfo":{
"$ref":"#/components/schemas/DoctorInfo"
},
"drgCode":{
"type":"string"
},
"explanation":{
"$ref":"#/components/schemas/Note"
},
"name":{
"type":"string"
},
"orderNo":{
"type":"string"
},
"processCode":{
"$ref":"#/components/schemas/ProcessCode"
},
"processDateTime":{
"type":"string",
"format":"date-time"
},
"rateVat":{
"type":"number"
},
"rightLeft":{
"type":"string"
},
"swiftCode":{
"type":"string"
}
}
}
Yaml configs:
springdoc:
swagger-ui:
docExpansion: none
displayRequestDuration: true
deepLinking: true
showExtensions: true
operationsSorter: alpha
tagsSorter: alpha
cache:
disabled: true
writer-with-order-by-keys: true
I did tried to add @Schema but i still didn't generate them. Is there an any configuration for this problem ?