Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
xiaofang li
MeterSphere
Commits
e28b300c
Commit
e28b300c
authored
4 years ago
by
chenjianxing
Browse files
Options
Download
Email Patches
Plain Diff
fix: 接口定义导出为swagger
parent
088e8079
pr@dev@fix_接口定义导出为swagger
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java
+13
-5
.../metersphere/api/dto/definition/parse/Swagger3Parser.java
with
13 additions
and
5 deletions
+13
-5
backend/src/main/java/io/metersphere/api/dto/definition/parse/Swagger3Parser.java
+
13
-
5
View file @
e28b300c
...
...
@@ -542,6 +542,9 @@ public class Swagger3Parser extends SwaggerAbstractParser {
}
else
{
// JSONOArray
parsedParam
.
put
(
"type"
,
"array"
);
JSONObject
item
=
new
JSONObject
();
if
(
param
==
null
)
{
param
=
new
JSONArray
();
}
if
(((
JSONArray
)
param
).
size
()
>
0
)
{
if
(((
JSONArray
)
param
).
get
(
0
)
instanceof
JSONObject
)
{
///
item
=
buildRequestBodyJsonInfo
((
JSONObject
)
((
JSONArray
)
param
).
get
(
0
));
...
...
@@ -591,11 +594,14 @@ public class Swagger3Parser extends SwaggerAbstractParser {
}
*/
private
JSONObject
buildResponseBody
(
JSONObject
response
)
{
if
(
response
==
null
)
{
return
new
JSONObject
();
}
JSONObject
responseBody
=
new
JSONObject
();
JSONObject
statusCodeInfo
=
new
JSONObject
();
// build 请求头
JSONObject
headers
=
new
JSONObject
();
JSONArray
headValueList
=
response
.
getJSONArray
(
"headers"
);
JSONArray
headValueList
=
response
.
getJSONArray
(
"headers"
);
if
(
headValueList
!=
null
)
{
for
(
Object
item
:
headValueList
)
{
if
(
item
instanceof
JSONObject
&&
((
JSONObject
)
item
).
getString
(
"name"
)
!=
null
)
{
...
...
@@ -654,12 +660,14 @@ public class Swagger3Parser extends SwaggerAbstractParser {
}
}
String
type
=
respOrReq
.
getJSONObject
(
"body"
).
getString
(
"type"
);
JSONObject
content
=
new
JSONObject
();
JSONObject
schema
=
bodyInfo
;
// 请求体部分
JSONObject
typeName
=
new
JSONObject
();
schema
.
put
(
"type"
,
null
);
schema
.
put
(
"format"
,
null
);
typeName
.
put
(
"schema"
,
schema
);
JSONObject
content
=
new
JSONObject
();
if
(
schema
!=
null
)
{
schema
.
put
(
"type"
,
null
);
schema
.
put
(
"format"
,
null
);
typeName
.
put
(
"schema"
,
schema
);
}
if
(
type
!=
null
&&
StringUtils
.
isNotBlank
(
type
))
{
content
.
put
(
typeMap
.
get
(
type
),
typeName
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help