OpenAPITools / OpenAPITools/openapi-generator

[BUG] [TYPESCRIPT-AXIOS] [MAVEN] allOf inherit not working

Open
#23,376 0 comments 3 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

I have 2 classes, the first one (One1) has some fields and the second one (Two2) has also some fields and inherits the fields from class One1.

On my Java generator this works just fine.
On my Typescript-axios generator this doesnt work, and generate me the class One1, but the class Two2 doesnt have any inherits nor fields, it will do this:

export type Two2 = One1;

Ive also tried this on the Typescript-angular & Typescript-fetch generator, they also work just fine.
Only Typescript-Axios seems to have this issue.

Image
openapi-generator version

Tested this issue with these version of the openapi-generator-maven plugin:
7.21.0
7.19.0
7.5.0

OpenAPI declaration file content
openapi: 3.0.4
info:
  title: test
  version: '0.1'
paths:
  /api/test-path:
    get:
      summary: test endpoint
      operationId: testEndPoint
      security: []
      responses:
        "200":
          description: success
          content:
            'application/json':
              schema:
                $ref: '#/components/schemas/One1'
components:
  schemas:
    One1:
      type: object
      required:
        - a
      properties:
        a:
          type: string

    Two2:
      allOf:
        - $ref: '#/components/schemas/One1'
        - type: object
          required:
            - c
          properties:
            c:
              type: string
            d:
              type: integer
Generation Details

POM.xml
<plugin> <groupId>org.openapitools</groupId> <artifactId>openapi-generator-maven-plugin</artifactId> <version>7.21.0</version> <executions> <execution> <id>openapi-test-gen</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> <configuration> <generatorName>typescript-axios</generatorName> <inputSpec>src/main/resources/swagger.yaml</inputSpec> <apiPackage>services</apiPackage> <modelPackage>types</modelPackage> <generateApis>true</generateApis> <generateModels>true</generateModels> <configOptions> <withSeparateModelsAndApi>true</withSeparateModelsAndApi> <withAWSV4Signature>false</withAWSV4Signature> <enumPropertyNaming>UPPERCASE</enumPropertyNaming> <openapiNormalizer>REF_AS_PARENT_IN_ALLOF=true</openapiNormalizer> </configOptions> </configuration> </execution> </executions> </plugin>

Steps to reproduce

Just generate a Typescript-Axios client with the given specs i provided.
Take a look at the generated types/classes.

Related issues/PRs
Suggest a fix
  • When i have time, i will edit this post or comment here.

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 by generating the supplied OpenAPI 3.0.4 spec with the openapi-generator-maven-plugin using the typescript-axios generator and REF_AS_PARENT_IN_ALLOF=true. Compare the generated Two2 model with One1 and with the typescript-angular or typescript-fetch output; done means Two2 includes the inherited and local fields rather than only being an alias of One1.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.