Skip to content

Commit 4478f42

Browse files
authored
[Rust Server] Generate valid Rustdocs for lazy_static items (#3556)
Generate valid Rustdocs for lazy_static items and update samples
1 parent 9e659d1 commit 4478f42

5 files changed

Lines changed: 106 additions & 53 deletions

File tree

modules/openapi-generator/src/main/resources/rust-server/mimetypes.mustache

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@ pub mod responses {
44
use hyper::mime::*;
55
66
// The macro is called per-operation to beat the recursion limit
7-
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#responses}}{{#produces}}{{#-first}}{{#dataType}} /// Create Mime objects for the response content types for {{{operationId}}}
7+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#responses}}{{#produces}}{{#-first}}{{#dataType}}
88
lazy_static! {
9+
/// Create Mime objects for the response content types for {{{operationId}}}
910
pub static ref {{#vendorExtensions}}{{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}{{/vendorExtensions}}: Mime = "{{{mediaType}}}".parse().unwrap();
1011
}
1112
{{/dataType}}{{/-first}}{{/produces}}{{/responses}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
1213
}
1314

1415
pub mod requests {
1516
use hyper::mime::*;
16-
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#bodyParam}} /// Create Mime objects for the request content types for {{{operationId}}}
17+
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#bodyParam}}
1718
lazy_static! {
19+
/// Create Mime objects for the request content types for {{{operationId}}}
1820
pub static ref {{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}}: Mime = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/json{{/consumes}}".parse().unwrap();
1921
}
20-
{{/bodyParam}}{{^bodyParam}}{{#vendorExtensions}}{{#formParams}}{{#-first}} /// Create Mime objects for the request content types for {{{operationId}}}
22+
{{/bodyParam}}{{^bodyParam}}{{#vendorExtensions}}{{#formParams}}{{#-first}}
2123
lazy_static! {
24+
/// Create Mime objects for the request content types for {{{operationId}}}
2225
pub static ref {{#vendorExtensions}}{{{uppercase_operation_id}}}{{/vendorExtensions}}: Mime = "{{#consumes}}{{#-first}}{{{mediaType}}}{{/-first}}{{/consumes}}{{^consumes}}application/x-www-form-urlencoded{{/consumes}}".parse().unwrap();
2326
}
2427
{{/-first}}{{/formParams}}{{/vendorExtensions}}{{/bodyParam}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}

samples/server/petstore/rust-server/output/multipart-v3/src/mimetypes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ pub mod responses {
99

1010
pub mod requests {
1111
use hyper::mime::*;
12-
/// Create Mime objects for the request content types for MultipartRequestPost
12+
1313
lazy_static! {
14+
/// Create Mime objects for the request content types for MultipartRequestPost
1415
pub static ref MULTIPART_REQUEST_POST: Mime = "multipart/form-data".parse().unwrap();
1516
}
1617

samples/server/petstore/rust-server/output/openapi-v3/src/mimetypes.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,44 @@ pub mod responses {
44
use hyper::mime::*;
55

66
// The macro is called per-operation to beat the recursion limit
7-
/// Create Mime objects for the response content types for UuidGet
7+
88
lazy_static! {
9+
/// Create Mime objects for the response content types for UuidGet
910
pub static ref UUID_GET_DUPLICATE_RESPONSE_LONG_TEXT: Mime = "application/json".parse().unwrap();
1011
}
1112

1213
}
1314

1415
pub mod requests {
1516
use hyper::mime::*;
16-
/// Create Mime objects for the request content types for RequiredOctetStreamPut
17+
1718
lazy_static! {
19+
/// Create Mime objects for the request content types for RequiredOctetStreamPut
1820
pub static ref REQUIRED_OCTET_STREAM_PUT: Mime = "application/octet-stream".parse().unwrap();
1921
}
20-
/// Create Mime objects for the request content types for XmlExtraPost
22+
2123
lazy_static! {
24+
/// Create Mime objects for the request content types for XmlExtraPost
2225
pub static ref XML_EXTRA_POST: Mime = "application/xml".parse().unwrap();
2326
}
24-
/// Create Mime objects for the request content types for XmlOtherPost
27+
2528
lazy_static! {
29+
/// Create Mime objects for the request content types for XmlOtherPost
2630
pub static ref XML_OTHER_POST: Mime = "application/xml".parse().unwrap();
2731
}
28-
/// Create Mime objects for the request content types for XmlOtherPut
32+
2933
lazy_static! {
34+
/// Create Mime objects for the request content types for XmlOtherPut
3035
pub static ref XML_OTHER_PUT: Mime = "application/xml".parse().unwrap();
3136
}
32-
/// Create Mime objects for the request content types for XmlPost
37+
3338
lazy_static! {
39+
/// Create Mime objects for the request content types for XmlPost
3440
pub static ref XML_POST: Mime = "application/xml".parse().unwrap();
3541
}
36-
/// Create Mime objects for the request content types for XmlPut
42+
3743
lazy_static! {
44+
/// Create Mime objects for the request content types for XmlPut
3845
pub static ref XML_PUT: Mime = "application/xml".parse().unwrap();
3946
}
4047

samples/server/petstore/rust-server/output/petstore-with-fake-endpoints-models-for-testing/src/mimetypes.rs

Lines changed: 74 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,157 +4,194 @@ pub mod responses {
44
use hyper::mime::*;
55

66
// The macro is called per-operation to beat the recursion limit
7-
/// Create Mime objects for the response content types for TestSpecialTags
7+
88
lazy_static! {
9+
/// Create Mime objects for the response content types for TestSpecialTags
910
pub static ref TEST_SPECIAL_TAGS_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
1011
}
11-
/// Create Mime objects for the response content types for FakeOuterBooleanSerialize
12+
1213
lazy_static! {
14+
/// Create Mime objects for the response content types for FakeOuterBooleanSerialize
1315
pub static ref FAKE_OUTER_BOOLEAN_SERIALIZE_OUTPUT_BOOLEAN: Mime = "*/*".parse().unwrap();
1416
}
15-
/// Create Mime objects for the response content types for FakeOuterCompositeSerialize
17+
1618
lazy_static! {
19+
/// Create Mime objects for the response content types for FakeOuterCompositeSerialize
1720
pub static ref FAKE_OUTER_COMPOSITE_SERIALIZE_OUTPUT_COMPOSITE: Mime = "*/*".parse().unwrap();
1821
}
19-
/// Create Mime objects for the response content types for FakeOuterNumberSerialize
22+
2023
lazy_static! {
24+
/// Create Mime objects for the response content types for FakeOuterNumberSerialize
2125
pub static ref FAKE_OUTER_NUMBER_SERIALIZE_OUTPUT_NUMBER: Mime = "*/*".parse().unwrap();
2226
}
23-
/// Create Mime objects for the response content types for FakeOuterStringSerialize
27+
2428
lazy_static! {
29+
/// Create Mime objects for the response content types for FakeOuterStringSerialize
2530
pub static ref FAKE_OUTER_STRING_SERIALIZE_OUTPUT_STRING: Mime = "*/*".parse().unwrap();
2631
}
27-
/// Create Mime objects for the response content types for TestClientModel
32+
2833
lazy_static! {
34+
/// Create Mime objects for the response content types for TestClientModel
2935
pub static ref TEST_CLIENT_MODEL_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
3036
}
31-
/// Create Mime objects for the response content types for TestClassname
37+
3238
lazy_static! {
39+
/// Create Mime objects for the response content types for TestClassname
3340
pub static ref TEST_CLASSNAME_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
3441
}
35-
/// Create Mime objects for the response content types for FindPetsByStatus
42+
3643
lazy_static! {
44+
/// Create Mime objects for the response content types for FindPetsByStatus
3745
pub static ref FIND_PETS_BY_STATUS_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
3846
}
39-
/// Create Mime objects for the response content types for FindPetsByTags
47+
4048
lazy_static! {
49+
/// Create Mime objects for the response content types for FindPetsByTags
4150
pub static ref FIND_PETS_BY_TAGS_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
4251
}
43-
/// Create Mime objects for the response content types for GetPetById
52+
4453
lazy_static! {
54+
/// Create Mime objects for the response content types for GetPetById
4555
pub static ref GET_PET_BY_ID_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
4656
}
47-
/// Create Mime objects for the response content types for UploadFile
57+
4858
lazy_static! {
59+
/// Create Mime objects for the response content types for UploadFile
4960
pub static ref UPLOAD_FILE_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
5061
}
51-
/// Create Mime objects for the response content types for GetInventory
62+
5263
lazy_static! {
64+
/// Create Mime objects for the response content types for GetInventory
5365
pub static ref GET_INVENTORY_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
5466
}
55-
/// Create Mime objects for the response content types for GetOrderById
67+
5668
lazy_static! {
69+
/// Create Mime objects for the response content types for GetOrderById
5770
pub static ref GET_ORDER_BY_ID_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
5871
}
59-
/// Create Mime objects for the response content types for PlaceOrder
72+
6073
lazy_static! {
74+
/// Create Mime objects for the response content types for PlaceOrder
6175
pub static ref PLACE_ORDER_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
6276
}
63-
/// Create Mime objects for the response content types for GetUserByName
77+
6478
lazy_static! {
79+
/// Create Mime objects for the response content types for GetUserByName
6580
pub static ref GET_USER_BY_NAME_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
6681
}
67-
/// Create Mime objects for the response content types for LoginUser
82+
6883
lazy_static! {
84+
/// Create Mime objects for the response content types for LoginUser
6985
pub static ref LOGIN_USER_SUCCESSFUL_OPERATION: Mime = "application/json".parse().unwrap();
7086
}
7187

7288
}
7389

7490
pub mod requests {
7591
use hyper::mime::*;
76-
/// Create Mime objects for the request content types for TestSpecialTags
92+
7793
lazy_static! {
94+
/// Create Mime objects for the request content types for TestSpecialTags
7895
pub static ref TEST_SPECIAL_TAGS: Mime = "application/json".parse().unwrap();
7996
}
80-
/// Create Mime objects for the request content types for FakeOuterBooleanSerialize
97+
8198
lazy_static! {
99+
/// Create Mime objects for the request content types for FakeOuterBooleanSerialize
82100
pub static ref FAKE_OUTER_BOOLEAN_SERIALIZE: Mime = "application/json".parse().unwrap();
83101
}
84-
/// Create Mime objects for the request content types for FakeOuterCompositeSerialize
102+
85103
lazy_static! {
104+
/// Create Mime objects for the request content types for FakeOuterCompositeSerialize
86105
pub static ref FAKE_OUTER_COMPOSITE_SERIALIZE: Mime = "application/json".parse().unwrap();
87106
}
88-
/// Create Mime objects for the request content types for FakeOuterNumberSerialize
107+
89108
lazy_static! {
109+
/// Create Mime objects for the request content types for FakeOuterNumberSerialize
90110
pub static ref FAKE_OUTER_NUMBER_SERIALIZE: Mime = "application/json".parse().unwrap();
91111
}
92-
/// Create Mime objects for the request content types for FakeOuterStringSerialize
112+
93113
lazy_static! {
114+
/// Create Mime objects for the request content types for FakeOuterStringSerialize
94115
pub static ref FAKE_OUTER_STRING_SERIALIZE: Mime = "application/json".parse().unwrap();
95116
}
96-
/// Create Mime objects for the request content types for TestBodyWithQueryParams
117+
97118
lazy_static! {
119+
/// Create Mime objects for the request content types for TestBodyWithQueryParams
98120
pub static ref TEST_BODY_WITH_QUERY_PARAMS: Mime = "application/json".parse().unwrap();
99121
}
100-
/// Create Mime objects for the request content types for TestClientModel
122+
101123
lazy_static! {
124+
/// Create Mime objects for the request content types for TestClientModel
102125
pub static ref TEST_CLIENT_MODEL: Mime = "application/json".parse().unwrap();
103126
}
104-
/// Create Mime objects for the request content types for TestEndpointParameters
127+
105128
lazy_static! {
129+
/// Create Mime objects for the request content types for TestEndpointParameters
106130
pub static ref TEST_ENDPOINT_PARAMETERS: Mime = "application/x-www-form-urlencoded".parse().unwrap();
107131
}
108-
/// Create Mime objects for the request content types for TestEnumParameters
132+
109133
lazy_static! {
134+
/// Create Mime objects for the request content types for TestEnumParameters
110135
pub static ref TEST_ENUM_PARAMETERS: Mime = "application/x-www-form-urlencoded".parse().unwrap();
111136
}
112-
/// Create Mime objects for the request content types for TestInlineAdditionalProperties
137+
113138
lazy_static! {
139+
/// Create Mime objects for the request content types for TestInlineAdditionalProperties
114140
pub static ref TEST_INLINE_ADDITIONAL_PROPERTIES: Mime = "application/json".parse().unwrap();
115141
}
116-
/// Create Mime objects for the request content types for TestJsonFormData
142+
117143
lazy_static! {
144+
/// Create Mime objects for the request content types for TestJsonFormData
118145
pub static ref TEST_JSON_FORM_DATA: Mime = "application/x-www-form-urlencoded".parse().unwrap();
119146
}
120-
/// Create Mime objects for the request content types for TestClassname
147+
121148
lazy_static! {
149+
/// Create Mime objects for the request content types for TestClassname
122150
pub static ref TEST_CLASSNAME: Mime = "application/json".parse().unwrap();
123151
}
124-
/// Create Mime objects for the request content types for AddPet
152+
125153
lazy_static! {
154+
/// Create Mime objects for the request content types for AddPet
126155
pub static ref ADD_PET: Mime = "application/json".parse().unwrap();
127156
}
128-
/// Create Mime objects for the request content types for UpdatePet
157+
129158
lazy_static! {
159+
/// Create Mime objects for the request content types for UpdatePet
130160
pub static ref UPDATE_PET: Mime = "application/json".parse().unwrap();
131161
}
132-
/// Create Mime objects for the request content types for UpdatePetWithForm
162+
133163
lazy_static! {
164+
/// Create Mime objects for the request content types for UpdatePetWithForm
134165
pub static ref UPDATE_PET_WITH_FORM: Mime = "application/x-www-form-urlencoded".parse().unwrap();
135166
}
136-
/// Create Mime objects for the request content types for UploadFile
167+
137168
lazy_static! {
169+
/// Create Mime objects for the request content types for UploadFile
138170
pub static ref UPLOAD_FILE: Mime = "multipart/form-data".parse().unwrap();
139171
}
140-
/// Create Mime objects for the request content types for PlaceOrder
172+
141173
lazy_static! {
174+
/// Create Mime objects for the request content types for PlaceOrder
142175
pub static ref PLACE_ORDER: Mime = "application/json".parse().unwrap();
143176
}
144-
/// Create Mime objects for the request content types for CreateUser
177+
145178
lazy_static! {
179+
/// Create Mime objects for the request content types for CreateUser
146180
pub static ref CREATE_USER: Mime = "application/json".parse().unwrap();
147181
}
148-
/// Create Mime objects for the request content types for CreateUsersWithArrayInput
182+
149183
lazy_static! {
184+
/// Create Mime objects for the request content types for CreateUsersWithArrayInput
150185
pub static ref CREATE_USERS_WITH_ARRAY_INPUT: Mime = "application/json".parse().unwrap();
151186
}
152-
/// Create Mime objects for the request content types for CreateUsersWithListInput
187+
153188
lazy_static! {
189+
/// Create Mime objects for the request content types for CreateUsersWithListInput
154190
pub static ref CREATE_USERS_WITH_LIST_INPUT: Mime = "application/json".parse().unwrap();
155191
}
156-
/// Create Mime objects for the request content types for UpdateUser
192+
157193
lazy_static! {
194+
/// Create Mime objects for the request content types for UpdateUser
158195
pub static ref UPDATE_USER: Mime = "application/json".parse().unwrap();
159196
}
160197

samples/server/petstore/rust-server/output/rust-server-test/src/mimetypes.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,34 @@ pub mod responses {
44
use hyper::mime::*;
55

66
// The macro is called per-operation to beat the recursion limit
7-
/// Create Mime objects for the response content types for FileResponseGet
7+
88
lazy_static! {
9+
/// Create Mime objects for the response content types for FileResponseGet
910
pub static ref FILE_RESPONSE_GET_SUCCESS: Mime = "application/json".parse().unwrap();
1011
}
11-
/// Create Mime objects for the response content types for HtmlPost
12+
1213
lazy_static! {
14+
/// Create Mime objects for the response content types for HtmlPost
1315
pub static ref HTML_POST_SUCCESS: Mime = "text/html".parse().unwrap();
1416
}
15-
/// Create Mime objects for the response content types for RawJsonGet
17+
1618
lazy_static! {
19+
/// Create Mime objects for the response content types for RawJsonGet
1720
pub static ref RAW_JSON_GET_SUCCESS: Mime = "*/*".parse().unwrap();
1821
}
1922

2023
}
2124

2225
pub mod requests {
2326
use hyper::mime::*;
24-
/// Create Mime objects for the request content types for DummyPut
27+
2528
lazy_static! {
29+
/// Create Mime objects for the request content types for DummyPut
2630
pub static ref DUMMY_PUT: Mime = "application/json".parse().unwrap();
2731
}
28-
/// Create Mime objects for the request content types for HtmlPost
32+
2933
lazy_static! {
34+
/// Create Mime objects for the request content types for HtmlPost
3035
pub static ref HTML_POST: Mime = "text/html".parse().unwrap();
3136
}
3237

0 commit comments

Comments
 (0)