From ba6e0b85c3d61b4a601730524c10eafa0f3529fc Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Thu, 29 Dec 2022 09:50:37 +0530 Subject: [PATCH] To fix Sec builder doc_generator failure and requirements issues (#36) * fix sec builder failure issue * fix main.yaml * length fix Signed-off-by: Sumit Jaiswal * fragment fix Signed-off-by: Sumit Jaiswal Signed-off-by: Sumit Jaiswal --- changelogs/fragments/doc_generator_fix.yaml | 5 +++++ requirements.txt | 1 + roles/module_openapi/tasks/main.yaml | 2 +- roles/module_openapi/templates/doc_generator.py | 15 ++++++++------- 4 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/doc_generator_fix.yaml diff --git a/changelogs/fragments/doc_generator_fix.yaml b/changelogs/fragments/doc_generator_fix.yaml new file mode 100644 index 0000000..c0e91ae --- /dev/null +++ b/changelogs/fragments/doc_generator_fix.yaml @@ -0,0 +1,5 @@ +--- +bugfixes: + - To fix the doc_generator issue for secbuity RM builder using OpenAPI JSON file. + - https://github.com/ansible-community/ansible.content_builder/issues/28 + - https://github.com/ansible-community/ansible.content_builder/issues/29 diff --git a/requirements.txt b/requirements.txt index 320c18c..c7e8fec 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ black==22.3.0 Jinja2==3.0.3 ansible-core jsonschema +oyaml diff --git a/roles/module_openapi/tasks/main.yaml b/roles/module_openapi/tasks/main.yaml index 5b44704..6045127 100644 --- a/roles/module_openapi/tasks/main.yaml +++ b/roles/module_openapi/tasks/main.yaml @@ -11,7 +11,7 @@ register: tmp_directory - name: EXECUTE the python script - ansible.builtin.command: python3 doc_generator.py "{{ plugin['rm_swagger_json'] }}" + ansible.builtin.command: python3 "{{ role_path }}"/templates/doc_generator.py "{{ plugin['rm_swagger_json'] }}" "{{ plugin['api_object_path'] }}" "{{ plugin['name'] }}" "{{ plugin['module_version'] }}" diff --git a/roles/module_openapi/templates/doc_generator.py b/roles/module_openapi/templates/doc_generator.py index 270cba4..3d82a32 100644 --- a/roles/module_openapi/templates/doc_generator.py +++ b/roles/module_openapi/templates/doc_generator.py @@ -881,14 +881,15 @@ def main(): } ) else: - # post_properties = get_api_param_properties_recursively( - # "$ref", api_object, data, global_var_mgmt_dict - # ) - post_properties = get_api_param_properties_recursively( - "schema", api_object, data, global_var_mgmt_dict - ) + if str(sys.argv[6]) == "trendmicro": + post_properties = get_api_param_properties_recursively( + "$ref", api_object, data, global_var_mgmt_dict + ) + elif str(sys.argv[6]) == "fortinet": + post_properties = get_api_param_properties_recursively( + "schema", api_object, data, global_var_mgmt_dict + ) - attribute_map_by_param = {} module_name = str(sys.argv[3]) module_resource = str(sys.argv[5]) module_version = str(sys.argv[4])