Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
-

-->
------
## [1.0.5](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.4...v1.0.5)
### Added
- Added `json` output format support

### Changed
- bump asf-search to v9.0.6

------
## [1.0.5](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.4...v1.0.5)
### Added
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ujson==5.7.0
uvicorn==0.21.1
watchfiles==0.19.0

asf_search==9.0.4
asf_search==9.0.6
python-json-logger==2.0.7
asf_enumeration

Expand Down
11 changes: 9 additions & 2 deletions src/SearchAPI/application/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,18 @@

def as_output(results: asf.ASFSearchResults, output: str) -> dict:
output_format = output.lower()
if output_format == "json":
output_format = "jsonlite"

# Use a switch statement, so you only load the type of output you need:
match output_format:
case 'json':
return {
'content': ''.join(results.json()),
'media_type': 'application/json; charset=utf-8',
'headers': {
**constants.DEFAULT_HEADERS,
'Content-Disposition': f"attachment; filename={make_filename('json')}",
}
}
case 'jsonlite':
return {
'content': ''.join(results.jsonlite()),
Expand Down
2 changes: 1 addition & 1 deletion tests/yml_tests/test_Baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ tests:
output: json
# use_maturity: True

expected file: jsonlite # dropping json output
expected file: json # dropping json output
expected code: 200

- no output specified:
Expand Down
Loading