galasa-dev / projectmanagement

Project Management repo for Issues and ZenHub
7 stars 3 forks source link

openapi2beans generator to use a @SerializedName("<snake_cased_name>") annotation #1868

Closed Wyvinar closed 3 weeks ago

Wyvinar commented 1 month ago

Story

As a galasa developer, I want to specify snake_case variable names in fields within the openapi.yaml document, and when I do I want java code generated from those labels to be camelCase variable names in java code, with annotations such that Gson will render them as the original snake_case in any generated json documents, so the generated java code is more likely to conform to Java code naming standards.

Background

Examples

schemaType:
  type: object
  properties:
    snake_case:
      type: string

should become

class SchemaType {
...
    @SerializedName("snake_case")
    private String snakeCase;
...

The template would likely look like (at least for the single variable):

{{#SerializedOverrideName}}
@SerializedName("{{&.}}")
{{/SerializedOverrideName}}
[variable stuff continued]

Tasks