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

Trailing underscore gets removed while parsing #114

Open
zellidev0 opened this issue Oct 30, 2023 · 1 comment
Open

Trailing underscore gets removed while parsing #114

zellidev0 opened this issue Oct 30, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@zellidev0
Copy link

zellidev0 commented Oct 30, 2023

Description of the bug

Parsing the following spec produces invalid dart code.
The error is, that the class attribute package_ gets renamed to package but this one already exists.

Steps to reproduce

parse this file.

{
    "openapi": "3.0.1",
    "info": {
        "title": "my-service",
        "version": "1.0"
    },
    "servers": [
        {
            "url": "/my-service"
        }
    ],
    "security": [
        {
            "Authorization": []
        }
    ],
    "paths": {
        "/api/v2/subscription/cancel": {
            "delete": {
                "tags": [
                    "subscription-v-2-controller"
                ],
                "operationId": "cancelSubscription_2",
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "WechatPayRedirectToAndroidApp": {
                "type": "object",
                "properties": {
                    "timestamp": {
                        "type": "string"
                    },
                    "package_": {
                        "type": "string"
                    },
                    "package": {
                        "type": "string"
                    }
                }
            }
        }
    }
}
@Openapi(
  additionalProperties: AdditionalProperties(
    pubName: 'openapi_my_service',
  ),
  alwaysRun: true,
  inputSpecFile: 'lib/src/common/openapi_specs/my_service.json',
  generatorName: Generator.dart,
  outputDirectory: '../generated/my_service/',
)
class MyServiceOpenapiGeneratorConfig {}

Expected behavior

The variable gets not renamed, or I have the option to specify how it will be renamed.

Logs

:::::::::::::::::::::::::::::::::::::::::::
::      Openapi generator for dart       ::
:::::::::::::::::::::::::::::::::::::::::::

[INFO] openapi_generator on lib/src/common/openapi_clients.dart:Running following command to generate openapi client - [ generate -o=../generated/my_service/ -i=lib/src/common/openapi_specs/my_service.json -g=dart --additional-properties=allowUnicodeIdentifiers=false,ensureUniqueParams=true,useEnumExtension=true,prependFormOrBodyParameters=false,pubName=openapi_my_service,legacyDiscriminatorBehavior=true,sortModelPropertiesByRequiredFlag=true,sortParamsByRequiredFlag=true,wrapper=none ]
[INFO] openapi_generator on lib/src/common/openapi_clients.dart:Openapi generator completed successfully.
[INFO] openapi_generator on lib/src/common/openapi_clients.dart:Installing dependencies with generated source. flutter pub get
[INFO] openapi_generator on lib/src/common/openapi_clients.dart:Install completed successfully.
[INFO] openapi_generator on lib/src/common/openapi_clients.dart:Skipping source gen because generator does not need it.
[INFO] openapi_generator on lib/src/common/openapi_clients.dart:


### Screenshots

_No response_

### Platform

macOS

### Library version

4.12.1

### Flutter version

3.13.4

### Flutter channel

stable

### Additional context

_No response_
@zellidev0 zellidev0 added the bug Something isn't working label Oct 30, 2023
@Vitaliy-Svinchyak
Copy link

Same bug with _id and id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants