Page MenuHomeSoftware Heritage

api/apiresponse: Use DRF JsonEncoder in documented endpoint views
ClosedPublic

Authored by anlambert on Aug 21 2020, 6:06 PM.

Details

Summary

That encoder is used when querying the API for "application/json" content type.
It handles more encoding cases than the default one (notably it knows how to
encode a swh.model.collections.ImmutableDict), so let's also use it when
generating HTML documentation for the API endpoints.

Test Plan

I added a test to cover the issue discovered by @moranegg but this clearly calls
for tests improvements so I also created T2529.

Diff Detail

Repository
rDWAPPS Web applications
Branch
api-json-encode-fix
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 14728
Build 22694: Phabricator diff pipeline on jenkinsJenkins console · Jenkins
Build 22693: arc lint + arc unit

Event Timeline

Build is green

Patch application report for D3826 (id=13465)

Rebasing onto b98a351cea...

Current branch diff-target is up to date.
Changes applied before test
commit 37a8f590ad54c37ab25155cac8058ddefd5d8b3d
Author: Antoine Lambert <antoine.lambert@inria.fr>
Date:   Fri Aug 21 17:18:20 2020 +0200

    api/apiresponse: Use DRF JsonEncoder in documented endpoint views
    
    That encoder is used when querying the API for "application/json" content type.
    It handles more encoding cases than the default one (notably it knows how to
    encode a swh.model.collections.ImmutableDict), so let's also use it when
    generating HTML documentation for the API endpoints.

See https://jenkins.softwareheritage.org/job/DWAPPS/job/tests-on-diff/340/ for more details.

This revision is now accepted and ready to land.Aug 21 2020, 11:48 PM