Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeScript-Fetch] Invalid interface definition while setting additionalProperties as true #12388

Open
NachiketaDhal opened this issue Apr 30, 2024 · 0 comments

Comments

@NachiketaDhal
Copy link

Description

Compiling the following yaml into a TypeScript-Fetch client results in an interface with an incorrect type.
Specifically when the additionalProperties is set to true.

Swagger-codegen version

SWAGGER_VERSION=3.0.55

Swagger declaration file content or url

Following is an example sample yaml file

  /api/v1/classes/{className}:
    post:
      operationId: op1
      tags:
        - tag1
      parameters:
        - name: className
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                prop1:
                  type: string
                prop2:
                  type: string
              additionalProperties: true

For an example let's say we have 2 interfaces

interface Interface1 {
    prop1: string,
    prop2: string,
}

interface Interface2 {
    [key: string]: any;
}

So in this case if I'm not passing additionalProperties flag the interface i.e. getting generated for requestBody is Interface1 else it is Interface2.
But I'm looking for a combination that incorporates elements from both the interfaces.

Command line used for generation

java -jar ./swagger-codegen-cli.jar generate -i ./server/out/example.yaml -l typescript-axios -o ./server/out/api-client --additional-properties modelPropertyNaming=original enumPropertyNaming=original

Steps to reproduce

Compile a swagger API containing the definitions mentioned above into a typescript-fetch client.

Suggest a fix/enhancement

I'm looking for a combination that incorporates elements from both the interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant