Skip to content

Commit

Permalink
fix: change location of openapi.json generated file (#958)
Browse files Browse the repository at this point in the history
* fix: change location of openapi.json generated file

* fix: align endpoint of openapi.json

* test(ui): the location of openapi.json file changed

---------

Co-authored-by: Szymon Oleksy <soleksy@splunk.com>
  • Loading branch information
artemrys and soleksy-splunk authored Nov 27, 2023
1 parent 1716494 commit e0d38b7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ information [here](ucc_related_libraries.md).

* Generate UI (`appserver` folder)
* Generate Python REST handlers to support UI CRUD operations (`bin` folder)
* Generate OpenAPI description document (`static/openapi.json` file) (more info [here](openapi.md))
* Generate OpenAPI description document (`appserver/static/openapi.json` file) (more info [here](openapi.md))
* Generate `.conf` files (more info [here](dot_conf_files.md))
* Install Python requirements (`lib` folder)
* Generate metadata files (`metadata` folder)
Expand Down
6 changes: 3 additions & 3 deletions docs/openapi.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# OpenAPI description document

OpenAPI description document is generated with `ucc-gen` command.
There has to be defined valid `globalConfig.json` and `app.manifest` to have the document (`static/openapi.json` file) generated.
OpenAPI's description document is generated with `ucc-gen` command.
There has to be defined valid `globalConfig.json` and `app.manifest` to have the document (`appserver/static/openapi.json` file) generated.

## How to find the document?

Once `ucc-gen` command is executed, OpenAPI description document is located in output `static` subdirectory.
Once `ucc-gen` command is executed, OpenAPI description document is located in output `appserver/static` subdirectory.

One of ways is to download it via button displayed in top right corner of configuration page.

Expand Down
2 changes: 1 addition & 1 deletion splunk_add_on_ucc_framework/commands/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ def generate(
open_api = OpenAPI(open_api_object.json)

output_openapi_folder = os.path.abspath(
os.path.join(output_directory, ta_name, "static")
os.path.join(output_directory, ta_name, "appserver", "static")
)
output_openapi_path = os.path.join(output_openapi_folder, "openapi.json")
if not os.path.isdir(output_openapi_folder):
Expand Down
4 changes: 2 additions & 2 deletions tests/smoke/test_ucc_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def test_ucc_generate_with_configuration():
("README", "splunk_ta_uccexample_account.conf.spec"),
("README", "splunk_ta_uccexample_settings.conf.spec"),
("metadata", "default.meta"),
("static", "openapi.json"),
("appserver", "static", "openapi.json"),
]
helpers.compare_file_content(
files_to_be_equal,
Expand Down Expand Up @@ -276,6 +276,6 @@ def test_ucc_generate_openapi_with_configuration_files_only():
build.generate(source=package_folder, output_directory=temp_dir)

expected_file_path = path.join(
temp_dir, "Splunk_TA_UCCExample", "static", "openapi.json"
temp_dir, "Splunk_TA_UCCExample", "appserver", "static", "openapi.json"
)
assert not path.exists(expected_file_path)
2 changes: 1 addition & 1 deletion tests/ui/test_configuration_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_openapi_json_download_button(
)
configuration_page.download_openapi.wait_to_be_clickable()
self.assert_util(
"splunkd/__raw/servicesNS/nobody/Splunk_TA_UCCExample/static/openapi.json",
"/app/Splunk_TA_UCCExample/openapi.json",
download_openapi_href,
operator="in",
)
8 changes: 2 additions & 6 deletions ui/src/components/DownloadButton/OpenApiDownloadBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import React from 'react';
import { createRESTURL } from '@splunk/splunk-utils/url';
import { app } from '@splunk/splunk-utils/config';
import Icon from '@splunk/react-icons/ArrowBroadUnderbarDown';
import { getBuildDirPath } from '../../util/script';
import DownloadButton from './DownloadButton';

function OpenApiDownloadButton() {
return (
<div>
<DownloadButton
fileUrl={createRESTURL('static/openapi.json', {
app,
owner: 'nobody',
})}
fileUrl={getBuildDirPath().replace('js/build', 'openapi.json')}
fileNameAfterDownload="openapi.json"
>
<Icon />
Expand Down

0 comments on commit e0d38b7

Please sign in to comment.