OpenAPITools / OpenAPITools/openapi-generator

[BUG][typescript-*][possibly other languages] Missing fields when using allOf composition

Open
#16,150 16 comments 15 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

When working on an enhancement of the typescript-axios generation I've noticed fields missing in the generated classes.
This PR changed the way inline schemas are handled. This was done among other things in order to remove dangling/useless *allOf classes that existed in e.g. java. During this commit changes to the typescript examples have been comittet that removed the *allOf classes withouth regard of them now missing fields. This can for e.g. be seen when comparing the generated flat-stock-pick-order-dto.ts with the corresponding spec file.

I've tried using --inline-schema-name-defaults REFACTOR_ALLOF_INLINE_SCHEMAS=true with the locally build jar of the current master but couldn't get that to work. I'll include my command line arguments used, I probably did something wrong.

This also seems to be a problem for the atleast the typescript-rxjs/allOf-composition example aswell, where SuperBoy, SuperBaby & Superman are missing properties now.

openapi-generator version

Current master

OpenAPI declaration file content or url

Spec File

Command line used for generation

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g typescript-axios -i modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml -o samples/client/others/typescript-axios/with-separate-models-and-api-inheritance --additional-properties=withSeparateModelsAndApi=true --additional-properties=apiPackage=api --additional-properties=modelPackage=model --additional-properties=legacyDiscriminatorBehavior=false --inline-schema-name-defaults REFACTOR_ALLOF_INLINE_SCHEMAS=true

Steps to reproduce
  1. Check out the current master of the openapi-generator project
  2. Build the project
  3. Either run previously mentioned command line arguments for genrator or generate the mentioned example using ./bin/generate-samples.sh ./bin/configs/typescript-axios-with-separate-models-and-api-inheritance.yaml
  4. Compare the generated files and the spec to see that fields are missing in the generated files.
Related issues/PRs

Related Pull Requests: #15682

Suggest a fix/enhancement

If --inline-schema-name-defaults REFACTOR_ALLOF_INLINE_SCHEMAS=true works (which again maybe i was just too dumb to get to work) and fixes this issue it should probably be enabled by default for the typescript generators the same way it is for the csharp client generators as mentioned in the PR.
Additionally, tests should be added that check if properties are missing in generated types. As *typescript-axios/with-separate-models-and-api-inheritance was added by our team we would be willing to add those in a PR once the issue has been resolved.

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 modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml and compare it with the generated flat-stock-pick-order-dto.ts; also inspect the changes in PR #15682. Reproduce with the listed Maven-built CLI command or bin/generate-samples.sh, then verify that generated types include all spec properties and add regression coverage for the typescript-axios and typescript-rxjs examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
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.