OpenAPITools / OpenAPITools/openapi-generator

[BUG] [typescript-fetch] generated API references undeclared function objectToJSON

Open
#22,000 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • Have you tested with the latest master to confirm the issue still exists?
  • 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

With a schema that contains an object as a property, generation for typescript-fetch produces an invalid client that contains a reference to an undeclared function objectToJSON.

openapi-generator version

latest (via docker hub)

OpenAPI declaration file content or url

See reprex at https://github.com/luketudge/openapi-reprex

Generation Details
docker run --rm \
    -v "${PWD}:/local" \
    openapitools/openapi-generator-cli generate \
    -i /local/openapi.json \
    -g typescript-fetch \
    -c /local/openapi_gen_config_typescript.json \
    -o /local/typescript
Steps to reproduce

https://github.com/luketudge/openapi-reprex

Related issues/PRs

Looks like a regression of #19280 but in a special case. Whereas the very similar bug reported there occurs for a schema in which the top-level item is declared as type 'object', the bug here is the same thing, but with a property that is declared as type object.

Suggest a fix

I'm looking into it. Not sure yet.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generation command and the openapi-reprex repository linked in the issue, using the typescript-fetch generator and its Docker invocation to reproduce the output. Trace where the generated client references objectToJSON and confirm that the generated client no longer contains an undeclared function reference for object-valued properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.