Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Way to Set "isRequired" to True in Filter Params #595

Open
grichards opened this issue Jan 29, 2025 · 0 comments
Open

No Way to Set "isRequired" to True in Filter Params #595

grichards opened this issue Jan 29, 2025 · 0 comments

Comments

@grichards
Copy link

grichards commented Jan 29, 2025

API Platform version(s) affected: 4.0.3

Description
If you introspect the API Platform data and look at the Filter Params, there is a property "isRequired". It is always false no matter what I do with the API Platform configuration.

The FilterGuesser seems to want to evaluate that property to determine whether a filter should be "alwaysOn"... but I can't find any way tot set it.

How to reproduce

Create a Doctrine Entity with a SearchFilter configured.

In RA, introspect the API with something like this:

export function ETLogIntrospectedApiData() {
  const dataProvider = useDataProvider();
  const resourceName = useResourceContext();
  const schemaAnalyzer = hydraSchemaAnalyzer();

  dataProvider.introspect().then(({ data }: { data: Api }) => {
    console.log("API Data:", data);
    if (data && data.resources) {
      const resource = data.resources.find((res) => res.name === resourceName);
      if (resource) {
        schemaAnalyzer
          .getFiltersParametersFromSchema(resource)
          .then((params) => {
            console.log("Filter Params:", params);
          });
        schemaAnalyzer.getOrderParametersFromSchema(resource).then((params) => {
          console.log("Order Params:", params);
        });
      }
    }
  });
}

Notice in the console the Filter Params have an isRequired property set to false.

There are no docs about how to set it to true and various things I've tried with ApiProperty aren't working.

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

No branches or pull requests

1 participant