Skip to content

Commit d8213af

Browse files
feat: add json output support
1 parent 0a49ea2 commit d8213af

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2525
-
2626
2727
-->
28+
------
29+
## [1.0.5](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.4...v1.0.5)
30+
### Added
31+
- Added `json` output format support
32+
33+
### Changed
34+
- bump asf-search to v9.0.5
35+
2836
------
2937
## [1.0.5](https://github.com/asfadmin/Discovery-SearchAPI-v3/compare/v1.0.4...v1.0.5)
3038
### Added

src/SearchAPI/application/output.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,18 @@
6666

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

7270
# Use a switch statement, so you only load the type of output you need:
7371
match output_format:
72+
case 'json':
73+
return {
74+
'content': ''.join(results.json()),
75+
'media_type': 'application/json; charset=utf-8',
76+
'headers': {
77+
**constants.DEFAULT_HEADERS,
78+
'Content-Disposition': f"attachment; filename={make_filename('json')}",
79+
}
80+
}
7481
case 'jsonlite':
7582
return {
7683
'content': ''.join(results.jsonlite()),

0 commit comments

Comments
 (0)