OpenAPITools / OpenAPITools/openapi-generator

[BUG] Javascript fails when anyOf is used

Open
#3,144 4 comments 4 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 (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

For the javascript API-Client for version 4.0.1 anyOf options give in correct results.

Using the following openapi.json.gz you get the following output:

Error: Cannot find module './AnyOffloatarray'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/purcell/git/optimade-python-tools/javascript_client_generator/any_of_min_test/any_of/dist/model/TesterResponse.js:24:24)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)

However by removing the anyOf portion of the file like openapi_no_anyof.json.gz it runs as expected.

This means that anyOf can not be used.

openapi-generator version

4.0.1

OpenAPI declaration file content or url

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

Run the listed generation, npm install, build, and Node reproduction using openapi.json; inspect the generated TesterResponse.js import that references the missing AnyOffloatarray module and trace the JavaScript generator's import handling. Done means a client generated from the anyOf specification builds and runs without the missing-module error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.