Skip to content

generator: Fix broken union type anyOf selection since Redfish 2024.1#20

Open
Nitorac wants to merge 1 commit intoAmateurECE:developfrom
Nitorac:fix/broken_union_type_since_2024.1
Open

generator: Fix broken union type anyOf selection since Redfish 2024.1#20
Nitorac wants to merge 1 commit intoAmateurECE:developfrom
Nitorac:fix/broken_union_type_since_2024.1

Conversation

@Nitorac
Copy link
Copy Markdown

@Nitorac Nitorac commented Jul 25, 2025

Hi, I propose a minor fix that helps fixing the issue for union types in the OpenAPI spec after Redfish 2024.1.

In Redfish 2023.1 Resource.yaml, the Location resource looks like this:

    Resource_Location:
      anyOf:
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_1_15.yaml#/components/schemas/Resource_v1_1_15_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_2_14.yaml#/components/schemas/Resource_v1_2_14_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_3_13.yaml#/components/schemas/Resource_v1_3_13_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_4_12.yaml#/components/schemas/Resource_v1_4_12_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_5_11.yaml#/components/schemas/Resource_v1_5_11_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_6_11.yaml#/components/schemas/Resource_v1_6_11_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_7_10.yaml#/components/schemas/Resource_v1_7_10_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_8_10.yaml#/components/schemas/Resource_v1_8_10_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_9_8.yaml#/components/schemas/Resource_v1_9_8_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_10_5.yaml#/components/schemas/Resource_v1_10_5_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_11_4.yaml#/components/schemas/Resource_v1_11_4_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_12_3.yaml#/components/schemas/Resource_v1_12_3_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_13_2.yaml#/components/schemas/Resource_v1_13_2_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_14_1.yaml#/components/schemas/Resource_v1_14_1_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_15_0.yaml#/components/schemas/Resource_v1_15_0_Location
      - $ref: http://redfish.dmtf.org/schemas/v1/Resource.v1_16_0.yaml#/components/schemas/Resource_v1_16_0_Location
      description: The location of a resource.
      x-longDescription: This type shall describe the location of a resource.

So the redfish-generator works as expected on this structure.

But since Redfish 2024.1, it looks like this:

    Resource_Location:
      $ref: ./Resource.v1_19_1.yaml#/components/schemas/Resource_v1_19_1_Location
      description: The location of a resource.
      x-longDescription: This type shall describe the location of a resource.

This leads to the UnionContextFactory to ignore this kind of resources that fallback into a simple pub struct Location;.

As a patch, I propose to still support getAnyOf if any works, but add the support for the simple .get$ref() on these resources.

I'm still pretty new with the Redfish specification so I am open for any improvements on this code !

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.

1 participant