Skip to content

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

Description

@grichards

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions