forked from loafle/openapi-generator-original
Override escape reserved word in abstract rust (#17440)
* override escape reserved word in abstract rust * add tests for ref, improve verion lambda * add files
This commit is contained in:
parent
b7ea139f77
commit
191dc1a6ba
@ -436,4 +436,12 @@ public abstract class AbstractRustCodegen extends DefaultCodegen implements Code
|
||||
public String addRegularExpressionDelimiter(String pattern) {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "r#"+ name;
|
||||
}
|
||||
}
|
||||
|
@ -392,6 +392,13 @@ public class RustClientCodegen extends AbstractRustCodegen implements CodegenCon
|
||||
// remove v or V
|
||||
content = content.trim().replace("v", "");
|
||||
content = content.replace("V", "");
|
||||
|
||||
// convert 5.2 to 5.2.0 for example
|
||||
String[] contents = content.split("[.]");
|
||||
if (contents.length == 2) {
|
||||
content += ".0";
|
||||
}
|
||||
|
||||
writer.write(content);
|
||||
}
|
||||
});
|
||||
|
@ -955,3 +955,9 @@ components:
|
||||
nullable: true
|
||||
just_string:
|
||||
type: string
|
||||
ref:
|
||||
description: using reserved word as model name
|
||||
type: object
|
||||
properties:
|
||||
dummy:
|
||||
type: string
|
||||
|
@ -15,6 +15,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PropertyTest.md
|
||||
docs/Ref.md
|
||||
docs/Return.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
@ -41,6 +42,7 @@ src/models/baz.rs
|
||||
src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_ref.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
|
@ -64,6 +64,7 @@ Class | Method | HTTP request | Description
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PropertyTest](docs/PropertyTest.md)
|
||||
- [Ref](docs/Ref.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
|
11
samples/client/petstore/rust/hyper/petstore/docs/Ref.md
Normal file
11
samples/client/petstore/rust/hyper/petstore/docs/Ref.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Ref
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | Option<**String**> | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod property_test;
|
||||
pub use self::property_test::PropertyTest;
|
||||
pub mod model_ref;
|
||||
pub use self::model_ref::Ref;
|
||||
pub mod model_return;
|
||||
pub use self::model_return::Return;
|
||||
pub mod tag;
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use crate::models;
|
||||
|
||||
/// Ref : using reserved word as model name
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Ref {
|
||||
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
|
||||
pub dummy: Option<String>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
/// using reserved word as model name
|
||||
pub fn new() -> Ref {
|
||||
Ref {
|
||||
dummy: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PropertyTest.md
|
||||
docs/Ref.md
|
||||
docs/Return.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
@ -39,6 +40,7 @@ src/models/baz.rs
|
||||
src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_ref.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
|
@ -64,6 +64,7 @@ Class | Method | HTTP request | Description
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PropertyTest](docs/PropertyTest.md)
|
||||
- [Ref](docs/Ref.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Ref
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | Option<**String**> | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod property_test;
|
||||
pub use self::property_test::PropertyTest;
|
||||
pub mod model_ref;
|
||||
pub use self::model_ref::Ref;
|
||||
pub mod model_return;
|
||||
pub use self::model_return::Return;
|
||||
pub mod tag;
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use crate::models;
|
||||
|
||||
/// Ref : using reserved word as model name
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Ref {
|
||||
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
|
||||
pub dummy: Option<String>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
/// using reserved word as model name
|
||||
pub fn new() -> Ref {
|
||||
Ref {
|
||||
dummy: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PropertyTest.md
|
||||
docs/Ref.md
|
||||
docs/Return.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
@ -39,6 +40,7 @@ src/models/baz.rs
|
||||
src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_ref.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
|
@ -64,6 +64,7 @@ Class | Method | HTTP request | Description
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PropertyTest](docs/PropertyTest.md)
|
||||
- [Ref](docs/Ref.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Ref
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | Option<**String**> | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod property_test;
|
||||
pub use self::property_test::PropertyTest;
|
||||
pub mod model_ref;
|
||||
pub use self::model_ref::Ref;
|
||||
pub mod model_return;
|
||||
pub use self::model_return::Return;
|
||||
pub mod tag;
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use crate::models;
|
||||
|
||||
/// Ref : using reserved word as model name
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Ref {
|
||||
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
|
||||
pub dummy: Option<String>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
/// using reserved word as model name
|
||||
pub fn new() -> Ref {
|
||||
Ref {
|
||||
dummy: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PropertyTest.md
|
||||
docs/Ref.md
|
||||
docs/Return.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
@ -39,6 +40,7 @@ src/models/baz.rs
|
||||
src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_ref.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
|
@ -64,6 +64,7 @@ Class | Method | HTTP request | Description
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PropertyTest](docs/PropertyTest.md)
|
||||
- [Ref](docs/Ref.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Ref
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | Option<**String**> | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod property_test;
|
||||
pub use self::property_test::PropertyTest;
|
||||
pub mod model_ref;
|
||||
pub use self::model_ref::Ref;
|
||||
pub mod model_return;
|
||||
pub use self::model_return::Return;
|
||||
pub mod tag;
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use crate::models;
|
||||
|
||||
/// Ref : using reserved word as model name
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Ref {
|
||||
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
|
||||
pub dummy: Option<String>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
/// using reserved word as model name
|
||||
pub fn new() -> Ref {
|
||||
Ref {
|
||||
dummy: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PropertyTest.md
|
||||
docs/Ref.md
|
||||
docs/Return.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
@ -39,6 +40,7 @@ src/models/baz.rs
|
||||
src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_ref.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
|
@ -64,6 +64,7 @@ Class | Method | HTTP request | Description
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PropertyTest](docs/PropertyTest.md)
|
||||
- [Ref](docs/Ref.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Ref
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | Option<**String**> | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod property_test;
|
||||
pub use self::property_test::PropertyTest;
|
||||
pub mod model_ref;
|
||||
pub use self::model_ref::Ref;
|
||||
pub mod model_return;
|
||||
pub use self::model_return::Return;
|
||||
pub mod tag;
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use crate::models;
|
||||
|
||||
/// Ref : using reserved word as model name
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Ref {
|
||||
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
|
||||
pub dummy: Option<String>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
/// using reserved word as model name
|
||||
pub fn new() -> Ref {
|
||||
Ref {
|
||||
dummy: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ docs/Order.md
|
||||
docs/Pet.md
|
||||
docs/PetApi.md
|
||||
docs/PropertyTest.md
|
||||
docs/Ref.md
|
||||
docs/Return.md
|
||||
docs/StoreApi.md
|
||||
docs/Tag.md
|
||||
@ -39,6 +40,7 @@ src/models/baz.rs
|
||||
src/models/category.rs
|
||||
src/models/enum_array_testing.rs
|
||||
src/models/mod.rs
|
||||
src/models/model_ref.rs
|
||||
src/models/model_return.rs
|
||||
src/models/nullable_array.rs
|
||||
src/models/optional_testing.rs
|
||||
|
@ -64,6 +64,7 @@ Class | Method | HTTP request | Description
|
||||
- [Order](docs/Order.md)
|
||||
- [Pet](docs/Pet.md)
|
||||
- [PropertyTest](docs/PropertyTest.md)
|
||||
- [Ref](docs/Ref.md)
|
||||
- [Return](docs/Return.md)
|
||||
- [Tag](docs/Tag.md)
|
||||
- [TypeTesting](docs/TypeTesting.md)
|
||||
|
11
samples/client/petstore/rust/reqwest/petstore/docs/Ref.md
Normal file
11
samples/client/petstore/rust/reqwest/petstore/docs/Ref.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Ref
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | Option<**String**> | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
|
@ -20,6 +20,8 @@ pub mod pet;
|
||||
pub use self::pet::Pet;
|
||||
pub mod property_test;
|
||||
pub use self::property_test::PropertyTest;
|
||||
pub mod model_ref;
|
||||
pub use self::model_ref::Ref;
|
||||
pub mod model_return;
|
||||
pub use self::model_return::Return;
|
||||
pub mod tag;
|
||||
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
* Generated by: https://openapi-generator.tech
|
||||
*/
|
||||
|
||||
use crate::models;
|
||||
|
||||
/// Ref : using reserved word as model name
|
||||
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Ref {
|
||||
#[serde(rename = "dummy", skip_serializing_if = "Option::is_none")]
|
||||
pub dummy: Option<String>,
|
||||
}
|
||||
|
||||
impl Ref {
|
||||
/// using reserved word as model name
|
||||
pub fn new() -> Ref {
|
||||
Ref {
|
||||
dummy: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user