Skip to content

[DART] Add Dart client option to NOT convert model property names to camel case #9384

@ghost

Description

Description

Model property names are converted to camel case. There should be an option to use the original case.

Converting the model property names to camel case does not match the naming convention in the OpenAPI spec that I am using, here. This breaks, and so for any property names that are not served with camel case names, in their original format, no data is matched, and an error results.

Swagger-codegen version

v3.0.7 I believe. I pulled this from the master branch today (18 Apr)

Swagger declaration file content or url

The definition that I am working with. Note: This is not a OpenAPI / Swagger definition issue. I think we need to add an option to NOT convert model property names to camel case.

Command line used for generation

This is based on bin/dart-petstore.sh. I am only generating a non-browser client, so everything after that is cleared.

java $JAVA_OPTS -jar $executable generate -t modules/swagger-codegen/src/main/resources/dart -i https://raw.githubusercontent.com/jackvz/mezzanine-cartridge-api/master/swagger.json -l dart -o client/mezzanine_dart_client -DhideGenerationTimestamp=true -DbrowserClient=false -DcamelCaseModelProperties=false -DpubName=mezzanine_dart_client -DpubDescription="A Dart client for the REST Web API for Mezzanine with Cartridge"

Steps to reproduce

Clone this repo.

Replace line 35 in bin/dart-petstore.sh with:

java $JAVA_OPTS -jar $executable generate -t modules/swagger-codegen/src/main/resources/dart -i https://raw.githubusercontent.com/jackvz/mezzanine-cartridge-api/master/swagger.json -l dart -o client/mezzanine_dart_client -DhideGenerationTimestamp=true -DbrowserClient=false -DcamelCaseModelProperties=false -DpubName=mezzanine_dart_client -DpubDescription="A Dart client for the REST Web API for Mezzanine with Cartridge"

Note how all of the generated Dart models, for example client/mezzanine_dart_client/lib/model/category, have property names that are camel cased, and here is the real issue: It also tries to find the data in camel case, in the models' fromJsons methods, and fails, errorring out.

Related issues/PRs

None that I could find specifically for Dart. I am putting in a PR that will resolve this.

Suggest a fix/enhancement

I suggest adding a Dart client option to NOT convert model property names to camel case, and am putting in a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions