OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
The purpose of this pull request is to fix an issue where the TypeScript + fetch generated code with oneOf does not properly check the dto type.
Description
The issue was that the generated instanceOfXXX() functions did not properly check the type property to determine which model instance it is. This caused bugs in production where Payload2 and Payload3 were never matched.
The changes in this pull request update the modelGeneric.mustache template to check if the type property matches the expected enum value for the model. This ensures that the instanceOfXXX() functions correctly identify the model instance.
Summary
Updated the modelGeneric.mustache template to check the type property against the expected enum value for the model
This ensures the instanceOfXXX() functions correctly identify the model instance when using oneOf
Modified the instanceOfPayload1() function to check if the type property is equal to the first value in the Payload1TypeEnum
Fixes #1.
[!TIP]
To get Sweep to edit this pull request, you can:
Comment below, and Sweep can edit the entire PR
Comment on a file, Sweep will only modify the commented file
Edit the original issue to get Sweep to recreate the PR from scratch
This is an automated message generated by Sweep AI.
Purpose
The purpose of this pull request is to fix an issue where the TypeScript + fetch generated code with
oneOf
does not properly check the dto type.Description
The issue was that the generated
instanceOfXXX()
functions did not properly check thetype
property to determine which model instance it is. This caused bugs in production wherePayload2
andPayload3
were never matched.The changes in this pull request update the
modelGeneric.mustache
template to check if thetype
property matches the expected enum value for the model. This ensures that theinstanceOfXXX()
functions correctly identify the model instance.Summary
modelGeneric.mustache
template to check thetype
property against the expected enum value for the modelinstanceOfXXX()
functions correctly identify the model instance when usingoneOf
instanceOfPayload1()
function to check if thetype
property is equal to the first value in thePayload1TypeEnum
Fixes #1.
This is an automated message generated by Sweep AI.