swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[typescript-axios] additionalProperties generates null interface

Open chasebish opened this issue 3 years ago • 0 comments

Description

The usage of additionalProperties generates invalid code that tries to extend a null interface. The output looks like this:

export interface ExampleRequestBody extends null<String, any> {
}

The null reference needs to be manually changed to a Map<String, any> in order to compile

All of the following usages are not working:

additionalProperties: true
additionalProperties:
  type: string
additionalProperties:
  anyOf:
    - type: string
    - type: boolean
Swagger-codegen version

swagger-codegen-cli-v3:3.0.35

Swagger declaration file content or url
openapi: "3.0.3"
info:
  title: "Custom Test Api"
  version: "0.0.0"
components:
  schemas:
    ExampleRequestBody:
      type: "object"
      additionalProperties: true
paths:
  /example/request:
    post:
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ExampleRequestBody"
      responses:
        204:
          description: "Success"

Command line used for generation
docker run --rm -v ${PWD}:/local --user=`id -u`:`id -g` swaggerapi/swagger-codegen-cli-v3:3.0.35 generate -i /local/open-api-spec.yaml -l typescript-axios -o /local/out
Steps to reproduce
  1. Pull the correct docker image:
docker pull swaggerapi/swagger-codegen-cli-v3:3.0.35
  1. Copy the .yaml file above
  2. Run the command above with the correct path to the .yaml file

chasebish avatar Sep 20 '22 22:09 chasebish