Skip to content

Commit 816c18d

Browse files
committed
fixed open-api template generating unnecessary comment
This fix is about vendor extension scoping problem
1 parent ea7bc0b commit 816c18d

File tree

17 files changed

+46
-239
lines changed

17 files changed

+46
-239
lines changed

openapi-generator-template/reqwest/api.mustache

Lines changed: 22 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ use super::{Error, configuration, ContentType};
88
{{#operations}}
99
{{#operation}}
1010
{{#vendorExtensions.x-group-parameters}}
11-
{{^allParams}}
12-
/*
13-
{{/allParams}}
11+
{{#allParams}}
12+
{{#-first}}
1413
/// struct for passing parameters to the method [`{{operationId}}`]
1514
#[derive(Clone, Debug)]
16-
pub struct {{{operationIdCamelCase}}}Params{{{vendorExtensions.x-rust-params-generic-parameter}}} {
17-
{{#allParams}}
15+
pub struct {{{operationIdCamelCase}}}Params{{!
16+
Iterate through ALL parameters in the operation.
17+
Only the requestBody has this extension defined, so it will print "<B>".
18+
The other parameters have nothing, so they will print nothing.
19+
This effectively extract the generic parameter from the requestBody
20+
and places it on the struct definition line.
21+
}}{{#allParams}}
22+
{{{vendorExtensions.x-rust-params-generic-parameter}}}
23+
{{/allParams}} {
24+
{{/-first}}
1825
{{#description}}
1926
/// {{{.}}}
2027
{{/description}}
@@ -32,14 +39,15 @@ pub struct {{{operationIdCamelCase}}}Params{{{vendorExtensions.x-rust-params-gen
3239
### Models and primative types
3340
}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{!
3441
### Option End
35-
}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}},
42+
}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{!
43+
### Comma for next arguement
44+
}}{{^-last}},{{/-last}}
3645
{{/vendorExtensions.x-rust-type}}
37-
{{/allParams}}
46+
{{#-last}}
3847
}
39-
{{^allParams}}
40-
*/
41-
{{/allParams}}
4248

49+
{{/-last}}
50+
{{/allParams}}
4351
{{/vendorExtensions.x-group-parameters}}
4452
{{/operation}}
4553
{{/operations}}
@@ -97,51 +105,12 @@ pub enum {{{operationIdCamelCase}}}Error {
97105
/// {{{.}}}
98106
{{/notes}}
99107
{{#vendorExtensions.x-group-parameters}}
100-
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{{vendorExtensions.x-rust-generic-parameter}}}(configuration: &configuration::Configuration
101-
{{^allParams}}
102-
/*
103-
{{/allParams}}
104-
, params: &{{{operationIdCamelCase}}}Params{{{vendorExtensions.x-rust-params-generic-parameter}}}
105-
{{^allParams}}
106-
*/
107-
{{/allParams}}{{!
108+
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{{vendorExtensions.x-rust-generic-parameter}}}(configuration: &configuration::Configuration{{#allParams}}{{#-first}}, {{!
109+
### Params
110+
}}params: &{{{operationIdCamelCase}}}Params{{#allParams}}{{{vendorExtensions.x-rust-params-generic-parameter}}}{{/allParams}}{{/-first}}{{/allParams}}{{!
108111
### Function return type
109112
}}) -> Result<{{#vendorExtensions.x-rust-return-type}}{{{.}}}{{/vendorExtensions.x-rust-return-type}}{{^vendorExtensions.x-rust-return-type}}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{^isResponseFile}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}, Error<{{{operationIdCamelCase}}}Error>> {
110113
{{/vendorExtensions.x-group-parameters}}
111-
{{^vendorExtensions.x-group-parameters}}
112-
pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{{vendorExtensions.x-rust-generic-parameter}}}{{{vendorExtensions.x-rust-params-generic-parameter}}}(configuration: &configuration::Configuration, {{#allParams}}{{{paramName}}}: {{!
113-
### Option Start
114-
}}{{^required}}Option<{{/required}}{{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{!
115-
### &str and Vec<&str>
116-
}}{{#isString}}{{#isArray}}Vec<{{/isArray}}{{^isUuid}}&str{{/isUuid}}{{#isArray}}>{{/isArray}}{{/isString}}{{!
117-
### UUIDs
118-
}}{{#isUuid}}{{#isArray}}Vec<{{/isArray}}&str{{#isArray}}>{{/isArray}}{{/isUuid}}{{!
119-
### Models and primative types
120-
}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}models::{{/isContainer}}{{/isPrimitiveType}}{{{dataType}}}{{/isUuid}}{{/isString}}{{!
121-
### Option End
122-
}}{{^required}}>{{/required}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{!
123-
### Comma for next arguement
124-
}}{{^-last}}, {{/-last}}{{/allParams}}{{!
125-
### Function return type
126-
}}) -> Result<{{#vendorExtensions.x-rust-return-type}}{{{vendorExtensions.x-rust-return-type}}}{{/vendorExtensions.x-rust-return-type}}{{^vendorExtensions.x-rust-return-type}}{{!
127-
### Response File Support
128-
}}{{#isResponseFile}}{{#supportAsync}}reqwest::Response{{/supportAsync}}{{^supportAsync}}reqwest::blocking::Response{{/supportAsync}}{{/isResponseFile}}{{!
129-
### Regular Responses
130-
}}{{^isResponseFile}}{{!
131-
### Multi response support
132-
}}{{#supportMultipleResponses}}ResponseContent<{{{operationIdCamelCase}}}Success>{{/supportMultipleResponses}}{{!
133-
### Regular return type
134-
}}{{^supportMultipleResponses}}{{^returnType}}(){{/returnType}}{{{returnType}}}{{{vendorExtensions.x-rust-return-type-generic-parameter}}}{{/supportMultipleResponses}}{{/isResponseFile}}{{/vendorExtensions.x-rust-return-type}}{{!
135-
### Error Type
136-
}}, Error<{{{operationIdCamelCase}}}Error>> {
137-
{{#allParams.0}}
138-
// add a prefix to parameters to efficiently prevent name collisions
139-
{{/allParams.0}}
140-
{{#allParams}}
141-
let {{{vendorExtensions.x-rust-param-identifier}}} = {{{paramName}}};
142-
{{/allParams}}
143-
{{/vendorExtensions.x-group-parameters}}
144-
145114
let uri_str = format!("{}{{{path}}}", configuration.base_path{{#pathParams}}, {{{baseName}}}={{#isString}}crate::apis::urlencode(&{{/isString}}{{{vendorExtensions.x-rust-param-identifier}}}{{^required}}.unwrap(){{/required}}{{#required}}{{#isNullable}}.unwrap(){{/isNullable}}{{/required}}{{#isArray}}.join(",").as_ref(){{/isArray}}{{^isString}}{{^isUuid}}{{^isPrimitiveType}}{{^isContainer}}.to_string(){{/isContainer}}{{/isPrimitiveType}}{{/isUuid}}{{/isString}}{{#isString}}){{/isString}}{{/pathParams}});
146115
let mut req_builder = configuration.client.request(reqwest::Method::{{{httpMethod}}}, &uri_str);
147116

@@ -523,4 +492,4 @@ pub {{#supportAsync}}async {{/supportAsync}}fn {{{operationId}}}{{{vendorExtensi
523492
}
524493

525494
{{/operation}}
526-
{{/operations}}
495+
{{/operations}}

preprocessed_openapi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,9 @@ paths:
348348
description: Can be any key-value pair
349349
x-go-type: interface{}
350350
required: true
351+
x-rust-params-generic-parameter: <B>
351352
x-rust-type: B
352353
x-rust-generic-parameter: '<B: Serialize>'
353-
x-rust-params-generic-parameter: <B>
354354
delete:
355355
tags:
356356
- documents
@@ -1256,6 +1256,7 @@ paths:
12561256
description: Can be any key-value pair
12571257
x-go-type: interface{}
12581258
required: true
1259+
x-rust-params-generic-parameter: <B>
12591260
x-rust-type: B
12601261
responses:
12611262
'200':
@@ -1272,7 +1273,6 @@ paths:
12721273
schema:
12731274
$ref: '#/components/schemas/ApiResponse'
12741275
x-rust-generic-parameter: '<B: Serialize>'
1275-
x-rust-params-generic-parameter: <B>
12761276
delete:
12771277
tags:
12781278
- documents

typesense/src/client/collection/document.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ where
5151

5252
let result_value = execute_wrapper!(self, documents_api::get_document, params)?;
5353

54-
// Deserialize the raw JSON value into the user's type T.
54+
// Deserialize the raw JSON value into the user's type D.
5555
serde_json::from_value(result_value).map_err(Error::from)
5656
}
5757

typesense_codegen/src/apis/analytics_api.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ pub struct DeleteAnalyticsRuleParams {
3434
pub rule_name: String,
3535
}
3636

37-
/*
38-
/// struct for passing parameters to the method [`flush_analytics`]
39-
#[derive(Clone, Debug)]
40-
pub struct FlushAnalyticsParams {
41-
}
42-
*/
43-
4437
/// struct for passing parameters to the method [`get_analytics_events`]
4538
#[derive(Clone, Debug)]
4639
pub struct GetAnalyticsEventsParams {
@@ -51,13 +44,6 @@ pub struct GetAnalyticsEventsParams {
5144
pub n: i32,
5245
}
5346

54-
/*
55-
/// struct for passing parameters to the method [`get_analytics_status`]
56-
#[derive(Clone, Debug)]
57-
pub struct GetAnalyticsStatusParams {
58-
}
59-
*/
60-
6147
/// struct for passing parameters to the method [`retrieve_analytics_rule`]
6248
#[derive(Clone, Debug)]
6349
pub struct RetrieveAnalyticsRuleParams {
@@ -335,9 +321,7 @@ pub async fn delete_analytics_rule(
335321

336322
/// Triggers a flush of analytics data to persistent storage.
337323
pub async fn flush_analytics(
338-
configuration: &configuration::Configuration, /*
339-
, params: &FlushAnalyticsParams
340-
*/
324+
configuration: &configuration::Configuration,
341325
) -> Result<models::AnalyticsEventCreateResponse, Error<FlushAnalyticsError>> {
342326
let uri_str = format!("{}/analytics/flush", configuration.base_path);
343327
let mut req_builder = configuration
@@ -455,9 +439,7 @@ pub async fn get_analytics_events(
455439

456440
/// Returns sizes of internal analytics buffers and queues.
457441
pub async fn get_analytics_status(
458-
configuration: &configuration::Configuration, /*
459-
, params: &GetAnalyticsStatusParams
460-
*/
442+
configuration: &configuration::Configuration,
461443
) -> Result<models::AnalyticsStatus, Error<GetAnalyticsStatusError>> {
462444
let uri_str = format!("{}/analytics/status", configuration.base_path);
463445
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

typesense_codegen/src/apis/collections_api.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ pub struct GetAliasParams {
4141
pub alias_name: String,
4242
}
4343

44-
/*
45-
/// struct for passing parameters to the method [`get_aliases`]
46-
#[derive(Clone, Debug)]
47-
pub struct GetAliasesParams {
48-
}
49-
*/
50-
5144
/// struct for passing parameters to the method [`get_collection`]
5245
#[derive(Clone, Debug)]
5346
pub struct GetCollectionParams {
@@ -402,9 +395,7 @@ pub async fn get_alias(
402395

403396
/// List all aliases and the corresponding collections that they map to.
404397
pub async fn get_aliases(
405-
configuration: &configuration::Configuration, /*
406-
, params: &GetAliasesParams
407-
*/
398+
configuration: &configuration::Configuration,
408399
) -> Result<models::CollectionAliasesResponse, Error<GetAliasesError>> {
409400
let uri_str = format!("{}/aliases", configuration.base_path);
410401
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

typesense_codegen/src/apis/conversations_api.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ pub struct DeleteConversationModelParams {
2626
pub model_id: String,
2727
}
2828

29-
/*
30-
/// struct for passing parameters to the method [`retrieve_all_conversation_models`]
31-
#[derive(Clone, Debug)]
32-
pub struct RetrieveAllConversationModelsParams {
33-
}
34-
*/
35-
3629
/// struct for passing parameters to the method [`retrieve_conversation_model`]
3730
#[derive(Clone, Debug)]
3831
pub struct RetrieveConversationModelParams {
@@ -209,9 +202,7 @@ pub async fn delete_conversation_model(
209202

210203
/// Retrieve all conversation models
211204
pub async fn retrieve_all_conversation_models(
212-
configuration: &configuration::Configuration, /*
213-
, params: &RetrieveAllConversationModelsParams
214-
*/
205+
configuration: &configuration::Configuration,
215206
) -> Result<Vec<models::ConversationModelSchema>, Error<RetrieveAllConversationModelsError>> {
216207
let uri_str = format!("{}/conversations/models", configuration.base_path);
217208
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

typesense_codegen/src/apis/debug_api.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ use crate::{apis::ResponseContent, models};
1313
use reqwest;
1414
use serde::{Deserialize, Serialize, de::Error as _};
1515

16-
/*
17-
/// struct for passing parameters to the method [`debug`]
18-
#[derive(Clone, Debug)]
19-
pub struct DebugParams {
20-
}
21-
*/
22-
2316
/// struct for typed errors of method [`debug`]
2417
#[derive(Debug, Clone, Serialize, Deserialize)]
2518
#[serde(untagged)]
@@ -29,9 +22,7 @@ pub enum DebugError {
2922

3023
/// Print debugging information
3124
pub async fn debug(
32-
configuration: &configuration::Configuration, /*
33-
, params: &DebugParams
34-
*/
25+
configuration: &configuration::Configuration,
3526
) -> Result<models::Debug200Response, Error<DebugError>> {
3627
let uri_str = format!("{}/debug", configuration.base_path);
3728
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

typesense_codegen/src/apis/health_api.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ use crate::{apis::ResponseContent, models};
1313
use reqwest;
1414
use serde::{Deserialize, Serialize, de::Error as _};
1515

16-
/*
17-
/// struct for passing parameters to the method [`health`]
18-
#[derive(Clone, Debug)]
19-
pub struct HealthParams {
20-
}
21-
*/
22-
2316
/// struct for typed errors of method [`health`]
2417
#[derive(Debug, Clone, Serialize, Deserialize)]
2518
#[serde(untagged)]
@@ -29,9 +22,7 @@ pub enum HealthError {
2922

3023
/// Checks if Typesense server is ready to accept requests.
3124
pub async fn health(
32-
configuration: &configuration::Configuration, /*
33-
, params: &HealthParams
34-
*/
25+
configuration: &configuration::Configuration,
3526
) -> Result<models::HealthStatus, Error<HealthError>> {
3627
let uri_str = format!("{}/health", configuration.base_path);
3728
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

typesense_codegen/src/apis/keys_api.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ pub struct GetKeyParams {
3434
pub key_id: i64,
3535
}
3636

37-
/*
38-
/// struct for passing parameters to the method [`get_keys`]
39-
#[derive(Clone, Debug)]
40-
pub struct GetKeysParams {
41-
}
42-
*/
43-
4437
/// struct for typed errors of method [`create_key`]
4538
#[derive(Debug, Clone, Serialize, Deserialize)]
4639
#[serde(untagged)]
@@ -258,9 +251,7 @@ pub async fn get_key(
258251
}
259252

260253
pub async fn get_keys(
261-
configuration: &configuration::Configuration, /*
262-
, params: &GetKeysParams
263-
*/
254+
configuration: &configuration::Configuration,
264255
) -> Result<models::ApiKeysResponse, Error<GetKeysError>> {
265256
let uri_str = format!("{}/keys", configuration.base_path);
266257
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

typesense_codegen/src/apis/nl_search_models_api.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@ pub struct DeleteNlSearchModelParams {
2727
pub model_id: String,
2828
}
2929

30-
/*
31-
/// struct for passing parameters to the method [`retrieve_all_nl_search_models`]
32-
#[derive(Clone, Debug)]
33-
pub struct RetrieveAllNlSearchModelsParams {
34-
}
35-
*/
36-
3730
/// struct for passing parameters to the method [`retrieve_nl_search_model`]
3831
#[derive(Clone, Debug)]
3932
pub struct RetrieveNlSearchModelParams {
@@ -215,9 +208,7 @@ pub async fn delete_nl_search_model(
215208

216209
/// Retrieve all NL search models.
217210
pub async fn retrieve_all_nl_search_models(
218-
configuration: &configuration::Configuration, /*
219-
, params: &RetrieveAllNlSearchModelsParams
220-
*/
211+
configuration: &configuration::Configuration,
221212
) -> Result<Vec<models::NlSearchModelSchema>, Error<RetrieveAllNlSearchModelsError>> {
222213
let uri_str = format!("{}/nl_search_models", configuration.base_path);
223214
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);

0 commit comments

Comments
 (0)