From a0af50a2e71611045424328bd6e250582476040a Mon Sep 17 00:00:00 2001 From: hsekowski-splunk <74253926+hsekowski-splunk@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:25:23 +0200 Subject: [PATCH] chore: xml removed from output_mode (#741) * chore: xml removed from output_mode * chore: removed xml-related, commented code --- .../commands/openapi_generator/oas.py | 11 -- .../commands/openapi_generator/ucc_to_oas.py | 24 +-- .../Splunk_TA_UCCExample/static/openapi.json | 175 ++---------------- 3 files changed, 25 insertions(+), 185 deletions(-) diff --git a/splunk_add_on_ucc_framework/commands/openapi_generator/oas.py b/splunk_add_on_ucc_framework/commands/openapi_generator/oas.py index 9754def6c..f54d1c865 100644 --- a/splunk_add_on_ucc_framework/commands/openapi_generator/oas.py +++ b/splunk_add_on_ucc_framework/commands/openapi_generator/oas.py @@ -44,19 +44,9 @@ class ServerObject(Init): # https://spec.openapis.org/oas/latest.html#server-ob description: Optional[str] = None -@dataclass -class XMLObject(Init): # https://spec.openapis.org/oas/latest.html#xml-object - name: Optional[str] = None - namespace: Optional[str] = None - prefix: Optional[str] = None - attribute: Optional[bool] = False - wrapped: Optional[bool] = False - - @dataclass class SchemaObject(Init): # https://spec.openapis.org/oas/latest.html#schema-object # discriminator Discriminator Object - # xml XML Object # externalDocs External Documentation Object # example Any # above is a theory @@ -64,7 +54,6 @@ class SchemaObject(Init): # https://spec.openapis.org/oas/latest.html#schema-ob type: Optional[str] = None properties: Optional[dict] = None items: Optional[Dict[str, str]] = None - xml: Optional[XMLObject] = None @dataclass diff --git a/splunk_add_on_ucc_framework/commands/openapi_generator/ucc_to_oas.py b/splunk_add_on_ucc_framework/commands/openapi_generator/ucc_to_oas.py index 9d2dab6cf..c0f0a50a9 100644 --- a/splunk_add_on_ucc_framework/commands/openapi_generator/ucc_to_oas.py +++ b/splunk_add_on_ucc_framework/commands/openapi_generator/ucc_to_oas.py @@ -97,9 +97,7 @@ def __get_schema_object( *, name: str, entities: list, without: Optional[list] = None ) -> Tuple[str, oas.SchemaObject]: name = __create_schema_name(name=name, without=without) - schema_object = oas.SchemaObject( - type="object", xml=oas.XMLObject(name=name), properties={} - ) + schema_object = oas.SchemaObject(type="object", properties={}) for entity in entities: if "helpLink" == entity.type or ( isinstance(without, list) @@ -188,16 +186,13 @@ def __add_schemas_object( # consider changing to 'cache' once python is upgraded to >=3.9 @lru_cache(maxsize=None) def __get_media_type_object_with_schema_ref( - *, schema_name: str, schema_type: Optional[str] = None, is_xml: bool = False + *, schema_name: str, schema_type: Optional[str] = None ) -> oas.MediaTypeObject: ref_dict = {"$ref": f"#/components/schemas/{schema_name}"} schema: Union[oas.SchemaObject, Dict] = ( oas.SchemaObject( type=schema_type, items=ref_dict, - xml=oas.XMLObject(name=f"{schema_name}_list", wrapped=True) - if is_xml - else None, ) if schema_type else ref_dict @@ -217,9 +212,6 @@ def __get_path_get( "application/json": __get_media_type_object_with_schema_ref( schema_name=name, schema_type=schema_type ), - "application/xml": __get_media_type_object_with_schema_ref( - schema_name=name, schema_type=schema_type, is_xml=True - ), }, ) }, @@ -257,9 +249,6 @@ def __get_path_post( "application/json": __get_media_type_object_with_schema_ref( schema_name=name ), - "application/xml": __get_media_type_object_with_schema_ref( - schema_name=name, is_xml=True - ), }, ) }, @@ -295,9 +284,6 @@ def __get_path_delete(*, name: str) -> oas.OperationObject: "application/json": __get_media_type_object_with_schema_ref( schema_name=name, schema_type="array" ), - "application/xml": __get_media_type_object_with_schema_ref( - schema_name=name, schema_type="array", is_xml=True - ), }, ) }, @@ -308,9 +294,9 @@ def __get_output_mode() -> Dict[str, Any]: return { "name": "output_mode", "in": "query", - "required": False, - "description": "The name of the item to operate on", - "schema": {"type": "string", "enum": ["xml", "json"]}, + "required": True, + "description": "Output mode", + "schema": {"type": "string", "enum": ["json"], "default": "json"}, } diff --git a/tests/testdata/expected_addons/expected_output_global_config_configuration/Splunk_TA_UCCExample/static/openapi.json b/tests/testdata/expected_addons/expected_output_global_config_configuration/Splunk_TA_UCCExample/static/openapi.json index f3bfc5607..3d432c91d 100644 --- a/tests/testdata/expected_addons/expected_output_global_config_configuration/Splunk_TA_UCCExample/static/openapi.json +++ b/tests/testdata/expected_addons/expected_output_global_config_configuration/Splunk_TA_UCCExample/static/openapi.json @@ -53,11 +53,6 @@ "oauth": { "type": "string" } - }, - "xml": { - "name": "account", - "attribute": false, - "wrapped": false } }, "account_without_name": { @@ -86,11 +81,6 @@ "oauth": { "type": "string" } - }, - "xml": { - "name": "account_without_name", - "attribute": false, - "wrapped": false } }, "proxy": { @@ -123,11 +113,6 @@ "proxy_rdns": { "type": "string" } - }, - "xml": { - "name": "proxy", - "attribute": false, - "wrapped": false } }, "proxy_without_name": { @@ -160,11 +145,6 @@ "proxy_rdns": { "type": "string" } - }, - "xml": { - "name": "proxy_without_name", - "attribute": false, - "wrapped": false } }, "logging": { @@ -180,11 +160,6 @@ "CRITICAL" ] } - }, - "xml": { - "name": "logging", - "attribute": false, - "wrapped": false } }, "logging_without_name": { @@ -200,11 +175,6 @@ "CRITICAL" ] } - }, - "xml": { - "name": "logging_without_name", - "attribute": false, - "wrapped": false } }, "custom_abc": { @@ -231,11 +201,6 @@ "testUrl": { "type": "string" } - }, - "xml": { - "name": "custom_abc", - "attribute": false, - "wrapped": false } }, "custom_abc_without_name": { @@ -262,11 +227,6 @@ "testUrl": { "type": "string" } - }, - "xml": { - "name": "custom_abc_without_name", - "attribute": false, - "wrapped": false } } }, @@ -291,19 +251,6 @@ "$ref": "#/components/schemas/account" } } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/account" - }, - "xml": { - "name": "account_list", - "attribute": false, - "wrapped": true - } - } } } } @@ -320,11 +267,6 @@ "schema": { "$ref": "#/components/schemas/account" } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/account" - } } } } @@ -346,14 +288,14 @@ { "name": "output_mode", "in": "query", - "required": false, - "description": "The name of the item to operate on", + "required": true, + "description": "Output mode", "schema": { "type": "string", "enum": [ - "xml", "json" - ] + ], + "default": "json" } } ] @@ -368,11 +310,6 @@ "schema": { "$ref": "#/components/schemas/account" } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/account" - } } } } @@ -389,11 +326,6 @@ "schema": { "$ref": "#/components/schemas/account" } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/account" - } } } } @@ -423,19 +355,6 @@ "$ref": "#/components/schemas/account" } } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/account" - }, - "xml": { - "name": "account_list", - "attribute": false, - "wrapped": true - } - } } } } @@ -456,14 +375,14 @@ { "name": "output_mode", "in": "query", - "required": false, - "description": "The name of the item to operate on", + "required": true, + "description": "Output mode", "schema": { "type": "string", "enum": [ - "xml", "json" - ] + ], + "default": "json" } } ] @@ -481,19 +400,6 @@ "$ref": "#/components/schemas/proxy" } } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/proxy" - }, - "xml": { - "name": "proxy_list", - "attribute": false, - "wrapped": true - } - } } } } @@ -510,11 +416,6 @@ "schema": { "$ref": "#/components/schemas/proxy" } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/proxy" - } } } } @@ -536,14 +437,14 @@ { "name": "output_mode", "in": "query", - "required": false, - "description": "The name of the item to operate on", + "required": true, + "description": "Output mode", "schema": { "type": "string", "enum": [ - "xml", "json" - ] + ], + "default": "json" } } ] @@ -561,19 +462,6 @@ "$ref": "#/components/schemas/logging" } } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/logging" - }, - "xml": { - "name": "logging_list", - "attribute": false, - "wrapped": true - } - } } } } @@ -590,11 +478,6 @@ "schema": { "$ref": "#/components/schemas/logging" } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/logging" - } } } } @@ -616,14 +499,14 @@ { "name": "output_mode", "in": "query", - "required": false, - "description": "The name of the item to operate on", + "required": true, + "description": "Output mode", "schema": { "type": "string", "enum": [ - "xml", "json" - ] + ], + "default": "json" } } ] @@ -641,19 +524,6 @@ "$ref": "#/components/schemas/custom_abc" } } - }, - "application/xml": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/custom_abc" - }, - "xml": { - "name": "custom_abc_list", - "attribute": false, - "wrapped": true - } - } } } } @@ -670,11 +540,6 @@ "schema": { "$ref": "#/components/schemas/custom_abc" } - }, - "application/xml": { - "schema": { - "$ref": "#/components/schemas/custom_abc" - } } } } @@ -696,14 +561,14 @@ { "name": "output_mode", "in": "query", - "required": false, - "description": "The name of the item to operate on", + "required": true, + "description": "Output mode", "schema": { "type": "string", "enum": [ - "xml", "json" - ] + ], + "default": "json" } } ]