Skip to content

Regression due to PR 7419 when using @rtk-query/codegen-openapi on hydra:member type #7479

@cpetit-sigma-fr

Description

@cpetit-sigma-fr

API Platform version(s) affected: 4.2.2

Description

#7419 introduces a regression for our project using @rtk-query/codegen-openapi as defining 'hydra:member': object[] instead of 'hydra:member': any makes Typescript consider type is object[] even if hydra:member is redefined as a correct type like FooBarJsonldBazCollection[] like this:

export type FooBarJsonldBazCollectionApiResponse =
  /** status 200 FooBarBaz */ HydraCollectionBaseSchema & {
    'hydra:member'?: FooBarJsonldBazCollection[]
  }

How to reproduce

  • Open http://localhost:8000/api/docs.jsonopenapi (with a running API platform (core) project)
  • if API is 4.2.1, HydraCollectionBaseSchema uses any for member
  • if API is 4.2.2, HydraCollectionBaseSchema uses object[] for member

Possible Solution

make this object[] change optional / configurable

Additional Context

For now, our workaround is to replace all occurences in each of our generated API files:

for api in src/redux/*Api.ts ; do
    echo "api='$api'"
    sed -i "s/'hydra:member': object\[\]/'hydra:member': any/g" $api
done

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