Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 9dceedc

Browse files
committed
opt: 适配yapi的type为数组的情况
1 parent 514da46 commit 9dceedc

File tree

4 files changed

+17
-18
lines changed

4 files changed

+17
-18
lines changed

Plugin/src/com/ciy/plugin/modle/JsonSchemaBean.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.ciy.plugin.modle
33
data class JsonSchemaBean(
44
val title: String,
55
val description: String,
6-
val type: String,
6+
val type: Any,
77
val properties: Map<String, JsonSchemaBean>,
88
val items: JsonSchemaBean,
99
val required: List<String>

Plugin/src/com/ciy/plugin/ui/ShowErrorListDialog.form

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.ciy.plugin.ui.ShowErrorListDialog">
3-
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
66
<xy x="48" y="54" width="529" height="369"/>
@@ -11,7 +11,7 @@
1111
<grid id="94766" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
1212
<margin top="0" left="0" bottom="0" right="0"/>
1313
<constraints>
14-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
14+
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
1515
</constraints>
1616
<properties/>
1717
<border type="none"/>
@@ -49,7 +49,7 @@
4949
</grid>
5050
</children>
5151
</grid>
52-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
52+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
5353
<margin top="0" left="0" bottom="0" right="0"/>
5454
<constraints>
5555
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -66,18 +66,16 @@
6666
<text value="错误列表"/>
6767
</properties>
6868
</component>
69-
<component id="4a49b" class="javax.swing.JList" binding="lsError">
70-
<constraints>
71-
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false">
72-
<preferred-size width="150" height="50"/>
73-
</grid>
74-
</constraints>
75-
<properties>
76-
<foreground color="-4518912"/>
77-
</properties>
78-
</component>
7969
</children>
8070
</grid>
71+
<component id="11fb8" class="javax.swing.JTextArea" binding="taError">
72+
<constraints>
73+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
74+
<preferred-size width="150" height="50"/>
75+
</grid>
76+
</constraints>
77+
<properties/>
78+
</component>
8179
</children>
8280
</grid>
8381
</form>

Plugin/src/com/ciy/plugin/ui/ShowErrorListDialog.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
import java.awt.event.*;
55
import java.util.ArrayList;
66
import java.util.List;
7+
import java.util.stream.Collectors;
78

89
public class ShowErrorListDialog extends JDialog {
910
private JPanel contentPane;
1011
private JButton buttonOK;
1112
private JButton buttonCancel;
12-
private JList lsError;
13+
private JTextArea taError;
1314
private List<Throwable> errorList;
1415

1516
public ShowErrorListDialog(List<Throwable> errorList) {
@@ -50,7 +51,7 @@ public void actionPerformed(ActionEvent e) {
5051
}
5152
}, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
5253

53-
lsError.setListData(errorList.toArray());
54+
taError.setText(errorList.stream().map(it -> (it.toString() + "\n\n")).collect(Collectors.joining()));
5455
}
5556

5657
private void onOK() {

Plugin/src/com/ciy/plugin/utils/ResponseModelGenerate.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ object ResponseModelGenerate {
117117
}
118118
}
119119
// 基本类型
120-
"string", "integer", "boolean", "number", "String", "Integer", "Boolean", "Number" -> {
121-
return PropertySpec.builder(name, getType(jsonSchema.type).copy(true)).initializer("null")
120+
else -> {
121+
return PropertySpec.builder(name, getType(jsonSchema.type.toString()).copy(true)).initializer("null")
122122
.addKdoc(jsonSchema.description ?: "").mutable()
123123
.build()
124124
}

0 commit comments

Comments
 (0)