Home > Back-end >  Excuse me knife4j2. 0.8 swagger2 if display interface parameter contains JsonFormat Shape. The OBJEC
Excuse me knife4j2. 0.8 swagger2 if display interface parameter contains JsonFormat Shape. The OBJEC

Time:01-12

I enumerated type of code
 import com. Baomidou. Mybatisplus. The annotation. IEnum; 
The import com. Fasterxml. Jackson. The annotation. JsonFormat;
The import IO. Swagger. Annotations. ApiModel;
The import IO. Swagger. Annotations. ApiModelProperty;

/*
* @ description: transaction type enumeration class
*/
@ JsonFormat (shape=JsonFormat. Shape. OBJECT)
@ ApiModel (" transaction type enumeration ")
Public enum TransactionType implements IEnum {
Receivable (11, "receivables"),
Receipt (12, "payment"),
Payable (13, "deal with"),
Payment (14, "payment"),
OtherReceipt (21, "other receipts"),
OtherPayment (22, "other payment"),
To the (31, "transfer"),
AccountAdjustment (32, adjust the "account");

private int value;
@ ApiModelProperty (" trade name ")
private String desc;

TransactionType (int value, String desc) {
This value=https://bbs.csdn.net/topics/value;
this.desc=desc;
}

@ Override
Public Integer getValue () {
return value;
}

Public String getDesc () {
Return desc;
}

Public static TransactionType getByValue (int value) {
For (TransactionType TransactionType: values ()) {
If (transactionType. GetValue ()==value) {
Return transactionType;
}
}
return null;
}
}


I interface request object
 public class FinancialTypeQuery extends BaseTenantInfo {

Private static final long serialVersionUID=3796292091036079412 l;

@ ApiModelProperty (" transaction type ")
@ JsonFormat shape=JsonFormat. Shape. (STRING)
Private TransactionType TransactionType;

@ ApiModelProperty (" parent type number ")
Private Long parentSn;

@ ApiModelProperty (" number ")
Private Long sn.

@ ApiModelProperty (" type name ")
private String name;

Type list @ ApiModelProperty (value="https://bbs.csdn.net/topics/", hidden=true)
@ JsonFormat (shape=JsonFormat. Shape. ARRAY)
Private List TransactionTypes;
}


My controller code
 @ RestController 
@ RequestMapping ("/finance/financialType ")
@ Setter (onMethod_={@autowired})
@ Api (tags="financial type interface")
Public class FinancialTypeRest {

Private FinancialTypeService FinancialTypeService;

@ GetMapping (value="https://bbs.csdn.net/page")
@ ApiOperation (value="financial types paging query" https://bbs.csdn.net/topics/
@ Auth (permissions={PermissionType. Finance_setting})
Public ApiResponses Page (FinancialTypePageQuery FinancialTypePageQuery) {

Return ApiResponses. Success (financialTypeService. Page (financialTypePageQuery));
}
}



In order to reduce the code I deleted transactionType left only a few fields and transactionTypes, return is normal, the transactionType json objects, but the request of display is wrong, the front can't read it. What should I do excuse me?

I use the swagger2, reference method is thought to be a single knife4j package, version is the mid-atlantic moved

Com. Making. Xiaoymin
Knife4j - spring - the boot - starter
Mid-atlantic moved & lt;/version>
  • Related