Skip to content

Commit 51979e9

Browse files
committed
Allow hyphen
1 parent a2f3cb6 commit 51979e9

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

.generator/src/generator/templates/api.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use flate2::{write::{GzEncoder, ZlibEncoder}, Compression};
2020
{%- endif %}
2121
{%- endfor %}
2222

23-
{%- set structName = name.replace(" ", "")+"API" %}
23+
{%- set structName = name.replace(" ", "").replace("-", "")+"API" %}
2424
{% for path, method, operation in operations|sort(attribute="2.operationId", case_sensitive=true) %}
2525
{%- set httpMethod = method.upper() %}
2626
{%- set returnType, _ = operation|return_type(version) %}

.generator/src/generator/templates/function_mappings.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct ApiInstances {
1515
{%- for version, apis in all_apis.items() %}
1616
{%- for name, operations in apis.items() %}
1717
{%- set fieldName = "api_"+name %}
18-
{%- set structName = name.replace(" ", "")+"API" %}
18+
{%- set structName = name.replace(" ", "").replace("-", "")+"API" %}
1919
pub {{version}}_{{fieldName | snake_case}}: Option<datadog{{ version.upper() }}::{{fieldName | snake_case}}::{{structName}}>,
2020
{%- endfor %}
2121
{%- endfor %}
@@ -25,7 +25,7 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) {
2525
match api.as_str() {
2626
{%- for name, versions in get_apis_and_versions(all_apis) %}
2727
{%- set fieldName = "api_"+name|snake_case %}
28-
{%- set structName = name.replace(" ", "")+"API" %}
28+
{%- set structName = name.replace(" ", "").replace("-", "")+"API" %}
2929
"{{name.replace(" ", "")}}" => {
3030
{%- for version in versions %}
3131
world.api_instances.{{version}}_{{fieldName}} = Some(datadog{{ version.upper() }}::{{fieldName}}::{{structName}}::with_client_and_config(

tests/scenarios/fixtures.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ fn valid_appkey(world: &mut DatadogWorld) {
298298

299299
#[given(expr = "an instance of {string} API")]
300300
fn instance_of_api(world: &mut DatadogWorld, api: String) {
301-
initialize_api_instance(world, api.clone());
301+
let api_name = api.clone().replace("-", "");
302+
initialize_api_instance(world, api_name);
302303
world.api_name = Some(api);
303304
}
304305

@@ -358,7 +359,7 @@ pub fn given_resource_in_system(
358359
.as_str()
359360
.expect("failed to parse given tag as str")
360361
.to_string();
361-
api_name.retain(|c| !c.is_whitespace());
362+
api_name.retain(|c| !c.is_whitespace() && c != '-');
362363

363364
api_name
364365
} else {
@@ -867,8 +868,8 @@ fn build_undo(
867868
.unwrap()
868869
.to_string()
869870
};
870-
api_name.retain(|c| !c.is_whitespace());
871-
871+
api_name.retain(|c| !c.is_whitespace() && c != '-');
872+
872873
if undo.get("operationId").is_none() {
873874
return Ok(None);
874875
}

0 commit comments

Comments
 (0)