Skip to content

Commit

Permalink
fix: OpenAPI schema generator fixes for when multiple inputs are defi…
Browse files Browse the repository at this point in the history
…ned (#1016)

Previously it was trying to use the parent tables.actions object but
that doesn't work when you've only got a single input.

Also added a sample app that has multiple inputs to test, not sure how
to add it to the test suite though?

---------

Co-authored-by: sgoral <sgoral@splunk.com>
  • Loading branch information
yaleman and sgoral-splunk authored Jan 16, 2024
1 parent bc82425 commit 332db43
Show file tree
Hide file tree
Showing 11 changed files with 560 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,15 @@ def __add_paths(
global_config.pages.inputs, "services" # type: ignore[attr-defined]
):
for service in global_config.pages.inputs.services: # type: ignore[attr-defined]
if hasattr(service, "table"):
actions = service.table.actions
else:
actions = global_config.pages.inputs.table.actions # type: ignore[attr-defined]
open_api_object = __assign_ta_paths(
open_api_object=open_api_object,
path=f"/{global_config.meta.restRoot}_{service.name}", # type: ignore[attr-defined]
path_name=service.name,
actions=global_config.pages.inputs.table.actions, # type: ignore[attr-defined]
actions=actions,
page=GloblaConfigPages.INPUTS,
)
return open_api_object
Expand Down
12 changes: 12 additions & 0 deletions tests/smoke/test_ucc_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ def test_ucc_generate_with_everything():
assert path.exists(expected_file_path)


def test_ucc_generate_with_multiple_inputs_tabs():
package_folder = path.join(
path.dirname(path.realpath(__file__)),
"..",
"testdata",
"test_addons",
"package_global_config_multi_input",
"package",
)
build.generate(source=package_folder)


@pytest.mark.skipif(sys.version_info >= (3, 8), reason=PYTEST_SKIP_REASON)
def test_ucc_generate_with_configuration():
with tempfile.TemporaryDirectory() as temp_dir:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Just a readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"schemaVersion": "2.0.0",
"info": {
"title": "Splunk Add-on for UCC Example",
"id": {
"group": null,
"name": "Splunk_TA_UCCExample",
"version": "7.0.1"
},
"author": [
{
"name": "Splunk Inc.",
"email": null,
"company": null
}
],
"releaseDate": null,
"description": "Splunk Add-on for UCC Example",
"classification": {
"intendedAudience": null,
"categories": [],
"developmentStatus": null
},
"commonInformationModels": null,
"license": {
"name": null,
"text": "LICENSES/Apache-2.0.txt",
"uri": null
},
"privacyPolicy": {
"name": null,
"text": null,
"uri": null
},
"releaseNotes": {
"name": null,
"text": "./README.txt",
"uri": null
}
},
"dependencies": null,
"tasks": null,
"inputGroups": null,
"incompatibleApps": null,
"platformRequirements": null,
"supportedDeployments": [
"_standalone",
"_distributed"
],
"targetWorkloads": [
"_search_heads",
"_indexers"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[install]
build = 0

[launcher]
author = Splunk Inc.
version = 0.1.0
description = Splunk_TA_UCCExample

[ui]
is_visible = false
label = Splunk_TA_UCCExample
docs_section_override=AddOns:released

[package]
id = Splunk_TA_UCCExample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
splunktaucclib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 332db43

Please sign in to comment.