Skip to content

Commit

Permalink
fix: res_body 可能为空
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Dec 26, 2018
1 parent 6408fc3 commit 2cfd029
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/generateRequestPayloadType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default async function generateRequestPayloadType(api: Api, interfaceName
break
case RequestBodyType.Json:
if (api.req_body_is_json_schema) {
jsonSchema = JSON.parse(api.req_body_other)
jsonSchema = api.req_body_other && JSON.parse(api.req_body_other)
} else {
jsonSchema = api.req_body_other && jsonSchemaGenerator(JSON5.parse(api.req_body_other))
}
Expand Down
2 changes: 1 addition & 1 deletion src/generateResponsePayloadType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function generateResponsePayloadType(api: Api, interfaceNam
case ResponseBodyType.Json:
case ResponseBodyType.JsonSchema:
if (api.res_body_is_json_schema) {
jsonSchema = JSON.parse(api.res_body)
jsonSchema = api.res_body && JSON.parse(api.res_body)
} else {
jsonSchema = api.res_body && mockjsJsonToJsonSchema(JSON5.parse(api.res_body))
}
Expand Down

0 comments on commit 2cfd029

Please sign in to comment.