ash-project / ash-project/ash_json_api

Limit OpenAPI filter operators based on attribute/argument type

Open
#309 6 comments 0 reactions 0 assignees View on GitHub
enhancement needs review
Dominant language
Elixir
Stars
94
Forks
80
Avg merge
5h 5m
Merged PRs (30d)
4

Description

**Is your feature request related to a problem? Please describe.**

In `AshJsonApi.OpenApi.raw_filter_type/2`, all of `Ash.Filter.builtin_operators/0` are included when generating filter schemas, regardless of the attribute or argument type. This results in many irrelevant or inapplicable filters being included in the schema.

e.g. Filtering operators like contains, length, or ilike appear even for types where they don’t make sense (e.g., integer), which can be confusing or misleading in the generated API documentation.

**Describe the solution you'd like**

It would be great if the available filters could be limited based on the type of each attribute or argument. That way, only relevant operators would be included in the filter schema.

**Describe alternatives you've considered**

no

**Express the feature either with a change to resource syntax, or with a change to the resource interface**

I have no idea.

**Additional context**

For now, I’m proposing this change here, but it might actually require modifications in the ash library itself, depending on the desired approach.

Contributor guide

Open the contributing guide

Research direction

Start with AshJsonApi.OpenApi.raw_filter_type/2 and inspect how Ash.Filter.builtin_operators/0 is used when generating filter schemas. Determine how attribute and argument types should select operators; done means irrelevant operators such as contains, length, and ilike no longer appear for incompatible types while applicable operators remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir, openapi
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.