Skip to content

Commit 03c48af

Browse files
committed
Fix content-type and accept in PHP API
1 parent 6ac497d commit 03c48af

File tree

9 files changed

+397
-42
lines changed

9 files changed

+397
-42
lines changed

modules/swagger-codegen/src/main/resources/php/api.mustache

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,12 @@ class {{classname}} {
4444
$queryParams = array();
4545
$headerParams = array();
4646
$formParams = array();
47-
$headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
48-
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
47+
$_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}';
48+
if ($_header_accept !== '') {
49+
$headerParams['Accept'] = $_header_accept;
50+
}
51+
$_header_content_type = array({{#consumes}}'{{mediaType}}'{{#hasMore}},{{/hasMore}}{{/consumes}});
52+
$headerParams['Content-Type'] = count($_header_content_type) > 0 ? $_header_content_type[0] : 'application/json';
4953

5054
{{#queryParams}}// query params
5155
if(${{paramName}} !== null) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
namespace io.swagger.Model {
7+
public class category {
8+
9+
10+
11+
public long? id { get; set; }
12+
13+
14+
15+
16+
public string name { get; set; }
17+
18+
19+
20+
public override string ToString() {
21+
var sb = new StringBuilder();
22+
sb.Append("class category {\n");
23+
24+
sb.Append(" id: ").Append(id).Append("\n");
25+
26+
sb.Append(" name: ").Append(name).Append("\n");
27+
28+
sb.Append("}\n");
29+
return sb.ToString();
30+
}
31+
}
32+
33+
34+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
namespace io.swagger.Model {
7+
public class order {
8+
9+
10+
11+
public long? id { get; set; }
12+
13+
14+
15+
16+
public long? petId { get; set; }
17+
18+
19+
20+
21+
public int? quantity { get; set; }
22+
23+
24+
25+
26+
public DateTime shipDate { get; set; }
27+
28+
29+
30+
/* Order Status */
31+
32+
public string status { get; set; }
33+
34+
35+
36+
37+
public bool? complete { get; set; }
38+
39+
40+
41+
public override string ToString() {
42+
var sb = new StringBuilder();
43+
sb.Append("class order {\n");
44+
45+
sb.Append(" id: ").Append(id).Append("\n");
46+
47+
sb.Append(" petId: ").Append(petId).Append("\n");
48+
49+
sb.Append(" quantity: ").Append(quantity).Append("\n");
50+
51+
sb.Append(" shipDate: ").Append(shipDate).Append("\n");
52+
53+
sb.Append(" status: ").Append(status).Append("\n");
54+
55+
sb.Append(" complete: ").Append(complete).Append("\n");
56+
57+
sb.Append("}\n");
58+
return sb.ToString();
59+
}
60+
}
61+
62+
63+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
namespace io.swagger.Model {
7+
public class pet {
8+
9+
10+
11+
public long? id { get; set; }
12+
13+
14+
15+
16+
public Category category { get; set; }
17+
18+
19+
20+
21+
public string name { get; set; }
22+
23+
24+
25+
26+
public List<string> photoUrls { get; set; }
27+
28+
29+
30+
31+
public List<Tag> tags { get; set; }
32+
33+
34+
35+
/* pet status in the store */
36+
37+
public string status { get; set; }
38+
39+
40+
41+
public override string ToString() {
42+
var sb = new StringBuilder();
43+
sb.Append("class pet {\n");
44+
45+
sb.Append(" id: ").Append(id).Append("\n");
46+
47+
sb.Append(" category: ").Append(category).Append("\n");
48+
49+
sb.Append(" name: ").Append(name).Append("\n");
50+
51+
sb.Append(" photoUrls: ").Append(photoUrls).Append("\n");
52+
53+
sb.Append(" tags: ").Append(tags).Append("\n");
54+
55+
sb.Append(" status: ").Append(status).Append("\n");
56+
57+
sb.Append("}\n");
58+
return sb.ToString();
59+
}
60+
}
61+
62+
63+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
namespace io.swagger.Model {
7+
public class tag {
8+
9+
10+
11+
public long? id { get; set; }
12+
13+
14+
15+
16+
public string name { get; set; }
17+
18+
19+
20+
public override string ToString() {
21+
var sb = new StringBuilder();
22+
sb.Append("class tag {\n");
23+
24+
sb.Append(" id: ").Append(id).Append("\n");
25+
26+
sb.Append(" name: ").Append(name).Append("\n");
27+
28+
sb.Append("}\n");
29+
return sb.ToString();
30+
}
31+
}
32+
33+
34+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Text;
3+
using System.Collections;
4+
using System.Collections.Generic;
5+
6+
namespace io.swagger.Model {
7+
public class user {
8+
9+
10+
11+
public long? id { get; set; }
12+
13+
14+
15+
16+
public string username { get; set; }
17+
18+
19+
20+
21+
public string firstName { get; set; }
22+
23+
24+
25+
26+
public string lastName { get; set; }
27+
28+
29+
30+
31+
public string email { get; set; }
32+
33+
34+
35+
36+
public string password { get; set; }
37+
38+
39+
40+
41+
public string phone { get; set; }
42+
43+
44+
45+
/* User Status */
46+
47+
public int? userStatus { get; set; }
48+
49+
50+
51+
public override string ToString() {
52+
var sb = new StringBuilder();
53+
sb.Append("class user {\n");
54+
55+
sb.Append(" id: ").Append(id).Append("\n");
56+
57+
sb.Append(" username: ").Append(username).Append("\n");
58+
59+
sb.Append(" firstName: ").Append(firstName).Append("\n");
60+
61+
sb.Append(" lastName: ").Append(lastName).Append("\n");
62+
63+
sb.Append(" email: ").Append(email).Append("\n");
64+
65+
sb.Append(" password: ").Append(password).Append("\n");
66+
67+
sb.Append(" phone: ").Append(phone).Append("\n");
68+
69+
sb.Append(" userStatus: ").Append(userStatus).Append("\n");
70+
71+
sb.Append("}\n");
72+
return sb.ToString();
73+
}
74+
}
75+
76+
77+
}

0 commit comments

Comments
 (0)