Skip to content

Fix V3 enum-typed DTO properties decoded as nested objects - #76

Merged
jstapelkamp merged 1 commit into
masterfrom
bugfix/LKCAPIBRIDGENL-1V-product-media-enum-dto
Jun 22, 2026
Merged

jstapelkamp merged 1 commit into
masterfrom
bugfix/LKCAPIBRIDGENL-1V-product-media-enum-dto

Conversation

@jstapelkamp

Copy link
Copy Markdown
Contributor

Enum schemas (e.g. DatabankViewOption, ContactTypeEnum, WebsiteProductListType) are referenced via $ref but carry no type key in the V3 OpenAPI spec. The generator treated every $ref property as a nested object DTO, so it emitted empty enum classes plus a Foo::make($data["Type"]) call.

At runtime getProductMedia crashed with:

TypeError: DatabankViewOption::make(): Argument #1 ($data) must be of type array, string given

because the API returns the enum value as a plain string (e.g. "Photo").

Fix

ComponentClassGenerator now detects when a referenced schema is an enum and generates the property as its scalar (string) type instead of a nested DTO. Regenerated the affected V3 classes (ProductResource, ContactCharacteristic, WebshopVisitorBehaviour) and removed the three orphaned empty enum DTO classes.

Test

Added ProductMediaTest reproducing the production path (getProductMedia -> ProductMediaFileDto -> ProductResource) with a string Type, which threw before the fix and now decodes correctly.

Fixes LKCAPIBRIDGENL-1V

…objects

Enum schemas (e.g. DatabankViewOption) are referenced by $ref but carry no
type key, so the generator treated them as object DTOs and emitted empty
classes plus a Foo::make(string) call. getProductMedia then crashed with a
TypeError when the API returned the enum value as a string. Enum references
are now generated as their scalar type.

Fixes LKCAPIBRIDGENL-1V
@jstapelkamp jstapelkamp self-assigned this Jun 18, 2026
@jstapelkamp jstapelkamp changed the title LKCAPIBRIDGENL-1V Fix V3 enum-typed DTO properties decoded as nested objects Fix V3 enum-typed DTO properties decoded as nested objects Jun 22, 2026
@jstapelkamp

Copy link
Copy Markdown
Contributor Author

Tested against real data and is now working.

@jstapelkamp
jstapelkamp merged commit 21bd861 into master Jun 22, 2026
1 check passed
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