Skip to content

Commit d679941

Browse files
Handle body properties with dashes or dots in Python exporter
1 parent 86ae359 commit d679941

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/exporters/python.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class PythonExporter implements FormatExporter {
121121
}
122122
}
123123
}
124-
return name;
124+
return name.replaceAll("-", "_").replaceAll(".", "_");
125125
});
126126

127127
// custom conditional to check for request body kind

tests/convert.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,27 @@ resp1 = client.search(
222222
},
223223
)
224224
225+
`,
226+
);
227+
});
228+
229+
it("converts attribute with dashes or dots to python", async () => {
230+
expect(
231+
await convertRequests(
232+
`PUT /_security/settings {"security-profile": {}}
233+
PUT /_watcher/settings {"index.auto_expand_replicas":"0-4"}`,
234+
"python",
235+
{},
236+
),
237+
).toEqual(
238+
`resp = client.security.update_settings(
239+
security_profile={},
240+
)
241+
242+
resp1 = client.watcher.update_settings(
243+
index_auto_expand_replicas="0-4",
244+
)
245+
225246
`,
226247
);
227248
});

0 commit comments

Comments
 (0)