Skip to content

Commit 6a48d42

Browse files
committed
feat: omit content-type header when no parameters are present
1 parent bf67a5c commit 6a48d42

5 files changed

+7
-34
lines changed

idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/RequestClassExporter.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -562,12 +562,13 @@ abstract class RequestClassExporter : ClassExporter {
562562
)
563563
}
564564

565-
if (request.hasBodyOrForm()) {
566-
requestBuilderListener.addHeaderIfMissed(
567-
methodExportContext,
568-
request, "Content-Type", "application/x-www-form-urlencoded"
569-
)
570-
}
565+
// no longer need to set content-type here
566+
//if (request.hasBodyOrForm()) {
567+
// requestBuilderListener.addHeaderIfMissed(
568+
// methodExportContext,
569+
// request, "Content-Type", "application/x-www-form-urlencoded"
570+
// )
571+
//}
571572

572573
}
573574

idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.CustomizedDirectorySpringMarkdownApiExporterTest.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,6 @@ test apis
750750

751751
| `name` | `value` | `desc` |
752752
| ------------ | ------------ | ----: |
753-
| Content-Type | application/x-www-form-urlencoded | |
754753
| token | | auth token |
755754

756755

@@ -799,7 +798,6 @@ test apis
799798

800799
| `name` | `value` | `desc` |
801800
| ------------ | ------------ | ----: |
802-
| Content-Type | application/x-www-form-urlencoded | |
803801
| token | | auth token |
804802

805803

idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.markdown.MarkdownApiExporterTest.DirectorySpringMarkdownApiExporterTest.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ test apis
748748

749749
| name | value | required | desc |
750750
| ------------ | ------------ | ------------ | ------------ |
751-
| Content-Type | application/x-www-form-urlencoded | YES | |
752751
| token | | YES | auth token |
753752

754753

@@ -797,7 +796,6 @@ test apis
797796

798797
| name | value | required | desc |
799798
| ------------ | ------------ | ------------ | ------------ |
800-
| Content-Type | application/x-www-form-urlencoded | YES | |
801799
| token | | YES | auth token |
802800

803801

idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.DirectorySpringPostmanApiExporterTest.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,12 +1421,6 @@
14211421
"method": "POST",
14221422
"description": "",
14231423
"header": [
1424-
{
1425-
"key": "Content-Type",
1426-
"value": "application/x-www-form-urlencoded",
1427-
"type": "text",
1428-
"description": ""
1429-
},
14301424
{
14311425
"key": "token",
14321426
"value": "",
@@ -1454,12 +1448,6 @@
14541448
"method": "POST",
14551449
"description": "",
14561450
"header": [
1457-
{
1458-
"key": "Content-Type",
1459-
"value": "application/x-www-form-urlencoded",
1460-
"type": "text",
1461-
"description": ""
1462-
},
14631451
{
14641452
"key": "token",
14651453
"value": "",

idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.DirectorySpringYapiApiExporterTest.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,6 @@
486486
"__v": 0,
487487
"markdown": "",
488488
"req_headers": [
489-
{
490-
"name": "Content-Type",
491-
"value": "application/x-www-form-urlencoded",
492-
"example": "application/x-www-form-urlencoded",
493-
"required": 1
494-
},
495489
{
496490
"name": "token",
497491
"value": "",
@@ -528,12 +522,6 @@
528522
"__v": 0,
529523
"markdown": "",
530524
"req_headers": [
531-
{
532-
"name": "Content-Type",
533-
"value": "application/x-www-form-urlencoded",
534-
"example": "application/x-www-form-urlencoded",
535-
"required": 1
536-
},
537525
{
538526
"name": "token",
539527
"value": "",

0 commit comments

Comments
 (0)