AnotiaWang / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
0 stars 0 forks source link

Sweep: Fix TypeScript + fetch generated code with `oneOf` to properly check the dto type #2

Closed sweep-ai[bot] closed 1 month ago

sweep-ai[bot] commented 1 month ago

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 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

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.

sweep-ai[bot] commented 1 month ago

Rollback Files For Sweep

This is an automated message generated by Sweep AI.

AnotiaWang commented 1 month ago

The {{classname}}FromJSONTyped function should also be updated (near the if (json == null) condition)