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

[BUG] [TYPESCRIPT] [DART] Missing enum key with non-latin characters #16928

Open
5 of 6 tasks
MonteePoke opened this issue Oct 27, 2023 · 0 comments
Open
5 of 6 tasks

Comments

@MonteePoke
Copy link

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

First enum key-value generates with missing key 1 when enum values contain non-latin characters

openapi-generator version

typescript-angular

export namespace ResOrderDto {
    export type StatusEnum = 'À' | 'Á' | 'Â' | 'Ã' | 'Ä';
    export const StatusEnum = {
        : 'À' as StatusEnum,
        2: 'Á' as StatusEnum,
        3: 'Â' as StatusEnum,
        4: 'Ã' as StatusEnum,
        5: 'Ä' as StatusEnum
    };
}

dart-dio

class ResOrderDtoStatusEnum extends EnumClass {

  @BuiltValueEnumConst(wireName: r'À')
  static const ResOrderDtoStatusEnum  = _$resOrderDtoStatusEnum_;
  @BuiltValueEnumConst(wireName: r'Á')
  static const ResOrderDtoStatusEnum 2 = _$resOrderDtoStatusEnum_2;
  @BuiltValueEnumConst(wireName: r'Â')
  static const ResOrderDtoStatusEnum 3 = _$resOrderDtoStatusEnum_3;
  @BuiltValueEnumConst(wireName: r'Ã')
  static const ResOrderDtoStatusEnum 4 = _$resOrderDtoStatusEnum_4;
  @BuiltValueEnumConst(wireName: r'Ä')
  static const ResOrderDtoStatusEnum 5 = _$resOrderDtoStatusEnum_5;

  static Serializer<ResOrderDtoStatusEnum> get serializer => _$resOrderDtoStatusEnumSerializer;

  const ResOrderDtoStatusEnum._(String name): super(name);

  static BuiltSet<ResOrderDtoStatusEnum> get values => _$resOrderDtoStatusEnumValues;
  static ResOrderDtoStatusEnum valueOf(String name) => _$resOrderDtoStatusEnumValueOf(name);
}
OpenAPI declaration file content or url

Json url

Generation Details

@openapitools/openapi-generator-cli (npm package) was used to generate code
Npm package downloaded lastest jar file (7.0.1.jar)

Following openapitools.json was used to configure CLI

{
  "$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
  "spaces": 2,
  "generator-cli": {
    "version": "7.0.1",
    "generators": {
      "mobile": {
        "generatorName": "dart-dio",
        "output": "#{cwd}/mobile/#{name}",
        "glob": "swagger/spec.json",
        "skip-validate-spec": true
      },
      "front": {
        "generatorName": "typescript-angular",
        "output": "#{cwd}/front/#{name}",
        "glob": "swagger/spec.json",
        "skip-validate-spec": true
      }
    }
  }
}

Executing npm run openapi-generator-cli generate led to next generator calls:

java -jar "E:\Projects\backend\node_modules\@openapitools\openapi-generator-cli\versions\7.0.1.jar" generate --input-spec="E:\Projects\backend\swagger\spec.json" --generator-name="typescript-angular" --output="E:\Projects\backend/front/spec" --skip-validate-spec
java -jar "E:\Projects\backend\node_modules\@openapitools\openapi-generator-cli\versions\7.0.1.jar" generate --input-spec="E:\Projects\backend\swagger\spec.json" --generator-name="dart-dio" --output="E:\Projects\backend/mobile/spec" --skip-validate-spec
Steps to reproduce
  1. npm run openapi-generator-cli generate
Related issues/PRs

Issue 893 had issues with Japanese characters, but author used different languages and had different problem

Suggest a fix

Not skipping 1 would be nice ☻

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

No branches or pull requests

1 participant