Skip to content

fix: Apply field_names mapping to OpenAPI filter schema#444

Merged
zachdaniel merged 1 commit into
mainfrom
fix/field-names-openapi-filter-schema
Jun 23, 2026
Merged

fix: Apply field_names mapping to OpenAPI filter schema#444
zachdaniel merged 1 commit into
mainfrom
fix/field-names-openapi-filter-schema

Conversation

@barnabasJ

@barnabasJ barnabasJ commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

The field_names DSL was respected at runtime for filter parsing (via filter_ref_transformer) but the generated OpenAPI spec still advertised filter properties and component schema ids under the raw internal field name. A resource with field_names(title: :subject) accepted filter[subject]=... at runtime but the spec advertised filter[title]=...

Route the filter property keys (attribute/calculation/aggregate) and the "-filter-" component schema id through
AshJsonApi.Resource.Info.field_to_json_key/2 so the spec matches runtime behavior. Relationship keys and boolean combinators are unaffected as they are not subject to field_names mapping.

This also changes the filter property key type from atom to string, consistent with how the rest of the spec represents JSON:API keys.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

The field_names DSL was respected at runtime for filter parsing (via
filter_ref_transformer) but the generated OpenAPI spec still advertised
filter properties and component schema ids under the raw internal field
name. A resource with field_names(title: :subject) accepted
filter[subject]=... at runtime but the spec advertised filter[title]=...

Route the filter property keys (attribute/calculation/aggregate) and the
"-filter-<name>" component schema id through
AshJsonApi.Resource.Info.field_to_json_key/2 so the spec matches runtime
behavior. Relationship keys and boolean combinators are unaffected as they
are not subject to field_names mapping.

This also changes the filter property key type from atom to string,
consistent with how the rest of the spec represents JSON:API keys.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@zachdaniel
zachdaniel merged commit 437cd32 into main Jun 23, 2026
25 checks passed
@zachdaniel

Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants