Skip to content

Commit

Permalink
chore: xml removed from output_mode (#741)
Browse files Browse the repository at this point in the history
* chore: xml removed from output_mode

* chore: removed xml-related, commented code
  • Loading branch information
hsekowski-splunk authored Apr 24, 2023
1 parent 2fef597 commit a0af50a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 185 deletions.
11 changes: 0 additions & 11 deletions splunk_add_on_ucc_framework/commands/openapi_generator/oas.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,16 @@ 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
# below is practice
type: Optional[str] = None
properties: Optional[dict] = None
items: Optional[Dict[str, str]] = None
xml: Optional[XMLObject] = None


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
),
},
)
},
Expand Down Expand Up @@ -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
),
},
)
},
Expand Down Expand Up @@ -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
),
},
)
},
Expand All @@ -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"},
}


Expand Down
Loading

0 comments on commit a0af50a

Please sign in to comment.