Skip to content

[API] Reduce hidden mutations #9481

Closed

Description

@SchrodingersGat

Body of the issue

A lot of API endpoints can be "mutated" by passing extra parameters (e.g. ?part_detail=true). These parameters are largely undocumented and should be re-implemented as API filters. This will expose them to the API schema documentation.

Activity

  1. added
    api
    enhancement
    on Apr 8, 2025
  2. added this to the 1.0.0 milestone on Apr 8, 2025
  3. matmair commented on Apr 17, 2025

    @matmair
    Member

    See #9045

  4. Reza98Sh commented on Aug 14, 2025

    @Reza98Sh
    Contributor

    I’d like to take on this issue. Is there any additional context or details I should know before starting?

  5. matmair commented on Aug 15, 2025

    @matmair
    Member

    @Reza98Sh With the limited work you have submitted to the backend I am not sure if you have found all the trip-hazards that are hidden in the way our backend api works, but you have shown potential in other work so sure, go ahead. Just let us know if you need pointers.

    Just to re-iterate the problem and what would be considered a "solve":
    Problem: We currently have parameters in the serializers that adapt the form of the API response.

    part_detail = str2bool(self.request.GET.get('part_detail', True))

    If you look into the OpenAPI schema you will see that this parameter is not represented there
    https://github.com/inventree/schema/blob/38ab7363cf0b1fcedc3e4994fbf5b351db2473bd/export/385/api.yaml#L1964-L2152

    There are at least 2 anti-patterns, that should be addressed:

    1. parameters that completely change the output schema - probably a lot of work, diving deep into drf serialisation and OpenAPI schema generation
    2. parameters that add filters that are not documented - easier as one can use proper django-filter filtersets / fields and that automatically gets picked up by schema generation

    Goal: A "solve" would be to eliminate 2 completely and proposes a working solution for addressing 1

    The whole issue was discovered by @1337joe as he is generating a client library from the schema and these mismatches lead to missing arguments/broken requests.

  6. matmair commented on Aug 15, 2025

    @matmair
    Member

    I think this issue is probably best addressed by a number of small PRs that tackle a few API endpoints at a time, as a large PR that does everything might be time-costly to review and correct.

  7. modified the milestones: 2.0.0, 1.1.0 on Oct 1, 2025
  8. matmair commented on Oct 1, 2025

    @matmair
    Member

    I have changed the milestone, I think it is realistic to tackle this with the next feature release

  9. added a commit that references this issue on Oct 5, 2025
    6895958
  10. added a commit that references this issue on Oct 6, 2025
    946418e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    apienhancement

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions