Skip to content

Commit fb8f1c8

Browse files
XiaofeiCaoCopilot
andauthored
mgmt Swagger generation, add suffix config to api-specs.yaml if present, when generating for the first-time (#45441)
* add suffix * Update eng/automation/generate_utils.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 0f81bc6 commit fb8f1c8

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

eng/automation/generate.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,9 @@ def main():
451451
args["readme"] = readme
452452
args["spec"] = spec
453453

454-
update_parameters(args.get("suffix") or get_suffix_from_api_specs(api_specs_file, spec))
455-
service = get_and_update_service_from_api_specs(api_specs_file, spec, args["service"])
454+
suffix = args.get("suffix") or get_suffix_from_api_specs(api_specs_file, spec)
455+
update_parameters(suffix)
456+
service = get_and_update_service_from_api_specs(api_specs_file, spec, args["service"], suffix)
456457
args["service"] = service
457458
module = ARTIFACT_FORMAT.format(service)
458459
stable_version, current_version = set_or_increase_version(sdk_root, GROUP_ID, module, **args)

eng/automation/generate_utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,22 @@ def get_and_update_service_from_api_specs(
284284
api_specs_file: str,
285285
spec: str,
286286
service: str = None,
287+
suffix: str = None,
287288
truncate_service: bool = False,
288289
):
290+
"""
291+
Updates the API specs file with the provided service name and optional suffix.
292+
293+
Args:
294+
api_specs_file (str): Path to the API specs file.
295+
spec (str): The specification key to update in the API specs.
296+
service (str, optional): The service name to associate with the spec. If not provided, it will be derived.
297+
suffix (str, optional): An optional suffix to add to the spec entry in the API specs file.
298+
truncate_service (bool, optional): Whether to truncate the service name to a maximum length of 32 characters.
299+
300+
Returns:
301+
str: The validated and potentially updated service name.
302+
"""
289303
special_spec = {"resources"}
290304
if spec in special_spec:
291305
if not service:
@@ -315,6 +329,9 @@ def get_and_update_service_from_api_specs(
315329
api_specs[spec] = dict() if not api_spec else api_spec
316330
api_specs[spec]["service"] = service
317331

332+
if suffix:
333+
api_specs[spec]["suffix"] = suffix
334+
318335
write_api_specs(api_specs_file, comment, api_specs)
319336

320337
return service

0 commit comments

Comments
 (0)