Skip to content

[BUG][typescript-axios] generates incorrect boolean enum from V2 spec #15178

@ssukienn

Description

@ssukienn

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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

Incorrect generation of model for boolean enum type. It is similar problem to linked similar issue/pr. I know the schema is strange but I have no control over it.

openapi-generator version

latest docker image, 6.6.0-SNAPSHOT at the time of writing

OpenAPI declaration file content or url
{
  "swagger": "2.0",
  "info": {
    "title": "",
    "version": ""
  },
  "host": "test.com",
  "basePath": "/api",
  "paths": {},
  "definitions": {
    "Commodity": {
      "type": "object",
      "properties": {
        "active": {
          "type": "boolean",
          "format": "boolean",
          "enum": [
            "true",
            "false"
          ]
        }
      }
    }
  }
}
Generation Details

Config can be seen below. Generated output creates:

/**
    * @export
    * @enum {string}
    */
export enum CommodityActiveEnum {
    TRUE = true,
    FALSE = false
}

which is incorrect. Should be smth like type = true | false or normalize to strings

Steps to reproduce
  1. Create some dir for docker volume with config.yaml, schema.yaml (content above), and generate.sh script (or run inline)
#!/bin/bash

VOLUME_PATH=...
docker run --rm \
  -v "${VOLUME_PATH}":/openapi openapitools/openapi-generator-cli generate \
  -i /openapi/schema.yaml \
  -g typescript-axios \
  -o /openapi/output" \
  -c /openapi/config.yaml \
  --skip-operation-example

config.yaml:

snapshot: false
supportsES6: true
allowUnicodeIdentifiers: true
apiPackage: api
modelPackage: model
withSeparateModelsAndApi: true
enumPropertyNaming: UPPERCASE
stringEnums: true
useSingleRequestParameter: true
  1. run ./generate.sh
Related issues/PRs

Related to #9024

Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions