Skip to content

[BUG] [JS] call to inexistant method validateJson() on nested oneOf class #19241

@etshy

Description

@etshy

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
    Tested on latest release, not latest master.
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

Json is gnerated from Php codebase usnig nelmio/api-doc-bundle.
On nested classes (properties, not extension), the js client will start calling validateJson on class that doesn't have that method.
It happens on validateJson method that call other class validateJson, but there is a "proxy class" between both.

Here is a repo with the generated js client for my openapi json : https://github.com/etshy/bad-generated-openapi-js-client

You can see in AddThingsCommand.js, validateJSON method, it try to call AddThingsCommandThings.validateJSON() but the method doesn't exists.
It should do ThingsDto.validateJSON() because AddThingsCommandThings is a "proxy" to ThingDto.

Noting that the generated client is good when using allOf, but nelmio bundle change all allOf to oneOf from v4.13 to follow a change on zircote/swagger-php : nelmio/NelmioApiDocBundle#2156

openapi-generator version

7.0.1 and 7.7.0 using javascript generator

OpenAPI declaration file content or url

Json

Gist

Generation Details

java -jar openapi-generator-cli-7.7.0.jar generate -i ./minimalopenapi.json -g javascript -o ./path/to/

with minimalopenapi.json the gist I linked

Steps to reproduce

Generate js client with provided openapi json

Suggest a fix

When using oneOf and there is a sort of "proxy" class, guess the real class/dto and call validateJson on it instead of the proxy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions